Boost logo

Boost Users :

From: Alexander Shyrokov (shirokov_at_[hidden])
Date: 2006-09-15 21:33:47


> template<class It, class F> void for_each_pair( It first, It last, F f )
> {
> for( ; first != last; ++first )
> {
> f( first->first, first->second );
> }
> }
>
> for_each_pair( a.begin(), a.end(), boost::bind( f, _2 ) );
Could you explain why _2 is used? It looks like f parameter should have
two parameters and we are using bind to use only 2nd parameter and
ignore the first one? Is it correct?

The second question: why last is not a constant and maybe taken by
reference? void for_each_pair( It first, const It& last, F f )

Thanks.

-- 
Regards,
     Alexander.                http://sjcomp.com

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