std::set<Key,Compare,Allocator>::empty (3) - Linux Manuals
std::set<Key,Compare,Allocator>::empty: std::set<Key,Compare,Allocator>::empty
Command to display std::set<Key,Compare,Allocator>::empty
manual in Linux: $ man 3 std::set<Key,Compare,Allocator>::empty
NAME
std::set<Key,Compare,Allocator>::empty - std::set<Key,Compare,Allocator>::empty
Synopsis
bool empty() const; (until C++11)
bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] bool empty() const noexcept; (since C++20)
Checks if the container has no elements, i.e. whether begin() == end().
Parameters
(none)
Return value
true if the container is empty, false otherwise
Complexity
Constant.
Example
The following code uses empty to check if a std::set<int> contains any elements:
// Run this code
#include <set>
#include <iostream>
int main()
{
std::set<int> numbers;
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
numbers.insert(42);
numbers.insert(13317);
std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n';
}
Output:
Initially, numbers.empty(): 1
After adding elements, numbers.empty(): 0
See also
returns the number of elements
size (public member function)
Pages related to std::set<Key,Compare,Allocator>::empty
- std::set<Key,Compare,Allocator>::emplace (3) - std::set<Key,Compare,Allocator>::emplace
- std::set<Key,Compare,Allocator>::emplace_hint (3) - std::set<Key,Compare,Allocator>::emplace_hint
- std::set<Key,Compare,Allocator>::end,std::set<Key,Compare,Allocator>::cend (3) - std::set<Key,Compare,Allocator>::end,std::set<Key,Compare,Allocator>::cend
- std::set<Key,Compare,Allocator>::equal_range (3) - std::set<Key,Compare,Allocator>::equal_range
- std::set<Key,Compare,Allocator>::erase (3) - std::set<Key,Compare,Allocator>::erase
- std::set<Key,Compare,Allocator>::extract (3) - std::set<Key,Compare,Allocator>::extract
- std::set<Key,Compare,Allocator>::begin,std::set<Key,Compare,Allocator>::cbegin (3) - std::set<Key,Compare,Allocator>::begin,std::set<Key,Compare,Allocator>::cbegin
- std::set<Key,Compare,Allocator>::clear (3) - std::set<Key,Compare,Allocator>::clear
- std::set<Key,Compare,Allocator>::contains (3) - std::set<Key,Compare,Allocator>::contains
- std::set<Key,Compare,Allocator>::count (3) - std::set<Key,Compare,Allocator>::count
- std::set<Key,Compare,Allocator>::find (3) - std::set<Key,Compare,Allocator>::find
- std::set<Key,Compare,Allocator>::get_allocator (3) - std::set<Key,Compare,Allocator>::get_allocator
- std::set<Key,Compare,Allocator>::insert (3) - std::set<Key,Compare,Allocator>::insert
- std::set<Key,Compare,Allocator>::key_comp (3) - std::set<Key,Compare,Allocator>::key_comp
- std::set<Key,Compare,Allocator>::lower_bound (3) - std::set<Key,Compare,Allocator>::lower_bound
- std::set<Key,Compare,Allocator>::max_size (3) - std::set<Key,Compare,Allocator>::max_size
- std::set<Key,Compare,Allocator>::merge (3) - std::set<Key,Compare,Allocator>::merge
- std::set<Key,Compare,Allocator>::operator= (3) - std::set<Key,Compare,Allocator>::operator=
- std::set<Key,Compare,Allocator>::rbegin,std::set<Key,Compare,Allocator>::crbegin (3) - std::set<Key,Compare,Allocator>::rbegin,std::set<Key,Compare,Allocator>::crbegin
- std::set<Key,Compare,Allocator>::rend,std::set<Key,Compare,Allocator>::crend (3) - std::set<Key,Compare,Allocator>::rend,std::set<Key,Compare,Allocator>::crend
- std::set<Key,Compare,Allocator>::set (3) - std::set<Key,Compare,Allocator>::set
- std::set<Key,Compare,Allocator>::size (3) - std::set<Key,Compare,Allocator>::size
- std::set<Key,Compare,Allocator>::swap (3) - std::set<Key,Compare,Allocator>::swap
- std::set<Key,Compare,Allocator>::upper_bound (3) - std::set<Key,Compare,Allocator>::upper_bound
- std::set<Key,Compare,Allocator>::value_comp (3) - std::set<Key,Compare,Allocator>::value_comp
- std::set<Key,Compare,Allocator>::~set (3) - std::set<Key,Compare,Allocator>::~set
- std::set (3) - std::set