Namespaces
Variants

std::initializer_list<T>::begin

From cppreference.com
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)    
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
 
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

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