std::queue::empty(3)
π NAME π
You're on the std::queue::empty(3) page in the C++ Standard Libary, bestie. The name is std::queue::empty β and the one-liner? Also std::queue::empty. No cap, that's the whole name section. Iconic.
π¦ Synopsis π¦
Two eras, two signatures, same "is it empty tho" energy:
bool empty() const; (until C++20)
[[nodiscard]] bool empty() const; (since C++20)
It checks if the underlying container has no elements. Equivalent to return c.empty();.
π Parameters π
(none)β literally no parameters. Not a single one. The parameter list is giving empty-queue energy.
π Return value π
trueif the underlying container is empty.falseotherwise.
π§ Complexity π§
Constant. That's the whole complexity note, bestie.
π₯ Example π₯
// Run this code
#include <algorithm>
#include <iostream>
#include <queue>
int main()
{
std::cout << std::boolalpha;
std::queue<int> queue;
std::cout << "Initially, queue.empty(): " << queue.empty() << '\n';
queue.push(42);
std::cout << "After adding elements, queue.empty(): " <<
queue.empty() << '\n';
}
π Output π
Initially, queue.empty(): true
After adding elements, queue.empty(): false
π See also π
sizeβ returns the number of elements (public member function).emptyβ checks whether the container is empty (C++17) (function template).
That's the whole page, bestie. Source/version/date: http://cppreference.com, 2024.06.10, std::queue::empty(3). Slay. π
π¦ 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