
23 Mar
2010
23 Mar
'10
10:31 a.m.
On Tue, Mar 23, 2010 at 10:02 AM, Stuart Dootson
Your code is fine when the bound thing is a method - you could use '&a' rather than 'boost::ref(a)' (a pointer to 'a' can be used for a method call in place of a reference to 'a')
However, for your 'double_it', I'd personally just write a function rather than define a struct with a method. Then, 'a' is not needed and the bind would be:
std::for_each( v.begin(), v.end(), boost::bind( &double_it, _1 ) );
It does indeed, thanks Stuart. I would of course lift the method from the class in real code, but this is just for exposition. In practise, as ever, there are additional constraints. - Rob. -- ACCU - Professionalism in programming - http://www.accu.org