
On Wednesday 07 August 2002 02:27 pm, Steven E. Harris wrote:
Douglas Gregor <gregod@cs.rpi.edu> writes:
Boost.Bind can do that:
for_each(my_map.begin(), my_map.end(), bind(&Point::Reset, bind(&map<int, Point *>::value_type::second, _1)));
So can Boost.Lambda:
for_each(my_map.begin(), my_map.end(), bind(&Point::Reset, (&_1)->*&map<int, Point *>::value_type::second));
Again, I can't see how this can work. "second" is the name of a member, not a function. You need a "pair select functor" to grab the first or second member from a pair. I've written a couple of these to use in conjunction with the projection_iterator adaptor.
It works, I promise :) Boost.Bind has an overload that supports pointers to data members by automagically transforming them into unary function objects. Boost.Lamda overloads the ->* operator for pointers to data members. Doug