std::flat_set::empty(3)
std::flat_set::empty β C++ Standard Libary manual, section 3 π¦
okay bestie, welcome to the C++ Standard Libary manual, section 3 β this page is std::flat_set::empty, and it's lowkey adorable. π
NAME π
std::flat_set::empty - std::flat_set::empty β yes bestie, the name is the name. Self-referential icon behavior.
Synopsis β¨
Here's the signature, fresh since C++23:
[[nodiscard]] bool empty() const noexcept; (since C++23)
Checks if the underlying container has no elements. Equivalent to return begin() == end();.
Parameters π
(none) β literally zero parameters. Not a single one, bestie.
Return value π
true if the underlying container is empty, false otherwise. Simple. Clean. Slay.
Complexity π
Constant. Periodt.
Example π
The following code uses empty to check if a std::flat_set<int> contains any elements:
// Run this code
#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';
}
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, date: 2024.06.10 β okay bye bestie, go check if your container is empty, ily π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms