Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr] make_shared slower than shared_ptr(new) on VC++9 (and 10) with fix
From: Peter Dimov (pdimov_at_[hidden])
Date: 2012-04-28 07:56:35

Mathias Gaunard wrote:
> On 27/04/12 01:59, Peter Dimov wrote:
> > Mathias Gaunard wrote:
> >
> >> I suppose you probably want to say that the type you're accessing the
> >> object with is actually the dynamic type of the object, but that idea
> >> is not supported anywhere in the standard.
> >
> > 3.8, object lifetime.
> In lack of a proper explanation, I will assume that your argument is that
> the array member lifetime has ended and you're re-using its storage to
> store an object of a different type.
> Is that what you meant?
> Assuming this is true (which I'm not entirely sure of, the fact that it is
> a subobject might be a problem), there still is 3.8/7 to consider, which
> does not allow you to re-use the storage for any other type if there is
> any reference to the original object.
> I don't see how the copy constructor of the class could avoid referring to
> the original object.

Interesting point.

In make_shared's case, there's no need for the class to have a copy

However, you may be right that one can't just create a new object in the
middle of an existing object, under a very strict reading.

Boost list run by bdawes at, gregod at, cpdaniel at, john at