table of contents
other versions
- Tumbleweed 2026.11.13-1.1
- Leap-16.0
- Leap-15.6
| std::stack::empty(3) | C++ Standard Libary | std::stack::empty(3) |
NAME¶
std::stack::empty - std::stack::empty
Synopsis¶
bool empty() const;
Checks if the underlying container has no elements. Equivalent to: return c.empty().
Parameters¶
(none)
Return value¶
true if the underlying container is empty, false otherwise.
Complexity¶
Constant.
Example¶
// Run this code
#include <cassert> #include <stack>
int main() {
std::stack<int> stack;
assert(stack.empty());
stack.push(42);
assert(!stack.empty());
stack.pop();
assert(stack.empty()); }
See also¶
size returns the number of elements
(public member function) empty checks whether the container is empty
(C++17) (function template)
| 2026.11.10 | http://cppreference.com |