Boost logo

Boost Users :

Subject: Re: [Boost-users] Member function varible callable...
From: Igor R (boost.lists_at_[hidden])
Date: 2010-05-11 11:08:25


> I have 2 functions like:
>
> struct obj {
>
>    void foo() {
>    };
>
>    void bar() {
>    };
>
> }
>
> How would I store this in a variable ... so that I can call the function via
> the variable later...

using boost::function;
using boost::bind;
obj o;
// NOTE that "o" will be copied
function<void()> callFoo = bind(&obj::foo, o), callBar = bind(&obj::bar, o);
callFoo();
callBar();


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