相关疑难解决方法(0)

std :: bind应该与boost :: asio兼容吗?

我正在尝试调整其中一个boost :: asio示例,尽可能使用c ++ 11/TR1库.原始代码如下所示:

void start_accept()
{ 
  tcp_connection::pointer new_connection =
    tcp_connection::create(acceptor_.get_io_service());

  acceptor_.async_accept(new_connection->socket(),
      boost::bind(&tcp_server::handle_accept, this, new_connection,
         boost::asio::placeholders::error));
}
Run Code Online (Sandbox Code Playgroud)

如果我更换boost::bindstd::bind如下:

void start_accept()
{ 
  tcp_connection::pointer new_connection =
    tcp_connection::create(acceptor_.get_io_service());

  acceptor_.async_accept(new_connection->socket(),
      std::bind(&tcp_server::handle_accept, this, new_connection,
                 boost::asio::placeholders::error ) );
      // std::bind(&tcp_server::handle_accept, this, new_connection, _1 ) );
}
Run Code Online (Sandbox Code Playgroud)

我收到一条大错误消息,结尾为:

/usr/include/c++/4.4/tr1_impl/functional:1137: error: return-statement with a value, in function returning 'void'
Run Code Online (Sandbox Code Playgroud)

我使用的是增强版1.47的gcc 4.4版

我希望boost :: bind和std :: bind可以互换.

c++ boost boost-asio c++11

43
推荐指数
1
解决办法
6125
查看次数

标签 统计

boost ×1

boost-asio ×1

c++ ×1

c++11 ×1