|Category: functors ||Component type: type |
Identity is a UnaryFunction that represents the identity function: it takes a single argument
x, and returns
int x = 137;
assert(x == id(x));
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h. This class is an SGI extension; it is not part of the C++ standard.
|Parameter ||Description ||Default |
|The function object's argument type, and return type.  || |
Public base classes
identity's members are defined in the AdaptableUnaryFunction requirements.
Identity does not introduce any new members.
 It is essential that the return type and the argument type are the same: generalizing
identity to allow them to differ would not work. The reason is that
identity returns a const reference to its argument, rather than a copy of its argument. If
identity were allowed to perform a conversion, then this would be a dangling reference.