在客户端代码的不同部分同时使用boost::bind和std::tr1::bind
Using both boost::bind and std::tr1::bind in different parts of the client code
我使用了两个使用绑定功能的自定义库。其中一个使用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);
如何解决这个问题?对我来说,对库进行更改或使用不同库的可能性被排除在外。
最终std
中的占位符由性状类标识。
代替using namespace
占位符,使用traits类使boost占位符变成std
占位符。
如果这是不实际的,那么您的boost占位符可能也是如此:为两个占位符创建一组新的占位符令牌,并将其用于两个占位符
相关文章:
- boost::bind()类似的东西,但用于函数调用
- 泛化传递给 boost::bind 的参数
- Boost.Asio:不能使用 std::bind() 来指定回调
- boost::bind函数缓冲区的最大大小
- 自 1.55 以来,boost::bind / boost::function 中的奇怪行为变化
- 使用 boost::bind 进行订阅回调时出错
- 将 std::bind 应用于带有参数 <boost::asio::ip::tcp::socket> 时出错?
- 如何使用 boost::bind 附加参数?
- boost::bind 无法绑定到纯虚拟基类中定义的非静态函数模板成员类型
- 如何正确绑定成员函数与 boost::bind
- 将 boost::function 和 boost::bind 替换为模板
- Boost Asio - boost::bind 导致程序崩溃
- ioService.post(boost::bind(&myFunction, this, attr1, attri2) 不会发布作品
- 我可以使用 boost::bind 来存储不相关的对象吗?
- 在spirit parser Action中,在上下文参数上编译boost :: bind(成员函数)上的错误
- 如何使用 boost::bind 将返回 int 的函数转换为返回布尔值的函数
- boost::bind with member functions(作为boost::asio异步写入处理程序)
- 创建一个 boost::线程 带有 boost::bind() 或不带
- boost::bind & boost::function with partial args
- boost::bind, boost::shared_ptr and inheritance