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. Anyone? Thanks -delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Delfin Rojas Sent: Friday, February 18, 2005 11:09 AM To: boost-users@lists.boost.org Subject: RE: [Boost-users] Boost lambda and shared_ptr
Can somebody comment in this, please?
Thanks
-delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Delfin Rojas Sent: Wednesday, February 16, 2005 7:09 PM To: boost-users@lists.boost.org Subject: [Boost-users] Boost lambda and shared_ptr
Hi all,
I would like to know if there is a way right now or if there is a plan to add the possibility of using bll::bind (boost lambda bind) with shared_ptr as one uses it with normal pointers.
This functionality is currently supported by boost::bind but I cannot find a way to make it work with lambda bind.
For example:
class CFoo { public: void SetI(const int & nI) { ... } };
std::vector
vpFoos; std::vector< boost::shared_ptr<CFoo> > vpFoos2; //Assume I initialize the vectors
std::for_each(vpFoos.begin(),vpFoos.end(), boost::lambda::bind(&CFoo::SetI, boost::lambda::_1, 5)); //Works great
//I _cannot_ find to make this work with vpFoos2; I _can_ make it work with boost::bind.
Thanks
-delfin
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users