c++functionc++11identitynegate

Is there a reason why there is not std::identity in the standard library?


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?


Solution

  • 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.