Namespaces
Variants
Views
Actions

std::begin(std::initializer_list)

From cppreference.com
< cpp‎ | utility‎ | initializer list
Revision as of 13:25, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
template< class E >
const E* begin( initializer_list<E> il );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

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

Contents

Parameters

il - an initializer_list

Return value

il.begin()

Exceptions

noexcept specification:  
noexcept
  

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

See also

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