c++11之bind

std::bind是个c++推出的新的特性,非常有用,让你写起来率试不爽。

#include <iostream>
using namespace std;

#include <functional>

int main() {
    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!


    auto a = bind([](int a,int b)->int{ return a+b; },placeholders::_1,2);
    cout<<a(1)<<endl; //小相当于调用这个匿名函数时传的参数是(1,2)
    return 0;
}
原文地址:https://www.cnblogs.com/mrblue/p/3262164.html