Category: functors | Component type: type |
int main() { int x = 137; identity<int> id; assert(x == id(x)); }
Parameter | Description | Default |
---|---|---|
T | The function object's argument type, and return type. [1] |
Member | Where defined | Description |
---|---|---|
argument_type | Adaptable Unary Function | The type of identity's argument: T. |
result_type | Adaptable Unary Function | The type of the result: T. [1] |
const T& operator()(const T&) const | Adaptable Unary Function | Function call. The return value is simply the argument. |
[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.
privacy policy | | | contact us |
Copyright © 1993-2001 Silicon Graphics, Inc. All rights reserved. | | | Trademark Information |