std::initia...r_list::size(3)

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

🌸 NAME 🌸

okay so bestie, we're on std::initia...r_list::size(3) β€” that's the manual name folded in right at the top β€” and it's from the C++ Standard Libary (their spelling, not mine, iykyk). The literal NAME line is:

  • std::initializer_list::size - std::initializer_list::size

periodt, that's the name, no notes.


✨ Synopsis ✨

Here's the signature tea, copied exactly:

size_type size() const noexcept;            (since C++11)
                                            (until C++14)
constexpr size_type size() const noexcept;  (since C++14)

So the plain size_type size() const noexcept; is (since C++11) and (until C++14), and then the constexpr glow-up constexpr size_type size() const noexcept; is (since C++14). The way that version upgrade happened? iconic.

It returns the number of elements in the initializer list, i.e. std::distance(begin(), end()). no cap.


🫢 Parameters 🫢

  • (none) β€” literally no parameters, she takes nothing, she just knows her size.

πŸ‘‘ Return value πŸ‘‘

  • the number of elements in the initializer list

πŸ’… Complexity πŸ’…

  • Constant

πŸŽ€ Example πŸŽ€

// Run this code

#include <initializer_list>
int main() { static_assert(std::initializer_list{1,2,3,4}.size() == 4);
}

okay bestie that's the whole vibe: std::initia...r_list::size(3) from http://cppreference.com, version 2024.06.10 β€” mwah, go check your initializer list's size, she's literally right there πŸ’–βœ¨

πŸ“¦ where this page comes from