
18 Aug
2009
18 Aug
'09
3:41 a.m.
On Tue, Aug 18, 2009 at 10:07 AM, Robert Jones <robertgbjones@gmail.com>wrote:
Use bind to call a free function on a vector of shared_ptrs?
struct A { }; void f(const A&); std::vector<boost::shared_ptr<A> > v;
for_each(v.begin(), v.end(), boost::bind(f, ???? ) );
what goes where ???? is?
Two tactics spring to mind. One is to use boost::make_indirect_iterator on v.begin() and v.end() and just pass in f instead of the boost::bind(...). The other is to use RangeEx (shameless plug) thus: using namespace boost::adaptors; boost::for_each(v | indirected, f);
Thanks, Rob.
Regards, Neil Groves
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users