繁体   English   中英

std :: bind到std :: function?

[英]std::bind to std::function?

我使用这个得到一个编译错误:

std::vector<std::function<int(int)>> functions;

std::function<int(int, int)> foo = [](int a, int b){ return a + b; };
std::function<int(int)> bar = std::bind(foo, 2);

functions.push_back(bar);

错误是:

/usr/include/c++/4.6/functional:1764:40:错误:无法调用'(std :: _ Bind(int)>)(int)'

有人能告诉我如何将std::bind转换为std::function吗?

std::function<int(int)> bar = std::bind(foo, 2, std::placeholders::_1);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM