16 Sep
2006
16 Sep
'06
2:03 a.m.
On 9/15/06, Alexander Shyrokov
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?
boost::bind( f, _2 ) is generating a binary functor that, when called, calls the unary function f and passes it the second argument to the functor.
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 )
Iterators are supposed to be cheap to copy and as far as I can tell it's just the usual way to pass the end iterator. There might also be some weird issues with argument deduction in some compilers. ( I seem to recall something about that... ) HTH, Scott