std::flat_m...t::max_size(3)

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

🌸 NAME 🌸

std::flat_multiset::max_size β€” bestie, it's literally std::flat_multiset::max_size πŸ’… (yes the name is the whole vibe, this is from the C++ Standard Library manual, welcome)


✨ SYNOPSIS ✨

size_type max_size() const noexcept;  (since C++23)

okay so this returns the maximum number of elements the container is able to hold due to system or library implementation limitations β€” like, std::distance(begin(), end()) for the largest container possible. big main character energy πŸ”₯


πŸŽ€ PARAMETERS πŸŽ€

(none)

she takes nothing, she gives everything 🫢


⭐ RETURN VALUE ⭐

Maximum number of elements. that's it, that's the tea πŸ‘‘


πŸ¦‹ COMPLEXITY πŸ¦‹

Constant. literally constant, no drama, no waiting, icon behaviour πŸ’…


πŸ’œ NOTES πŸ’œ

This value typically reflects the theoretical limit on the size of the container, at most std::numeric_limits<difference_type>::max(). 🧚

at runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available β€” so like, the theoretical limit is giving dream big 😭 but your actual RAM said "be so fr right now" πŸ’€

🌈 EXAMPLE 🌈

// Run this code

#include <iostream>
#include <flat_set>
#include <locale>

int main()
{
    std::flat_multiset<char> q;
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "Maximum size of a std::flat_multiset is " <<
q.max_size() << '\n';
}

Possible output:

Maximum size of a std::flat_multiset is 768,614,336,404,564,650

not that number being absolutely unhinged πŸ™ˆ but slay, we love a big max_size


πŸ‘‘ SEE ALSO πŸ‘‘

  • size β€” returns the number of elements (public member function) β€” the lowkey cousin of max_size(), also iconic πŸ’–

and that's the whole page bestie, no cap πŸ“πŸ’• β€” this was from cppreference.com, version 2024.06.10, std::flat_m...t::max_size(3) β€” go forth and know your theoretical limits, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from