cpp/utility/initializer list

(not to be confused with member initializer list)

An object of type is a lightweight proxy object that provides access to an array of objects of type.

A object is automatically constructed when:
 * a braced-init-list is used to list-initialize an object, where the corresponding constructor accepts an parameter,
 * a braced-init-list is used as the right operand of assignment or as a function call argument, and the corresponding assignment operator/function accepts an parameter,
 * a braced-init-list is bound to, including in a ranged for loop.

Initializer lists may be implemented as a pair of pointers or pointer and length. Copying a does not copy the underlying objects.

The underlying array is a temporary array of type, in which each element is copy-initialized (except that narrowing conversions are invalid) from the corresponding element of the original initializer list. The lifetime of the underlying array is the same as any other temporary object, except that initializing an initializer_list object from the array extends the lifetime of the array exactly like binding a reference to a temporary (with the same exceptions, such as for initializing a non-static class member). The underlying array may be allocated in read-only memory.

The program is ill-formed if an explicit or partial specialization of is declared.