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

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

πŸ’… std::flat_m...p::max_size πŸ’…

okay so bestie, this is the cppreference page for std::flat_multimap::max_size β€” yes the title is literally std::flat_multimap::max_size twice because that's just how NAME sections roll, we don't question it, we respect it 🫢. It lives in the C++ Standard Library and honestly? It's giving "small function, big feelings."


✨ NAME ✨

std::flat_multimap::max_size β€” which is, and I cannot stress this enough, std::flat_multimap::max_size πŸ’€


🌸 Synopsis 🌸

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

So what does it do? It returns the max number of elements the container is able to hold due to system or library implementation limitations. That's the whole vibe.

And it's equivalent to:

std::min<size_type>(c.keys.max_size(), c.values.max_size())

like it's literally just taking the smaller of the two, no cap. ✨


πŸŽ€ Parameters πŸŽ€

(none)

Nothing! Zero! Empty! It takes no arguments and honestly? Iconic behaviour. She doesn't need anything from you. πŸ’…


πŸ¦‹ Return value πŸ¦‹

Maximum number of elements. That's it, that's the return value. πŸ‘‘


⭐ Complexity ⭐

Constant. O(1) energy, she does not make you wait, we love a low-maintenance queen. 🌈


πŸ’œ Notes πŸ’œ

okay so listen, this value typically reflects the theoretical limit on the size of the container, at most std::numeric_limits<difference_type>::max(). Theoretical! Like a dream. 🧚

But β€” and this is the important part, bestie, don't come for me β€” 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... yes she says she can hold that many, but your actual RAM has opinions. 😭 Not a lie, just a theory vs. reality situation fr fr.


🌸 Example 🌸

// Run this code

#include <iostream>
#include <flat_map>
#include <locale>

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

Look at her go. q is a std::flat_multimap<char, char>, we're imbuing the "en_US.UTF-8" locale so the number gets those cute commas, and then we print. Chef's kiss. πŸŽ€


🫢 Possible output 🫢

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

768,614,336,404,564,650 !!! that's a real number that came out of a real computer, we're obsessed, we're floored, we're screaming πŸ’€πŸ”₯


πŸ‘‘ See also πŸ‘‘

  • size β€” returns the number of elements (public member function). Like max_size but for what you actually have instead of what you could have. Main character energy vs. potential energy, iykyk. ✨

and that's the whole page bestie!! no skips, no cuts, every single detail preserved because we love accuracy in this house πŸ’–

source: http://cppreference.com Β· 2024.06.10 Β· std::flat_m...p::max_size(3) β€” mwah, kisses, go write some C++ πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from