Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-02-18 18:06:07


Delfin Rojas wrote:
> I guess I had not done my homework all the way. I found a way to make
> bll::bind work when the placeholder is a shared_ptr by dereferencing
> it. In other words,
>
> std::for_each(vpFoos2.begin(),vpFoos2.end(),
> boost::lambda::bind(&CFoo::SetI,
> *boost::lambda::_1, 5));
>
> While this solves most of my problems I still cannot make it work for
> this other case:
>
> shared_ptr<CFoo> pFoo(new CFoo);
> std::vector<int> vnValues(10, 1);
> std::for_each(vnValues.begin(), vnValues.end(),
> boost::lambda::bind(&CFoo::SetI, pFoo, boost::lambda::_1));
>
> I tried dereferencing pFoo but it didn't work.

pFoo.get() should work. ref(*pFoo) or var(*pFoo) might also work.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net