问题
When dealing with generic code in C++, I would find a std::identity
functor (like std::negate
) very useful. Is there a particular reason why this is not present in the standard library?
回答1:
Soon after std::identity was introduced, issues began to appear, starting with conflicts to pre-cpp98 definitions of std::identity appearing as extensions: https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/vrrtKvA7cqo This site might give a little more history for it.
来源:https://stackoverflow.com/questions/35907848/is-there-a-reason-why-there-is-not-stdidentity-in-the-standard-library