Standard C++ Library Class Reference

Description
vector<T, Allocator> is a type of sequence that supports random access iterators. In addition, it
supports amortized constant time insert and erase operations at the end. Insert and erase in the middle
take linear time. Storage management is handled automatically. In vector, iterator is a random access
iterator referring to T. const_iterator is a constant random access iterator that returns a const T&
when being dereferenced. A constructor for iterator and const_iterator is guaranteed. size_type is an
unsigned integral type. difference_type is a signed integral type.
Any type used for the template parameter T must provide the following (where T is the type, t is a
value of T and u is a const value of T):
Default constructor T()
Copy constructors T(t) and T(u)
Destructor t.~T()
Address of &t and &u yielding T* and
const T* respectively
Assignment t = a where a is a
(possibly const) value of T
Special Case
Vectors of bit values (boolean 1/0 values) are handled as a special case by the standard library, so that
they can be efficiently packed several elements to a word. The operations for a boolean vector,
vector<bool>, are a superset of those for an ordinary vector, only the implementation is more
efficient.
Two member functions are available to the the boolean vector data type. One is flip(), which inverts
all the bits of the vector. Boolean vectors also return as reference an internal value that also supports
the flip() member function. The other vector<bool>-specific member function is a second form of the
swap() function
Interface
template <class T, class Allocator = allocator>
class vector {
public:
// Types
typedef T value_type;
typedef Allocator allocator_type;
typename reference;
typename const_reference;
typename iterator;
typename const_iterator;
typename size_type;
typename difference_type;
typename reverse_iterator;
typename const_reverse_iterator;
// Construct/Copy/Destroy