Boost logo

Boost :

From: Giovanni P. Deretta (gpderetta_at_[hidden])
Date: 2006-02-07 00:05:10


Felipe Magno de Almeida wrote:
> On 2/7/06, Giovanni P. Deretta <gpderetta_at_[hidden]> wrote:
>
> [snip]
>
>
>>You could argue that as this is a useful behavior stream_socket should
>>have pointer semantics by default and be reference counted. But you
>>would force the space and time overhead of a shared_ptr to everybody
>>(btw, shared_ptr still require dynamic allocation of the reference
>>counter).
>
>
> Yes and No.
> I'm arguing that it is a very useful behavior that should be supported
> by the library. The default I'm not quite sure, maybe yes (it is the
> safest choice, you wont be able to use the dangling socket without
> knowing it), maybe no (unnecessary overhead for the reference count).
> Or you believe that it shouldnt be supported by asio? Be in another
> library? A move_resource<>/shared_resource<> "smart pointer"?
>

Now we agree :) Yes, it is useful behaviour and probably should be
supported directly by asio. But it should not be the default or at
least the user should have the option.

Along side the current non-copyable (but maybe movable) stream_socket
asio could provide a stream_socket_ptr that would behave as if it were a
shared_ptr to a stream_socket (that is, pointer semantics), but it
wouldn't actually allocate a stream_socket (similar to the way an
optional looks like a pointer but actualy is stack based).

Would it work for you? I'haven't really thought much about it, so I'm
certanly missing something.

-- 
Giovanni P. Deretta

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