在 C++11 之前我用过boost::bind很多boost::lambda。bind一部分进入了标准std::bind库(现在,我几乎不使用std::bind,因为我几乎可以用 C++ lambda 做任何事情。我能想到一个有效的用例std::bind:
struct foo
{
  template < typename A, typename B >
  void operator()(A a, B b)
  {
    cout << a << ' ' << b;
  }
};
auto f = bind(foo(), _1, _2);
f( "test", 1.2f ); // will print "test 1.2"
对应的 C++14 将是
auto f = []( auto a, auto b ){ cout << a << ' ' << b; }
f( "test", 1.2f ); // will print "test 1.2"
更短更简洁。(在 C++11 中,由于 auto 参数,这还不起作用。)是否有任何其他有效std::bind的用例可以击败 C++ lambdas 替代方案,或者std::bind对于 C++14 来说是多余的?