How to use boost bind with a member function

Use the following instead: boost::function<void (int)> f2( boost::bind( &myclass::fun2, this, _1 ) ); This forwards the first parameter passed to the function object to the function using place-holders – you have to tell Boost.Bind how to handle the parameters. With your expression it would try to interpret it as a member function taking no arguments. … Read more

how boost::function and boost::bind work

boost::function allows anything with an operator() with the right signature to be bound as the parameter, and the result of your bind can be called with a parameter int, so it can be bound to function<void(int)>. This is how it works (this description applies alike for std::function): boost::bind(&klass::member, instance, 0, _1) returns an object like … Read more