【发布时间】:2011-02-10 10:20:01
【问题描述】:
我们最多可以传递多少个参数给 boost::bind()
【问题讨论】:
标签: c++ boost-bind
我们最多可以传递多少个参数给 boost::bind()
【问题讨论】:
标签: c++ boost-bind
【讨论】:
即使不能切换到 C++11,也应该考虑从 boost::function 切换到 TR1 函数,这是 C++11 的预览版
基本上,最初的 boost::function 成为了 C++ 标准库的一部分,现在它是用可变参数模板定义的。简而言之,这意味着不再有硬性限制(但如果您需要超出 _19 的内容,则可能需要定义额外的占位符变量)
要从 boost::function 切换到 std::tr1,请执行以下操作
查找所有出现的#include <boost/function> 和#include <boost/bind>
并将它们替换为:
#include <tr1/functional>
using std::tr1::function;
using std::tr1::bind;
using std::tr1::placeholders::_1;
using std::tr1::placeholders::_2;
...
这应该可以作为替代品。如果你以后碰巧切换到 C++11,就扔 去掉“tr1”部分。
【讨论】: