Boost logo

Boost Users :

From: khuroth (dansilva_at_[hidden])
Date: 2002-08-27 09:52:27


Oh, that works, thanks!
To clarify though, for a member function, bind can be passed either
an object pointer, an object reference, a function that returns an
object pointer (the result of another bind), or a function that
returns an object reference?

I'm definitely a fan of this library now =)

--- In Boost-Users_at_y..., Jaakko Jarvi <jajarvi_at_c...> wrote:
> > > 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_y...>
> >
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
> >
>
> --
> --
> -- Jaakko Järvi email: jajarvi_at_c...
> -- 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