开发者

boost::asio and make_shared does not work?

开发者 https://www.devze.com 2023-02-19 08:55 出处:网络
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)

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

精彩评论

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