boost::lambda::bind - how to address the member variable in the expression?

Example: struct A { int i; }; class C { public: void store(int i); }; boost::ptr_vector<A> lst; C c; std::for_each (lst.begin(), lst.end(), boost::lambda::bind(&C::store, c, boost::lambda::_1.i)); Question: construct boost::lambda::_1.i is invalid. I understand why it is so, but can't find a way to reference member variable in this case. Any advise or referral to the specific paragraph in boost::lambda documentation is appreciated. Thanks.

On Thu, 20 May 2010 12:41:37 +0200, Archie14
Example:
struct A { int i; };
class C { public: void store(int i); };
boost::ptr_vector<A> lst; C c;
std::for_each (lst.begin(), lst.end(), boost::lambda::bind(&C::store, c, boost::lambda::_1.i));
std::for_each(lst.begin(), lst.end(), boost::lambda::bind(&C::store, boost::ref(c), boost::lambda::bind(&A::i, boost::lambda::_1))); HTH, Boris
participants (2)
-
Archie14
-
Boris Schaeling