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

std::function and std::bind: what are they, and when should they be used?

std::bind is for partial function application. That is, suppose you have a function object f which takes 3 arguments: f(a,b,c); You want a new function object which only takes two arguments, defined as: g(a,b) := f(a, 4, b); g is a “partial application” of the function f: the middle argument has already been specified, and … Read more

How std::bind works with member functions

When you say “the first argument is a reference” you surely meant to say “the first argument is a pointer“: the & operator takes the address of an object, yielding a pointer. Before answering this question, let’s briefly step back and look at your first use of std::bind() when you use std::bind(my_divide, 2, 2) you … Read more