public member function
<initializer_list>

std::initializer_list::initializer_list

initializer_list() noexcept;
constexpr initializer_list() noexcept;
Construct empty initializer_list
Constructs an empty initializer_list object.

Notice that the compiler will automatically construct a non-empty object of this class template type whenever an initializer list expression needs to be passed or copied. This is the only way to set the values of an object of type initializer_list.

Parameters

none

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
// initializer_list example
#include <iostream>          // std::cout
#include <initializer_list>  // std::initializer_list

int main ()
{
  std::initializer_list<int> mylist;
  mylist = { 10, 20, 30 };
  std::cout << "mylist contains:";
  for (int x: mylist) std::cout << ' ' << x;
  std::cout << '\n';
  return 0;
}

Output:
mylist container: 10 20 30


Complexity

Constant.

Exception safety

No-throw guarantee: this member function never throws exceptions.

See also