##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::begin(std::initializer_list)

From cppreference.com
< cpp‎ | utility‎ | initializer list

template< class E > const E* begin( initializer_list<E> il ) noexcept; |  | (since C++11) (until C++14)
template< class E > constexpr const E* begin( initializer_list<E> il ) noexcept; |  | (since C++14)

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

### [edit] Parameters

il | - | an `initializer_list`

### [edit] Return value

il.begin()

### [edit] Example

Run this code

    #include <iostream>
    #include <initializer_list>

    int main()
    {
        std::initializer_list<int> il = {3, 1, 4, 1};
        for(auto it = std::begin(il); it != std::end(il); ++it) {
            std::cout << *it << '\n';
        }
    }

Output:

    3
    1
    4
    1

### [edit] See also

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

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/initializer_list/begin2&oldid=92120"