
23 Mar
2010
23 Mar
'10
9:49 a.m.
Hi All In this bit of code.... #include <algorithm> #include <vector> #include "boost/bind.hpp" struct A { int double_it( int i ) { return i * 2; } } a; std::vector< int > v; int main( ) { for ( std::vector< int >::iterator i = v.begin( ); i != v.end( ); ++ i ) { a.double_it( * i ); } // Write it as a for_each/bind std::for_each( v.begin(), v.end(), boost::bind( & A::double_it, boost::ref( a ), _1 ) ); } Is that last line the idiomatic way of writing the bind expression? Thanks, Rob.