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

Haatschii picture Haatschii · May 11, 2012 · Viewed 19.7k times · Source

Is there any difference between the two? Or am I safe to replace every occurrence of boost::bind by std::bind in my code and thereby remove the dependence on Boost?

Answer

ildjarn picture ildjarn · May 11, 2012
  • 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 if they want, or trivially reimplement it on their own.)

  • std::bind provides a direct mechanism to allow one to treat any user defined functor as a nested bind expression in order to force eager evaluation (std::is_bind_expression: [func.bind.isbind]/1, [func.bind.bind]/10), boost::bind does not.