Spec-Zone.ru › C++

std::initializer_list<T>::end

const T* end() const noexcept;
(since C++11)
(constexpr since C++14)

Obtains a pointer to one past the last element in the initializer list, i.e. begin() +size().

If the initializer list is empty, the values of begin() and end() are unspecified, but will be identical.

Return value

A pointer to one past the last element in the initializer list

Complexity

Constant

Example

#include <initializer_list>
#include <iostream>
#include <numeric>

int main()
{
    static constexpr auto l = {1, 13, 1, 13, 1};
    static_assert(std::accumulate(l.begin(), l.end(), 13) == 42);

    std::initializer_list e = {2, 7, 1, 8, 2, 8, 1};
    std::cout << std::accumulate(std::begin(e), std::end(e), 13) << '\n';
}

Output:

42

See also

begin
(C++11)
returns a pointer to the first element
(public member function)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/utility/initializer_list/end

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API