std::begin(...alizer_list)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– std::begin(...alizer_list)(3) β€” C++ Standard Libary πŸ’–

okay bestie, welcome to the std::begin(...alizer_list)(3) page from the C++ Standard Libary manual. it’s giving β€œtiny utility, main character energy” and we’re gonna get into every detail fr fr. πŸ’…


✨ NAME ✨

std::begin(std::initializer_list) β€” std::begin(std::initializer_list)


🌸 Synopsis 🌸

Defined in header <initializer_list>.

Era 1, since C++11 and until C++14:

template< class E >
const E* begin( std::initializer_list<E> il ) noexcept;

Era 2, since C++14:

template< class E >
constexpr const E* begin( std::initializer_list<E> il ) noexcept;

The overload of std::begin for initializer_list returns a pointer to the first element of il. lowkey iconic, no cap. ✨


πŸŽ€ Parameters πŸŽ€

  • il β€” an initializer_list

πŸ¦‹ Return value πŸ¦‹

il.begin()


πŸ“ Example πŸ“

// Run this code

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

int main()
{
    std::initializer_list il = {3, 1, 4, 1};

    std::copy(std::begin(il),
              std::end(il),
              std::ostream_iterator<int>(std::cout, "\n"));
}

πŸ’¬ Output πŸ’¬

3
1
4
1

🌈 See also 🌈

  • begin β€” returns a pointer to the first element (public member function)

xoxo, bestie πŸ’– source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::begin(...alizer_list)(3) β€” periodt. 🫢

πŸ“¦ where this page comes from