This type is used to access the values in a C++ initialization list, which is a list of elements of type const E.
Objects of this type are automatically constructed by the compiler from initialization list declarations, which is a list of comma-separated elements enclosed in braces:
auto il = { 10, 20, 30 }; // the type of il is an initializer_list
Notice though that this template class is not predefined and the header <initializer_list> shall be included for all uses, even if the type is used implicitly.
initializer_list objects are automatically constructed as if an array of elements of type E was allocated, with each of the elements in the list being copy-initialized to its corresponding element in the array, using any necessary non-narrowing implicit conversions.
The initializer_list object refers to the elements of this array without containing them: copying an initializer_list object produces another object referring to the same underlying elements, not to new copies of them (reference semantics).
The lifetime of this temporary array is the same as the initializer_list object.
Constructors taking only one argument of this type are a special kind of constructor, called initializer-list constructor. Initializer-list constructors take precedence over other constructors when the initializer-list constructor syntax is used: