我使用这个编译错误:
std::vector<std::function<int(int)>> functions; std::function<int(int,int)> foo = [](int a,int b){}; std::function<int(int)> bar = std::bind(foo,2); functions.push_back(bar);
我得到的错误是:
/usr/include/c++/4.6/functional:1764:40: error: no match for call to '(std::_Bind<std::function<int(int,int)>(int)>) (int)'
有人可以告诉我如何将std :: bind转换成std ::函数?
解决方法
std::function<int(int)> bar = std::bind(foo,2,std::placeholders::_1);