std::flat_set<Key,Compare,KeyContainer>::empty

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

# Declarations

bool empty() const noexcept;

(since C++23)

# Return value

true if the underlying container is empty, false otherwise.

# Example

#include <iostream>
#include <flat_set>
 
int main()
{
    std::flat_set<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';
}

# See also