|
Boost Users : |
From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-08-07 14:30:02
On Wednesday 07 August 2002 02:27 pm, Steven E. Harris wrote:
> Douglas Gregor <gregod_at_[hidden]> 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
Boost-users 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