proxygen
|
#include <Utility.h>
Public Member Functions | |
template<class T > | |
constexpr T && | operator() (T &&x) const noexcept |
A simple function object that passes its argument through unchanged.
Example:
int i = 42; int &j = Identity()(i); assert(&i == &j);
Warning: passing a prvalue through Identity turns it into an xvalue, which can effect whether lifetime extension occurs or not. For instance:
auto&& x = std::make_unique<int>(42); cout << *x ; // OK, x refers to a valid unique_ptr.
auto&& y = Identity()(std::make_unique<int>(42)); cout << *y ; // ERROR: y did not lifetime-extend the unique_ptr. It // is no longer valid