|
ALINK="#ff0000">
identity<T>
DescriptionIdentity is a Unary Function that represents the identity function: it takes a single argument x, and returns x.Exampleint main() { int x = 137; identity<int> id; assert(x == id(x)); } DefinitionDefined 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.Template parameters
Model ofAdaptable Unary FunctionType requirementsNone.Public base classesunary_function<T, T>Members
New membersAll of identity's members are defined in the Adaptable Unary Function requirements. Identity does not introduce any new members.Notes[1] 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. See alsoThe function object overview, select1st, select2nd, project1st, project2ndCopyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation
|