std::flat_m...p::max_size(3)
π 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). Likemax_sizebut 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
- 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