How does boost bind work behind the scenes in general?

I like this piece of the bind source: template<class R, class F, class L> class bind_t { public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {} #define BOOST_BIND_RETURN return #include <boost/bind/bind_template.hpp> #undef BOOST_BIND_RETURN }; Tells you almost all you need to know, really. The bind_template header expands to a list of … Read more

Difference between C++11 std::bind and boost::bind

boost::bind has overloaded relational operators, std::bind does not. boost::bind supports non-default calling conventions, std::bind is not guaranteed to (standard library implementations may offer this as an extension). boost::bind provides a direct mechanism to allow one to prevent eager evaluation of nested bind expressions (boost::protect), std::bind does not. (That said, one can use boost::protect with std::bind … Read more

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