Boost logo

Boost Users :

Subject: Re: [Boost-users] bind for_each and a range of functors
From: Peter Dimov (pdimov_at_[hidden])
Date: 2008-10-16 18:12:07


Michael Marcin:
> Let's say I have a std::list of a functor with a member function
>
> virtual operator()( int, int )
>
> Is there an easy way to call each function in this list using for_each?
>
> Intuitively I'd expect to be able to do something like:
>
> void call_each( std::list<functor>& l )
> {
> std::for_each( l.begin(), l.end(), boost::bind(_1,5,20) );
> }

With boost::bind, which doesn't evaluate its first argument, you'll need to
use apply<>, as explained in

http://www.boost.org/doc/libs/1_36_0/libs/bind/bind.html#nested_binds


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