9 Dec
2009
9 Dec
'09
12:10 a.m.
Vadim Guchenko wrote:
Hello, All!
Is there a simple way to create a functor that returns one of its arguments _1, _2, ...? Does standard unary functor exist, which simply returns its argument unchanged? I.e.:
template<typename T> struct arg: public std::unary_function
{ T operator()(const T &x) const { return x; } };
It's not part of the current standard, but many implementations provide std::identity as an extension. (It will be standard in C++0x.)