所以我试试:
boost::shared_ptr<tcp::socket> socket =
boost::make_shared<tcp::socket>(io_service);
如上所述here。但它给我带来了一个错误:
编译器告诉我它无法转动(
error C2664:
boost::asio::basic_stream_socket<Protocol>::basic_stream_socket(
boost::asio::io_service &))
'boost::asio::io_service *const ' into 'boost::asio::io_service &'
\include\boost\smart_ptr\make_shared.hpp
我该怎么办?
答案 0 :(得分:5)
使用io_service
时,您需要传递make_shared
作为参考。
boost::shared_ptr<tcp::socket> socket =
boost::make_shared<tcp::socket>(boost::ref(io_service));