
AMDG Zachary Turner wrote:
Thanks. On a related note, if a lambda placeholder refers to a structure, is there any way to access its members short of using bind and making a fake function to perform the access?
For example
struct foo { int x; int y; }; struct bar { int x, int y; };
foo f;
options.add_options() ("test", value<bar>()->notifier( var(f.x) = _1.x)));
is what I want. I've tried a variety of different things, most promising seemed to be
options.add_options() ("test", value<bar>()->notifier( var(f.x) = bind(&bar::x, _1)));
but this doesn't work either.
It ought to work. What's the error? The following works for me: #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> #include <iostream> struct foo { int x; int y; }; struct bar { int x; int y; }; int main() { foo f = { 1, 2 }; const bar b = { 3, 4 }; (boost::lambda::var(f.x) = boost::lambda::bind(&bar::x, boost::lambda::_1))(b); std::cout << f.x << std::endl; } In Christ, Steven Watanabe