C++ named requirements: ImplicitLifetimeType
Note: the standard doesn't define a named requirement with this name. This is a type category defined by the core language. It is included here as a named requirement only for consistency.
Requirements
The following types are collectively called implicit-lifetime types:
- scalar types
- implicit-lifetime class types
- arrays of such types
- cv-qualified versions of these types
Notes
Certain operations may implicitly create and start the lifetime of objects of implicit-lifetime types, if doing so would prevent undefined behavior. However, such operations do not start the lifetimes of subobjects of such objects that are not themselves of implicit-lifetime types.
The following operations may implicitly create objects:
-
An operation that begins the lifetime of an array of
unsigned char
or std::byte (od C++17). -
An invocation of std::aligned_alloc (od C++17), std::calloc, std::malloc, or std::realloc.
-
Any implicit or explicit invocation of a function named operator new or operator new[] (including non-allocating and user-defined placement allocation functions). Including
- An invocation of std::memory_resource::allocate, regardless of how storage is obtained. Including (od C++17)
-
An invocation of std::memcpy or std::memmove.
- An invocation of std::bit_cast (od C++20)
- An invocation of std::start_lifetime_as or std::start_lifetime_as_array. (od C++23)
-
An assignment expression that involves union members if the union's assignment operator is built-in or trivial.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
CWG 2489 | C++20 | an operation that begins the lifetime of a char array implicitly creates objects | it does not |