套接字创建的 Shared_Ptr - 出了什么问题?
所以我尝试:
boost::shared_ptr<tcp::socket> socket =
boost::make_shared<tcp::socket>(io_service);
如上所述此处。但它给我带来了一个错误:
编译器告诉我它无法转动(
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
我该怎么办?
So I try:
boost::shared_ptr<tcp::socket> socket =
boost::make_shared<tcp::socket>(io_service);
As described here. But It bring me an error:
Compiler tells me that it can not turn (
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
What shall I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
make_shared
时,您需要传递io_service
作为引用。You need to pass the
io_service
as a reference when usingmake_shared
.