Subject: Re: [boost] shared_ptr<X>
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2012-11-05 22:38:14
On Mon, Nov 5, 2012 at 6:37 AM, Peter Dimov <lists_at_[hidden]> wrote:
> Now that we (are going to) have shared_ptr<X>, what should
> shared_ptr<X> do?
>> From user point of view, it seems obvious that this is as good a pointer
> an array as shared_ptr<X> is, so it should behave similarly, having op
> and an element_type of X.
>> From a generic point of view, this could potentially break code that
> that shared_ptr<T>::get() always returns a T*, even when T is X. But how
> common is such a scenario?
I think it's reasonable that the generic code assume anything returned
by shared_ptr<T>::get be a pointer -- even if it required decay in
I'd suggest that any such generic code would be responsible for
reversing any potential pointer decay, if it was really necessary.
Otherwise they may just need to use element_type* (or auto, if they're
> On the other hand, it will actually _fix_ generic code of the form
> shared_ptr<T> p( new T );
> when T is X.
While both seem unlikely, the latter seems more likely than the former. . .