I've an expression that I need to put in std::transform
as callback, but I don't want to write another method for it. I want to express the expression _1.second->pair().first == r
to boost::lambda
assuming _1
is the only argument passed to it of type std::pair
I've a generic shorthand functors util::shorthand::pair_second
and util::shorthand::pair_first
which returns second and first item of a pair.
I can do boost::bind(util::shorthand::pair_second, _1)
but then do what ? how to implement rest of the expression ?
-1.second
is templated of type Connection<T>
.I cannot use C++11
Take a look at Boost.Lambda bind expressions. You can use them to bind member functions and member data.
I don't have enough information as to the types that you are using, but something like this should work:
Note: The
bind
in this sample is the one in theboost::lambda
namespace, not Boost.Bind.EDIT: Complete, compilable example: