Boost logo

Boost :

Subject: Re: [boost] Should pass boost::asio::io_service by raw pointer or smart pointer?
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2018-12-20 04:14:28


On Wed, Dec 19, 2018 at 4:30 PM hh h via Boost <boost_at_[hidden]> wrote:
> In many examples and even implementations, programmers like to pass
> boost::asio::io_service by raw pointer:

Those examples are wrong. `io_context` should be passed by reference.

> Will this cause issues to pass raw pointer for large size of classes,
> should it be replaced by passing smart pointer:

A smart pointer is less efficient than a pointer, all else equal. But
you shouldn't be using any form of pointer, the io_context (legacy
name: io_service) is passed by reference. All of the Beast and Asio
examples demonstrate this:

<https://github.com/boostorg/beast/tree/develop/example>
<https://github.com/boostorg/asio/tree/develop/example>

Regards


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk