Last Updated: May 22, 2026
std::stack<T> is a last-in, first-out (LIFO) container adapter from the standard library. It is not a new container in its own right; it is a thin wrapper around another container (a std::deque by default) that exposes only the operations a stack needs. This chapter covers what std::stack is, the small API it offers, why some of its methods look the way they do, how to swap out the underlying container, and the pitfalls that arise when it is treated like a std::vector.