Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-05-13 08:33:59


From: "Giovanni Bajo" <giovannibajo_at_[hidden]>
>
> Since we are at it, can we dereference through boost::bind?
>
> std::list<int*> ml;
> void dosomething(int a) { }
>
> std::for_each(ml.begin(), ml.end(), boost::bind(domsething, deref(_1)));

Unfortunately not. :-) This is lambda territory. The best you can do is

bind(dosomething, bind<int>(deref, _1))

> > std::pair<int, int> * p = &x;
> > boost::bind(&std::pair<int, int>::first, _1)(p);
>
> Does that basically returns p->first? So, bind() automatically dereference
a
> pointer when using this feature?

bind doesn't; mem_fn does. bind(member-pointer, ...) is syntactic sugar for
bind(mem_fn(member-pointer), ...).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk