I'm not exactly sure what you are trying to do, but here's some
explanation on bind and ->*
First, The dot operator cannot be overloaded, so you do this:
(_1 ->* &A::GetController).DoSomething
// DoSomething is not defined for (_1 ->* &A::GetController)
The semantics of ->* in general is rather tricky, and the Lambda Library
mimics that:
Here's a snippet of the LL docs:
For a built-in call like this, the result is kind of a delayed
member function call. Such an expression must be followed by a function
argument list, with which the delayed member function call is performed.
For example:
struct B { int foo(int); };
B* b = new B();
...
(b ->* &B::foo) // returns a delayed call to b->foo
// a function argument list must follow
(b ->* &B::foo)(1) // ok, calls b->foo(1)
(_1 ->* &B::foo)(b); // returns a delayed call to b->foo,
// no effect as such
(_1 ->* &B::foo)(b)(1); // calls b->foo(1)
The LL can figure out the return type when binding a pointer to member
function so you do no have to say bind
whoops, sorry about the typos. any A:: here is really View::
--- In Boost-Users@y..., "khuroth"
wrote: I have a View class that has some widgets, and a Controller class that controls the view, so the View class has a GetController() member function that returns a reference to its controller. When the View's constructor is called, GetController() would return a bad ref, but it would return a valid reference by the time a button is clicked... so what I'm trying to do is, inside the View constructor:
my_button.on_click = bind( (_1 ->* &A::GetController).DoSomething (), this );
but that obviously doesn't work... I'm even having trouble just saving the first part:
my_button.on_click = bind
(_1 ->* &A::GetController, this); also doesn't work... I tried defining the on_click member of the button as a boost::function<void> or a boost::function0<void> in the first example, and a boost::function
or boost::function0 in the second snip... I get immense compiler errors, so I'm not sure where I messed up. What am I doing wrong?
Yahoo! Groups Sponsor ADVERTISEMENT [ericsson_300x250.jpg] Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
-- -- -- Jaakko Järvi email: jajarvi@cs.indiana.edu -- Post Doctoral Fellow phone: +1 (812) 855-3608 -- Pervasive Technology Labs fax: +1 (812) 855-4829 -- Indiana University, Bloomington