Hello Rob,
> Subject: [Boost-users] [bind] How do I....?
You have two options if you want to use binders:>
> 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?
>
1) Use Boost.Bind with nested binds, binding operator* of shared_ptr in the inner bind.
for_each(vec.begin(), vec.end(), boost::bind(&foo, boost::bind(&boost::shared_ptr<A>::operator*, _1)));
2) Use Boost.Lambda's bind() and dereference the placeholder directly in the bind expression.
for_each(vec.begin(), vec.end(), bind(&foo, *_1));