function template
<initializer_list>

std::begin (initializer_list)

template<class T> const T* begin (initializer_list<T> il) noexcept;
Return iterator to beginning
Returns a pointer to the first element in il, just like initializer_list's member function begin.

This is a template specialiation of the global function begin for initializer_list objects.

Parameters

none

Return Value

A pointer to the first element in the initializer_list object il.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// begin/end (initializer_list)
#include <iostream>          // std::cout
#include <initializer_list>  // std::initializer_list

template<class T> void print_list (std::initializer_list<T> il) {
  for (const T* it=begin(il); it!=end(il); ++it) std::cout << ' ' << *it;
  std::cout << '\n';
}

int main ()
{
  print_list ({10,20,30});
  return 0;
}


Output:
 10 20 30

Complexity

Constant.

Data races

The il object is accessed. Its contained elements are constant: Concurrently accessing them is always safe.

Exception safety

No-throw guarantee: this function never throws exceptions.

See also