Section

std::stack

The std::stack class is a container adaptor that gives the programmer the functionality of a stack - specifically, a LIFO (last-in, first-out) data structure.

# Declarations

template<
class T,
class Container = std::deque<T>
> class stack;

# Notes

Feature-test macro Value Std Feature __cpp_lib_containers_ranges 202202L (C++23) Ranges construction and insertion for containers

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 307C++98Container could not be std::vectorallowed
LWG 2566C++98Missing the requirement for Container::value_typeill-formed if T is not the same type as Container::value_type

# See also