std::priority_queue::empty(3)
π NAME π
okay so welcome to std::priority_queue::empty(3) from the C++ Standard Libary manual β yes, βLibaryβ is the manualβs spelling and weβre not touching it, periodt π
. The name up top is std::priority_queue::empty - std::priority_queue::empty, which is giving self-referential main character energy, and honestly? iconic β¨.
π¦ Synopsis π¦
two signatures, depending on which C++ era youβre living in:
bool empty() const; (until C++20)
[[nodiscard]] bool empty() const; (since C++20)
Checks if the underlying container has no elements. Equivalent to return c.empty();.
πΈ Parameters πΈ
(none) β literally zero parameters, she takes nothing, low maintenance queen π«Ά.
π Return value π
true if the underlying container is empty, false otherwise. Thatβs the whole return vibe, no cap β¨.
β Complexity β
Constant. periodt.
π Example π
// Run this code β go off, bestie:
#include <algorithm>
#include <iostream>
#include <queue>
int main()
{
std::cout << std::boolalpha;
std::priority_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)
source/version/date check, bestie: http://cppreference.com, 2024.06.10, page std::priority_queue::empty(3) β mwah, bye ππ
π¦ 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