【发布时间】:2025-12-31 07:20:15
【问题描述】:
我正在使用两个使用绑定功能的自定义库。 其中一个使用 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);
如何解决这个问题?我排除了对库进行更改或使用其他库的可能性。提前致谢。
【问题讨论】:
标签: c++ boost boost-bind stdbind