std::unorde...ap::max_size(3)
β¨ 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms