完成处理程序中的Boost绑定错误
Boost binding error in completion handler
我遇到一个绑定错误
/usr/local/include/boost/bind/bind.hpp:457:错误:无效使用void表达式
我的程序是关于使用回调处理程序的异步操作,如下所示:
template<typename Handler>
void async_monitor(Handler handler) {
stream_descriptor_.async_read_some(
boost::asio::buffer(read_buffer_),
boost::bind(&dir_monitor_impl::handle_monitor<Handler>, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
handler));
}//IF I remove this code, the compilation success
和处理程序声明:
template<typename Handler>
void handle_monitor(boost::system::error_code &ec,
std::size_t bytes_transferred, Handler handler){
}
最后,这些异步操作的用法如下:
template <typename Handler>
void start_async_monitor(implementation_type &impl, Handler handler)
{
//this->async_monitor_io_service_.post(monitor_operation<Handler>(impl, this->get_io_service(), handler));
impl->async_monitor(handler);
}
你们能帮我解释一下这个错误吗,非常感谢!
处理程序签名必须如下(注意const):
void handle_monitor(const boost::system::error_code &ec, std::size_t bytes_transferred, Handler handler)
相关文章:
- Boost 绑定和"result_type":不是成员,对 c++03 友好
- ROS 订阅回调 - 使用 boost::绑定成员函数
- 当Boost ::绑定模板函数时,模板参数扣除/替换失败
- 使用boost ::绑定结果作为参数
- boost ::绑定发送变量的回调args到回调函数
- 传递 boost::绑定参数作为参数
- boost::绑定在存储时不保存部分参数
- boost::绑定静态函数的参数
- 使用 boost :: 绑定将映射作为参数传递
- boost::与boost:asio绑定在一起.boost::绑定后续
- boost::与boost:asio绑定在一起.boost::绑定不起作用,从示例中复制
- Boost绑定和Boost函数,将带有参数的函数存储在向量中,然后执行它们
- boost::绑定具有默认值的成员函数
- boost::绑定到类成员函数
- boost::绑定重载函数
- boost绑定或返回常量的lambda函数
- boost::绑定内部副本
- boost::绑定模板化的函子
- 使用boost绑定成员函数
- boost::绑定动态参数