template<class T,
class Cont = deque<T> >
class stack {
public:
typedef Cont::allocator_type allocator_type;
typedef Cont::value_type value_type;
typedef Cont::size_type size_type;
explicit stack(const allocator_type& al = allocator_type()) const;
bool empty() const;
size_type size() const;
allocator_type get_allocator() const;
value_type& top();
const value_type& top() const;
void push(const value_type& x);
void pop();
protected:
Cont c;
};
The template class describes an object that controls a varying-length sequence of elements. The object allocates and
frees storage for the sequence it controls through a protected object named c
, of class Cont
. The type T
of elements in
the controlled sequence must match value_type
.
An object of class Cont
must supply several public members defined the same as for deque
, list
, and vector
(all of
which are suitable candidates for class Cont
). The required members are:
typedef T value_type;
typedef T0 size_type;
Cont(const allocator_type& al);
bool empty() const;
size_type size() const;
allocator_type get_allocator() const;
value_type& back();
const value_type& back() const;
void push_back(const value_type& x);
void pop_back();
Here, T0
is an unspecified type that meets the stated requirements.