在客户端代码的不同部分使用boost :: bind和std :: tr1 :: bind

时间:2015-05-27 10:23:20

标签: c++ boost boost-bind stdbind

我正在使用两个使用绑定功能的自定义库。 其中一个使用std :: tr1中存在的绑定功能,而另一个使用boost bind

现在问题在于占位符。由于boost bind的占位符位于未命名的命名空间中,因此当我尝试编译代码时遇到以下错误

<file_name.cpp:line_no:char_no>: error: reference to '_1' is ambiguous
/usr/include/c++/4.6/tr1/functional:859:23: error: candidates are: std::tr1::_Placeholder<1> std::tr1::placeholders::{anonymous}::_1
<path>/common/include/boost/bind/placeholders.hpp:55:15: error:                 boost::arg<1> {anonymous}::_1

仅附加使用我正在使用的客户端代码中的boost绑定功能的行

f_args.f_cb = boost::bind(&MyProcess::flush, MyProcess::Type, _1, _2);

如何解决问题?我已经排除了对库进行更改或使用不同库的可能性。提前谢谢。

1 个答案:

答案 0 :(得分:0)

最终std中的占位符由特征类标识。

而不是using namespace占位符,使用traits类将增强占位符放入std占位符。

如果这不切实际,那么你的增强占位符可能也是如此:为两者创建一组新的占位符令牌,并将两者用于替换它们。

相关问题