Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-10-10 01:58:57

On Friday 10 October 2003 01:53 am, E. Gladyshev wrote:
> --- Douglas Gregor <gregod_at_[hidden]> wrote:
> According 3.8.4 (IF WE ASSUME THAT 'new(obj)' is "reusing storage") when I
> call char *p = new( (void*)&m.x ) char;
> I end lifetime of m.x,

Agreed, because the storage associated with m.x has been reused. For
reference, that's the last bullet of 3.8/1.

> so I end the storage duration of a member subobject.

Here I disagree. The lifetime of the member subobject has ended, but I don't
see how this impacts the storage duration of the member subobject. You

> 1.7.1
> "An object has a storage duration which influences its lifetime"

Note that it does not say that the lifetime influences the storage duration.
When the storage duration is over (i.e., the storage has been released or
reused; that's 3.8/4), the lifetime ends, but I see nothing that says that
the converse is true.

> According to 3.7.4
> The storage duration of m.x is the same as the its complete object.


> Do you see what I am talking about? "reusing storage" has to be
> consistently defined to fit into the whole picture.

I don't see that the definition is inconsistent. Reusing storage implies that
the lifetime of the object ends, but I don't see that it implies that the
storage duration ends. In fact, both 3.8/7 and 3.8/8 imply that the lifetime
of an object can end but its storage duration has not ended, because a new
object of the same type can be be dropped into that same storage location
without breaking pointers, references, or implicit destructor calls.

Also, some anecdotal information (far from proof-worthy, but helps show
intent): 3.7/4 explicitly states that the lifetime of a reference is its
storage duration, but we don't see any such statement for other types.


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