I've always assumed that "creating an object" is the same thing as "starting its lifetime" (and not the same thing as allocating storage for it).
But I've recently been told that "creating an object" means something else, and that starting object's lifetime recursively creates all its subobjects, even it doesn't start their lifetimes, e.g.:
When starting the lifetime of a union without setting an active element, all the elements still get created.
When the lifetime of an array starts without starting the lifetime of elements, e.g. by
std::allocator::allocate()or implicitly, all the element subobjects still get created.
I can't find a direct confirmation of this, but consider e.g. that:
The wording for
&says it returns the address of an object, and applying it to an inactive element of aunionis obviously legal.The wording on
std::allocator::allocatethat says that it returns the pointer to the first element of the array, which I assume requires it to have been created (or there would be no object to point to).
Is this interpretation correct? Is "creating an object" different from "starting its lifetime"? If yes, do we have wording that more explicitly confirms this?
Note that this is a language-lawyer question. I'm interested in what the standard has to say about it, this wording quirk likely doesn't affect what happens in practice.