
Boost Users : 
Subject: [Boostusers] [Bind] How to create a functor which returns one of its arguments?
From: Vadim Guchenko (nomail_at_[hidden])
Date: 20091208 08:05:26
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, T> {
T operator()(const T &x) const { return x; }
};
Then I could write:
boost::bind(arg<int>(), _2)
to create a functor which returns the value of its second argument, or
boost::bind(arg<bool>(), true)
to create a functor which always returns true.
 Best regards, Vadim Guchenko [yhw at relost dot net].
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net