c++ - boost::bind 作为左值对象

标签 c++ functor boost-bind lvalue

有没有办法做这样的事情(MS VS 2008)?

boost::bind mybinder = boost::bind(/*something is binded here*/);
mybinder(/*parameters here*/); // <--- first call
mybinder(/*another parameters here*/); // <--- one more call

我试过了

int foo(int){return 0;}

boost::bind<int(*)(int)> a = boost::bind(f, _1);

但它不起作用。

最佳答案

int foo(int){return 0;}
boost::function<int(int)> a = boost::bind(f, _1);

关于c++ - boost::bind 作为左值对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7444170/

相关文章:

haskell - 仿函数的实例

c++ - 我应该如何从 parent 的插槽中删除子对象?可能是 boost::asio 特定的

c++ - 用 std::tr1::bind 替换 boost::bind 时出现问题

c++ - 创建一个真正的 headless QApplication 实例

c++ - 为什么 zlibs z_stream::next_in 不是常量?

c++ - 为什么要覆盖 operator()?

c++ - 从重载集中检索指向最佳匹配的指针而不调用

android - Google Play 游戏服务和 64 位 x86 支持

c++ - 如何准确地按照要求格式化我的输出?

C++ 仿函数模板