std::multimap::empty(3)

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

🌸 NAME 🌸

std::multimap::empty - std::multimap::empty β€” okay so bestie, welcome to the std::multimap::empty(3) page from the C++ Standard Library. This is the std::multimap member that checks if the container has no elements. Literally the vibe check for your multimap.

✨ Synopsis ✨

Here's the signature glow-up across C++ versions β€” keep the annotations, they matter:

bool empty() const;                         (until C++11)
bool empty() const noexcept;                (since C++11)
                                            (until C++20)
[[nodiscard]] bool empty() const noexcept;  (since C++20)

So what does it do? It checks if the container has no elements, i.e. whether begin() == end(). No cap.

πŸŽ€ Parameters πŸŽ€

  • (none) β€” it takes zero parameters, bestie. Not a single one.

πŸ’– Return value πŸ’–

  • true if the container is empty.
  • false otherwise.

πŸ¦‹ Complexity πŸ¦‹

Constant. That's it. The vibe check is constant.

🌟 Example 🌟

The following code uses empty to check if a std::multimap<int, int> contains any elements:

       // Run this code

        #include <iostream>
        #include <map>
        #include <utility>

        int main()
        {
            std::multimap<int,int> numbers;
            std::cout << std::boolalpha;
            std::cout << "Initially, numbers.empty(): " << numbers.empty() <<
       '\n';

            numbers.emplace(42, 13);
            numbers.insert(std::make_pair(13317, 123));
            std::cout << "After adding elements, numbers.empty(): " <<
       numbers.empty() << '\n';
        }

✨ Output ✨

Initially, numbers.empty(): true
After adding elements, numbers.empty(): false

πŸ‘‘ See also πŸ‘‘

  • size β€” returns the number of elements (public member function)
  • empty β€” checks whether the container is empty (C++17) (function template)

πŸ’– source/version: http://cppreference.com Β· 2024.06.10 β€” that's the whole page, bestie. Now go check if your multimap is empty and slay, periodt. πŸ’…

πŸ“¦ where this page comes from