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;
}
复制代码

 

 

posted @   MrBlue  阅读(202)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示