allocator_type
·
assign
·
at
·
back
·
begin
·
capacity
·
clear
·
const_iterator
·
const_reference
·
const_reverse_iterator
·
difference_type
·
empty
·
end
·
erase
·
front
·
get_allocator
·
insert
·
iterator
·
max_size
·
operator[]
·
pop_back
·
push_back
·
rbegin
·
reference
·
rend
·
reserve
·
resize
·
reverse_iterator
·
size
·
size_type
·
swap
·
value_type
·
vector
template<class T, class A = allocator<T> >
class vector {
public:
typedef A allocator_type;
typedef A::size_type size_type;
typedef A::difference_type difference_type;
typedef A::reference reference;
typedef A::const_reference const_reference;
typedef A::value_type value_type;
typedef T0 iterator;
typedef T1 const_iterator;
typedef reverse_iterator<iterator, value_type,
reference, A::pointer, difference_type>
reverse_iterator;
typedef reverse_iterator<const_iterator, value_type,
const_reference, A::const_pointer, difference_type>
const_reverse_iterator;
explicit vector(const A& al = A());
explicit vector(size_type n, const T& v = T(), const A& al = A());
vector(const vector& x);
vector(const_iterator first, const_iterator last,
const A& al = A());
void reserve(size_type n);
size_type capacity() const;
iterator begin();
const_iterator begin() const;
iterator end();
iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
void resize(size_type n, T x = T());
size_type size() const;
size_type max_size() const;
bool empty() const;
A get_allocator() const;
reference at(size_type pos);
const_reference at(size_type pos) const;
reference operator[](size_type pos);
const_reference operator[](size_type pos);
reference front();
const_reference front() const;
reference back();
const_reference back() const;
void push_back(const T& x);
void pop_back();
void assign(const_iterator first, const_iterator last);
void assign(size_type n, const T& x = T());
iterator insert(iterator it, const T& x = T());
void insert(iterator it, size_type n, const T& x);
void insert(iterator it,
const_iterator first, const_iterator last);
iterator erase(iterator it);
iterator erase(iterator first, iterator last);
void clear();
void swap(vector x);
protected:
A allocator;
};
The template class describes an object that controls a varying-length sequence of elements of type T
. The sequence is
stored as an array of T
.
The object allocates and frees storage for the sequence it controls through a protected object named allocator
, of
class A
. Such an allocator object must have the same external interface as an object of template class allocator
.
Note that allocator
is not copied when the object is assigned.
Vector reallocation occurs when a member function must grow the controlled sequence beyond its current storage capacity. Other insertions and erasures may alter various storage addresses within the sequence. In all such cases, iterators or references that point at altered portions of the controlled sequence become invalid.