std::flat_map::max_size(3)

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

🌸 NAME 🌸

NAME? It's literally std::flat_map::max_size - std::flat_map::max_size. Yes bestie, the description is also the name, iconic. This page lives under the C++ Standard Libary manual (their spelling, not mine πŸ’…).

✨ Synopsis ✨

Okay so the signature is giving:

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

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations. Equivalent to std::min<size_type>(c.keys.max_size(), c.values.max_size()). Periodt.

πŸŽ€ Parameters πŸŽ€

(none) β€” no parameters, bestie. Nothing to pass in, just vibes.

πŸ’– Return value πŸ’–

Maximum number of elements. That's the whole return value, no cap.

πŸ¦‹ Complexity πŸ¦‹

Constant. Lowkey the easiest complexity ever.

πŸ”₯ 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, max_size() is the theoretical dream, but your actual RAM is the vibe check πŸ’€.

πŸŽ€ Example πŸŽ€

// Run this code

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

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

🌈 Possible output 🌈

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

πŸ‘‘ See also πŸ‘‘

  • size β€” returns the number of elements (public member function).

That's the whole page, bestie! Source/version/date: http://cppreference.com, 2024.06.10, page std::flat_map::max_size(3). Bye πŸ’…βœ¨

πŸ“¦ where this page comes from