Namespaces
Variants
Views
Actions

std::begin(std::initializer_list)

From cppreference.com
template< class E >
const E* begin( initializer_list<E> il );
(since C++11)
(until C++14)
template< class E >
constexpr const E* begin( initializer_list<E> il );
(since C++14)

The overload of std::begin for initializer_list returns a pointer to the first element of il.

Contents

[edit] Parameters

il - an initializer_list

[edit] Return value

il.begin()

[edit] Exceptions

noexcept specification:  
noexcept
  

[edit] Example

#include <iostream>
 
int main() 
{
    // range-based for uses std::begin and std::end to iterate
    // over a given range; in this case, it's an initializer list
    for (int i : {3, 1, 4, 1}) {
        std::cout << i << '\n';
    }
}

Output:

3
1
4
1

[edit] See also

returns a pointer the first element
(public member function) [edit]