
Hi All Here's a quickie for you.... Given struct A { void a(); }; type std::vector<boost::shared_ptr<A> > VecType; VecType v; for (VecType::iterator i=v.begin(); i != v.end(); ++i ) (*i)->a(); How can I write that as a for_each loop? for_each( v.begin(), v.end(), boost::bind( ????? ) ); Thanks, - Rob. ps I can't use lambda because boost.bind is already used, and the placeholder name collisions just aren't worth the pain.

On Fri, Jul 17, 2009 at 1:47 PM, Roman Perepelitsa < roman.perepelitsa@gmail.com> wrote:
std::for_each(v.begin(), v.end(), boost::mem_fn(&A::a));
Thanks Roman - I've missed a trick there! Is that also equivalent to for_each( v.begin(), v.end(), boost::bind(&A::a, _1)); ? Thanks. -- ACCU - Professionalism in programming - http://www.accu.org
participants (2)
-
Robert Jones
-
Roman Perepelitsa