Robert Jones
In the documentation of Boost.MemberFunction it suggests that a useful purpose for it would be to implement overloads of std algorithms, and indeed other similar algorithms such that the final callable parameter could be a simple pointer to member.
struct X { bool method( ); };
std::vector<X> xs;
for_each( xs.begin( ), xs.end( ), & X::method );
or from Boost.Range
boost::for_each( xs, &X::method );
Is such a facility implemented anywhere in Boost?
Where I'm really going with this, is that I'd like to see versions of Boost.Range adaptors which support the same facility, so I can say, for example
for_each( xs | filtered( & X::method ), doSomething );
rather than, as at present,
for_each ( xs | filtered( bind( & X::method, _1 ) ), doSomething );
and similarly for transformed.
Thanks,
- Rob.
I don't know Boost.MemberFunction and couldn't find any documentation for it, could you provide a link? But from what I can gather in your message, boost::mem_fn seems to be exactly this: for_each( xs.begin( ), xs.end( ), boost::mem_fn(& X::method) ); Granted, it is not exactly what you want, but gets very close. HTH, Philipp Moeller