std::list::empty(3)
πΈ NAME πΈ
okay so bestie, welcome to std::list::empty(3) from the C++ Standard Libary (yes, the header spells it like that, Iβm not fixing it π). The NAME section is literally std::list::empty - std::list::empty β recursive icon behavior, we love to see it π
.
β¨ Synopsis β¨
Hereβs the signature glow-up timeline, no cap:
bool empty() const; (until C++11)
bool empty() const noexcept; (since C++11)
(until C++20)
[[nodiscard]] bool empty() const noexcept; (since C++20)
It checks if the container has no elements, i.e. whether begin() == end(). Thatβs the whole vibe check π«Ά.
π Parameters π
(none) β literally zero parameters, not a single one, periodt.
π Return value π
true if the container is empty, false otherwise. Thatβs it, thatβs the tea π.
π¦ Complexity π¦
Constant. Constant, bestie β itβs giving stable, predictable, low-drama energy β¨.
π Example π
The following code uses empty to check if a std::list<int> contains any elements:
// Run this code
#include <list>
#include <iostream>
int main()
{
std::list<int> numbers;
std::cout << std::boolalpha;
std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n';
numbers.push_back(42);
numbers.push_back(13317);
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 π this lilβ page is from http://cppreference.com, version/date 2024.06.10 β std::list::empty(3) out πβ¨
π¦ 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