template<class T> class initializer_list;
const T.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.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.| member type | definition |
|---|---|
| value_type | The template parameter (T) |
| reference | const T& |
| const_reference | const T& |
| size_type | size_t |
| iterator | const T* |
| const_iterator | const T* |