Boost logo

Boost Users :

From: Jeff F (TriumphSprint2000_at_[hidden])
Date: 2007-04-24 08:54:30


MainBrain wrote:
> Hello,
>
> im looking through http://www.boost.org/libs/functional/index.html,
> there are ways to access a class method but i cant find a way to
> access a method of an object.
>
> How can i write an adapter for "instance.bar()" in this example:
> class foo
> {
> int _i;
> public:
> bar(); // manipulates _i

did you mean: "void bar();"

> } instance;

I'm not quite sure what you're after, but does this help?

...

boost::function<void()> fnc = boost::bind( &foo::bar,
boost::ref(instance) );

fnc(); // evaluate instance.bar()

See http://www.boost.org/doc/html/function.html
and http://www.boost.org/libs/bind/bind.html

Jeff


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