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.
The following types are collectively called implicit-lifetime types:
- scalar types
- implicit-lifetime class types
- array types
- cv-qualified versions of these types
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 (since C++17).
- An invocation of std::aligned_alloc, (since 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
- std::allocator::allocate_at_least (since C++23)
- (since C++17) An invocation of std::memory_resource::allocate, regardless of how storage is obtained. Including
- std::pmr::polymorphic_allocator::allocate (since C++17)
- std::pmr::polymorphic_allocator::allocate_bytes (since C++20)
- std::pmr::polymorphic_allocator::allocate_object (since C++20)
- An invocation of std::memcpy or std::memmove.
- (since C++20) An invocation of std::bit_cast.
- (since C++23) An invocation of std::start_lifetime_as or std::start_lifetime_as_array.
- 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|