Spec-Zone.ru › C++

std::initializer_list<T>::begin

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

Obtains a pointer to the first element in the initializer_list. Equivalent to return data();.

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

Return value

A pointer to the first element in the initializer list

Complexity

Constant

Example

#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <iterator>

int main()
{
    static constexpr auto il = {42, 24};
    static_assert(*il.begin() == 0x2A);
    static_assert(il.begin()[1] == 030);

    std::initializer_list ϕ = {'1', '.', '6', '1', '8', '0'};

    std::copy(ϕ.begin(),
              ϕ.end(),
              std::ostream_iterator<char>(std::cout, ""));

    std::cout << '\n';
}

Output:

1.6180

See also

end
(C++11)
returns a pointer to one past the last 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/begin

Spec-Zone.ru

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