A point from C++11 n3242 "Duration of subobjects, object lifetime", 3.8/1:
The lifetime of an object is a runtime property of the object. An object is said to have non-trivial initialization if it is of a class or aggregate type and it or one of its members is initialized by a constructor other than a trivial default constructor [ Note: initialization by a trivial copy/move constructor is non-trivial initialization. — end note ]
The lifetime of an object of type T begins when:
- storage with the proper alignment and size for type T is obtained, and
- if the object has non-trivial initialization, its initialization is complete.
The lifetime of an object of type T ends when:
- if T is a class type with a non-trivial destructor (12.4), the destructor call starts, or
- the storage which the object occupies is reused or released.
Here they said about trivial or nontrivial copy/move constructor with object lifetime. Can any one explain this with some example program?
And the change of an point describes when the lifetime of an object of type T
begins, but they didn't mention when T
ends. Why?