Standard C++ Library Class Reference
Description
The stack container adaptor causes a container to behave like a "last in, first out" (LIFO) stack.
The last item that was put ("pushed") onto the stack is the first item removed ("popped" off).
The stack can adapt to any container that provides the operations, back(), push_back(), and
pop_back(). In particular, deque , list , and vector can be used.
Interface
template <class T, class Container = deque<T>,
class Allocator = allocator>
class stack {
public:
// typedefs
typedef typename Container::value_type value_type;
typedef typename Container::size_type size_type;
typedef Allocator allocator_type
// Construct
explicit stack (const Allocator& = Allocator());
allocator_type get_allocator () const;
// Accessors
bool empty () const;
size_type size () const;
value_type& top ();
const value_type& top () const;
void push (const value_type&);
void pop ();
};
// Non-member Operators
template <class T, class Container, class Allocator>
bool operator== (const stack<T, Container, Allocator>&,
const stack<T, Container, Allocator>&);
template <class T, class Container, class Allocator>
bool operator< (const stack<T, Container, Allocator>&,
const stack<T, Container, Allocator>&);
Constructor
explicit
stack (const Allocator& alloc = Allocator());
Constructs an empty stack. The stack will use the allocator alloc for all storage
management.