开发者

boost::asio and make_shared does not work?

I seem to be able to use boost::make_shared everywhere except with boost asio?

example: _ioService = boost::shared_ptr<io_service>(new io_service)

if I turn this into: _ioService = boost::make_shared<io_service开发者_如何学JAVA>()

I get all kinds of errors?

Same problem if I take:

_acceptor = boost::shared_ptr<tcp::acceptor>(new tcp::acceptor(*_ioService));

and turn it into this: _acceptor = boost::make_shared<tcp::acceptor>(*_ioService);


As boost::asio::tcp::acceptor takes a boost::asio::io_service by non-const reference you need to change:

_acceptor = boost::make_shared<tcp::acceptor>(*_ioService);

to:

_acceptor = boost::make_shared<tcp::acceptor>(boost::ref(*_ioService));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜