首页 > 代码库 > C++ 11 bind

C++ 11 bind

#include <iostream>#include <functional>using namespace std;int add(int a, int b) {    return a + b;}int main() {        function<int (int, int)> f = add;        cout<<f(100, 100)<<endl;        function<int (int)> fsingle = bind(add, 123, placeholders::_1);        cout<<fsingle(111)<<endl;        return 0;}

跟javascript,python这类动态语言接近了

C++ 11 bind