Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::end(std::initializer_list)

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

Utility
  • C++11
  • C++14
1 min readView on cppreference
NotebookLM
Defined in header <initializer_list>
template< class E >
const E* end( std::initializer_list<E> il ) noexcept;
(since C++11)
(constexpr since 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()

Example

example.cpp
#include <cassert>
#include <initializer_list>
#include <iterator>
#include <numeric>
 
int main()
{
    std::initializer_list e = {2, 7, 1, 8, 2, 8, 1};
    assert(std::accumulate(std::begin(e), std::end(e), 13) == 42);
}

See also

returns a pointer to one past the last element
(public member function)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.