std::initializer_list::end(3)

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

πŸ’– std::initializer_list::end(3) πŸ’–

okay so this is the C++ Standard Libary page, bestie β€” manual name folded in, no cap. We're talking about std::initializer_list::end(3) and it's lowkey iconic.


πŸŽ€ NAME πŸŽ€

std::initializer_list::end β€” std::initializer_list::end. That's the name, fr fr. The page is named after itself and honestly? main character energy.


✨ Synopsis ✨

Two flavors, depending on your C++ era πŸ‘‘:

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

So the synopsis says: returns 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. Read that again: unspecified but identical β€” that's the rule, periodt.


🫢 Parameters 🫢

(none) β€” literally no parameters. Not me checking twice 😭.


🌸 Return value 🌸

a pointer to one past the last element in the initializer list. That's the whole vibe.


πŸ¦‹ Complexity πŸ¦‹

Constant β€” that's it, no extra lore.


πŸ”₯ Example πŸ”₯

Run this code, bestie (// Run this code energy):

#include <numeric>
#include <initializer_list>

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

πŸ‘‘ See also πŸ‘‘

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

mwah πŸ’‹ source/version and date, folded into a cute sign-off: http://cppreference.com, 2024.06.10, for std::initializer_list::end(3). slay πŸŽ€

πŸ“¦ where this page comes from