std::initia...list::begin(3)

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

✨ NAME ✨

okay so this is std::initia...list::begin(3), bestie β€” the std::initializer_list::begin page from the C++ Standard Libary. The NAME is literally std::initializer_list::begin - std::initializer_list::begin, because it ate and left no crumbs. πŸ’…

🌸 Synopsis 🌸

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

Returns a pointer to the first element in the initializer list. 🫢

⚠️ If the initializer list is empty, the values of begin() and end() are unspecified, but will be identical. No cap β€” they’ll match, the actual value just isn’t promised. 😭

πŸŽ€ Parameters πŸŽ€

  • (none) β€” literally none, bestie. ✨

πŸ¦‹ Return value πŸ¦‹

a pointer to the first element in the initializer list β€” iconic pointer behavior, fr fr. πŸ’–

πŸ”₯ Complexity πŸ”₯

Constant. That’s it. Periodt. πŸ’€

🌈 Example 🌈

// Run this code

#include <initializer_list>

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

πŸ’œ See also πŸ’œ

  • end β€” returns a pointer to one past the last element (public member function). Obsessed with the symmetry. ✨

mwah πŸ’‹ β€” this std::initia...list::begin(3) moment was sourced from http://cppreference.com, version/date 2024.06.10. πŸŽ€

πŸ“¦ where this page comes from