std::flat_multiset::empty(3)

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

πŸ’… std::flat_multiset::empty(3) πŸ’…

okay bestie, this little icon is from the C++ Standard Libary β€” yes that's the manual name, don't come for me 😭 β€” and it's giving "do I have anything in here?" energy. Let's go ✨


✨ NAME ✨

std::flat_multiset::empty β€” std::flat_multiset::empty (the NAME section said it twice, and honestly? double confirmation, slay πŸ’…)

✨ Synopsis ✨

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

Checks if the underlying container has no elements. Equivalent to return begin() == end();.

✨ Parameters ✨

(none) β€” no params, no drama, we love a low-maintenance queen 🫢

✨ Return value ✨

true if the underlying container is empty, false otherwise. Periodt. βœ…

✨ Complexity ✨

Constant. ⚑

✨ Example ✨

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

// Run this code

#include <iostream>
#include <flat_set>

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

    numbers.insert(42);
    numbers.insert(19937);
    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 πŸ’‹ signing off from http://cppreference.com with the date 2024.06.10, and yeah bestie this was std::flat_multiset::empty(3) β€” no cap, she ate πŸŒˆπŸ‘‘πŸ’–

πŸ“¦ where this page comes from