std::stack::empty(3)
π std::stack::empty(3) π
okay so welcome to the std::stack::empty(3) page from the C++ Standard Libary manual β yes bestie, that spelling is exactly what the header says, and weβre keeping it.
π NAME π
std::stack::empty - std::stack::empty
(Yes, the name is the name. Iconic behavior. π)
β¨ Synopsis β¨
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 none, bestie. no arguments, no stress. π
πΈ Return value πΈ
true if the underlying container is empty, false otherwise. fr fr.
π¦ Complexity π¦
Constant. thatβs the whole vibe. β¨
π₯ Example π₯
// Run this code
#include <algorithm>
#include <iostream>
#include <stack>
int main()
{
std::cout << std::boolalpha;
std::stack<int> stack;
std::cout << "Initially, stack.empty(): " << stack.empty() << '\n';
stack.push(42);
std::cout << "After adding elements, stack.empty(): " <<
stack.empty() << '\n';
}
π Output π
Initially, stack.empty(): true
After adding elements, stack.empty(): false
π See also π
sizeβ returns the number of elements (public member function)emptyβ checks whether the container is empty (C++17) (function template)
π cute sign-off: source/version is http://cppreference.com, and the date is 2024.06.10. periodt. π«Ά
π¦ 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