Boost logo

Boost Users :

From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-08-27 09:34:33


> > I think what you want is something like
> > bind( &Controller::DoSomething,
> >          bind( &A::GetController, _1 ) );
>
> That didn't work when I tried earlier, either because bind()
> produces a function instead of a pointer to a Controller or because
> GetController returns a reference instead of a pointer.

When binding member pointers, LL accepts either pointers or references
as the object argument, and the above should thus work.

This example works for me:

#include "boost/lambda/bind.hpp"
#include "boost/lambda/lambda.hpp"

#include <iostream>

using namespace boost;
using namespace boost::lambda;

class Controller {
public:
  void DoSomething() { std::cout << "Hello World!"; };
};

class View {
  Controller& contr;
public:
  View(Controller& c) : contr(c) {};
  Controller& GetController() { return contr; }
};

int main () {

  Controller c;
  View v(c);
  
  bind(&Controller::DoSomething,
    bind(&View::GetController, _1))(v);

};

/Jaakko

>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>

-- 
--
-- Jaakko Järvi                       email: jajarvi_at_[hidden]
-- Post Doctoral Fellow               phone: +1 (812) 855-3608
-- Pervasive Technology Labs          fax:   +1 (812) 855-4829
-- Indiana University, Bloomington

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net