Delfin Rojas wrote:
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.
My guess is that CFoo::SetI is not a const member function. Because *pFoo is being passed by const reference, compilation fails. You can workaround this in one of the following ways: boost::lambda::bind(&CFoo::SetI, pFoo.get(), // returns a raw pointer boost::lambda::_1)); boost::lambda::bind(&CFoo::SetI, boost::ref(*pFoo), // wrap *pFoo so it is passed // by (non-const) reference boost::lambda::_1)); boost::lambda::bind(&CFoo::SetI, boost::lambda::var(*pFoo), // wrap *pFoo so it is passed // by (non-const) reference boost::lambda::_1)); HTH, Best regards, João Abecasis