20 Memory management library [mem]

20.4 Types for composite class design [mem.composite.types]

20.4.1 Class template indirect [indirect]

20.4.1.1 General [indirect.general]

An indirect object manages the lifetime of an owned object.
An indirect object is valueless if it has no owned object.
An indirect object may become valueless only after it has been moved from.
In every specialization indirect<T, Allocator>, if the type allocator_traits<Allocator>​::​value_type is not the same type as T, the program is ill-formed.
Every object of type indirect<T, Allocator> uses an object of type Allocator to allocate and free storage for the owned object as needed.
Constructing an owned object with args... using the allocator a means calling allocator_traits<Allocator>​::​construct(a, p, args...) where args is an expression pack, a is an allocator, and p is a pointer obtained by calling allocator_traits<Allocator>​::​allocate.
The member alloc is used for any memory allocation and element construction performed by member functions during the lifetime of each indirect object.
The allocator alloc may be replaced only via assignment or swap().
Allocator replacement is performed by copy assignment, move assignment, or swapping of the allocator only if ([container.reqmts]):
  • allocator_traits<Allocator>​::​propagate_on_container_copy_assignment​::​value, or
  • allocator_traits<Allocator>​::​propagate_on_container_move_assignment​::​value, or
  • allocator_traits<Allocator>​::​propagate_on_container_swap​::​value
is true within the implementation of the corresponding indirect operation.
A program that instantiates the definition of the template indirect<T, Allocator> with a type for the T parameter that is a non-object type, an array type, in_place_t, a specialization of in_place_type_t, or a cv-qualified type is ill-formed.
The template parameter T of indirect may be an incomplete type.
The template parameter Allocator of indirect shall meet the Cpp17Allocator requirements.
If a program declares an explicit or partial specialization of indirect, the behavior is undefined.