16 Sep
2006
16 Sep
'06
1:33 a.m.
template
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