Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

stack

Library:  Containers


Does not inherit

Local Index

Members

Non-Members

Summary

A container adapter that behaves like a stack (last in, first out)

Synopsis

#include <stack>

namespace std {
  template <class T, class Container = deque<T> >
  class stack;
}

Description

The stack container adapter causes a container to behave like a last- in, first-out (LIFO) stack. The last item put (pushed) onto the stack is the first item removed (popped off). The stack can adapt any container that includes the operations back(), push_back(), and pop_back(). In particular, deque, list, and vector can be used.

Interface

Constructors

explicit
stack(const Container& = Container());

Member Functions

bool 
empty() const;
void 
pop();
void 
push(const value_type& x);
size_type 
size() const;
value_type& 
top();
const value_type& 
top() const;

Nonmember Operators

template <class T, class Container>
bool operator==(const stack<T, Container>& x,
                 const stack<T, Container>& y);
template <class T, class Container>
bool operator!=(const stack<T, Container>& x,
                 const stack<T, Container>& y);
template <class T, class Container>
bool operator<(const stack<T, Container>& x,
                const stack<T, Container>& y);
template <class T, class Container>
bool operator>(const stack<T, Container>& x,
                const stack<T, Container>& y);
template <class T, class Container>
bool operator<=(const stack<T, Container>& x,
                 const stack<T, Container>& y);
template <class T, class Container>
bool operator>=(const stack<T, Container>& x,
                 const stack<T, Container>& y);

Example

See Also

allocator, Containers, deque, list, vector

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 23.2.3.3



Previous fileTop of DocumentContentsIndex pageNext file