The
lifetime of an object or reference is a runtime property of the
object or reference
. A variable is said to have
vacuous initialization
if it is default-initialized, no other initialization is performed, and,
if it is of class type or a (possibly multidimensional) array thereof,
a trivial constructor of that class type is selected for
the default-initialization
. The lifetime of an object
o of type
T ends when:
- if T is a non-class type, the object is destroyed, or
- if T is a class type, the destructor call starts, or
- the storage which the object occupies is released,
or is reused by an object that is not nested within o ([intro.object]).
[
Example 1:
struct S {
int m;
};
void f() {
S x{1};
new(&x) S(x.m);
}
—
end example]