Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2006-02-07 10:20:18


On 2/7/06, Christopher Kohlhoff <chris_at_[hidden]> wrote:

[snip]

> Why should it be? A socket has an identity and is not a
> value-type object. And I don't want the interface to impose the
> cost of using a shared pointer when it's not required.

That's why it should be able to have both, one that's moveable and
another that's reference counted.

> In many applications the socket object might be on the stack, or
> it could be a member of some other class, e.g.:

Moveable would work nicely this way, but hardly well without even
moveable-semantics.

[snip]

>
> where the outer class is the one that's in a shared_ptr (as it
> is in my preferred approach). Consider also stream layering,
> e.g.:
>
> asio::ssl::stream<asio::stream_socket> socket;
>
> In this case a reference counted stream_socket implementation
> gives no advantage - it's the entire composed stream object that
> would need to be reference counted. Hence the shared_ptr should
> be external to the stream, not internal.

asio::ssl::stream should give a reference counted and a moveable
interface too, and use the moveable internally.

[snip]

>
> Cheers,
> Chris

--
Felipe Magno de Almeida

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