std::end(std::initializer_list)

1
2
template< class E >
const E* end( initializer_list<E> il );
(since C++11)
1
2
template< class E >
constexpr const E* end( initializer_list<E> il );
(since C++11)
(until C++14)

The overload of std::end for initializer_list returns a pointer to one past the last element of il.

Parameters

il - an initializer_list

Return value

il.end().

Exceptions

noexcept specification:
noexcept

Example

1
2
3
4
5
6
7
8
9
10
#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:

1
2
3
4
3
1
4
1

See also

returns a pointer to one past the last element
(public member function)
doc_CPP
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.