class template
<initializer_list>
std::initializer_listtemplate<class T> class initializer_list;
Initializer list
This type is used to access the values in a C++ initialization list, which is a list of elements of typeconst T
.
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:
1
auto il = { 10, 20, 30 }; // the type of il is an initializer_list
<initializer_list>
shall be included to access it, even if the type is used implicitly.
initializer_list objects are automatically constructed as if an array of elements of type T 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:
1
2
3
4
5
6
7
8
struct myclass {
myclass (int,int);
myclass (initializer_list<int>);
/* definitions ... */
};
myclass foo {10,20}; // calls initializer_list ctor
myclass bar (10,20); // calls first constructor
initializer_list::value_type
.
const T&
const_reference const T&
size_type size_t iterator const T*
const_iterator const T*
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3