std::unorde...ap::max_size(3)

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

✨ std::unordered_multimap::max_size ✨

okay bestie, we're in the C++ Standard Library zone and this page is literally titled std::unordered_multimap::max_size β€” the manual name up top is std::unorde...ap::max_size(3) because the header was too iconic to fit the whole thing πŸ’… don't worry, it's the same function, she just goes by a nickname in the corner.


🌸 NAME 🌸

std::unordered_multimap::max_size β€” and yes, that's the whole name, she's matching herself, main character energy only πŸ’–


πŸ¦‹ Synopsis πŸ¦‹

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

So what does it even do? It gives you the maximum number of elements the container is able to hold due to system or library implementation limitations β€” that is, std::distance(begin(), end()) for the largest container possible. no cap, that's the whole vibe check πŸŽ€


🧚 Parameters 🧚

(none) β€” she takes nothing, she needs nothing, she's low-maintenance like that πŸ™ˆ


⭐ Return value ⭐

The maximum number of elements. that's it. that's the tea πŸ”₯


πŸŽ€ Complexity πŸŽ€

Constant. literally O(1) behavior, she's fast, she doesn't even break a sweat 😭✨


πŸ’œ Notes πŸ’œ

okay important detail bestie, don't skip this one:

This value typically reflects the theoretical limit on the size of the container β€” at most std::numeric_limits<difference_type>::max(). But 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… she's telling you what the dream is, not necessarily what your laptop can actually do. theoretical queen, realistic consequences πŸ’€

🌈 Example 🌈

(the original page says // Run this code right here β€” that's the cppreference "run it live" link, go press it, it's giving interactive icon behavior 🫢)

#include <iostream>
#include <locale>
#include <unordered_map>

int main()
{
    std::unordered_multimap<char, char> p;
    std::unordered_multimap<long, char> q;

    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << std::uppercase
              << "p.max_size() = " << std::dec << p.max_size() << " = 0x"
              << std::hex << p.max_size() << '\n'
              << "q.max_size() = " << std::dec << q.max_size() << " = 0x"
              << std::hex << q.max_size() << '\n';
}

Possible output β€” look at these numbers, they ate and left absolutely no crumbs πŸ‘‘

p.max_size() = 1,152,921,504,606,846,975 = 0xFFF,FFF,FFF,FFF,FFF
q.max_size() = 768,614,336,404,564,650 = 0xAAA,AAA,AAA,AAA,AAA

πŸ” See also πŸ”

  • size β€” returns the number of elements (public member function). different girl, different job, both iconic πŸ’–

okay that's the whole page, you understood it perfectly, I'm so proud of you πŸ₯ΉπŸ’…

sign-off time: this little masterpiece lives over at http://cppreference.com and the version/date stamp on the footer is 2024.06.10 β€” so if you're reading this, that's the era, periodt βœ¨πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from