std::flat_map::empty(3)

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

okay so bestie, this is the std::flat_map::empty(3) page from the C++ Standard Libary manual β€” tiny page, big main character energy πŸ’…βœ¨

πŸŽ€ NAME πŸŽ€

std::flat_map::empty - std::flat_map::empty β€” literally the name, no notes πŸ˜­πŸ’–

✨ Synopsis ✨

[[nodiscard]] bool empty() const noexcept;  (since C++23)

Checks if the underlying containers have no elements. Equivalent to return begin() == end();. 🫢

🌸 Parameters 🌸

(none) β€” not a single parameter, bestie πŸ’€

πŸ’– Return value πŸ’–

true if the underlying containers are empty, false otherwise. Periodt. ✨

⚑ Complexity ⚑

Constant. ⚑ No drama, no scaling, just constant.

πŸ¦‹ Example πŸ¦‹

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

// Run this code

        #include <iostream>
        #include <flat_map>
        #include <utility>

        int main()
        {
            std::flat_map<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)

mwah πŸ’‹ source/version/date: http://cppreference.com Β· 2024.06.10 Β· std::flat_map::empty(3) β€” that's the footer tea, bestie πŸ§šπŸ’œ

πŸ“¦ where this page comes from