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

Why do objects returned from bind ignore extra arguments?

Ignoring extra arguments is a lot simpler to implement, and can actually be useful. In a typical implementation e.g. libstdc++ (g++), the approach taken is to collect the operator() arguments into a tuple and then let the std::placeholder bind arguments extract them as required. Enforcing argument count would require counting the number of used placeholders, … 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