std::stack<T,Container>::empty

Checks if the underlying container has no elements. Equivalent to: returnc.empty().

# Declarations

bool empty() const;

# Return value

true if the underlying container is empty, false otherwise.

# Example

#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