Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::container::vector< T, BOOST_CONTAINER_DOCONLY > Class Template Reference

A vector is a sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. More...

#include <vector.hpp>

Inheritance diagram for boost::container::vector< T, BOOST_CONTAINER_DOCONLY >:

Public Types

typedef T value_type
 
typedef
::boost::container::allocator_traits
< Allocator >::pointer 
pointer
 
typedef
::boost::container::allocator_traits
< Allocator >::const_pointer 
const_pointer
 
typedef
::boost::container::allocator_traits
< Allocator >::reference 
reference
 
typedef
::boost::container::allocator_traits
< Allocator >::const_reference 
const_reference
 
typedef
::boost::container::allocator_traits
< Allocator >::size_type 
size_type
 
typedef
::boost::container::allocator_traits
< Allocator >::difference_type 
difference_type
 
typedef Allocator allocator_type
 
typedef Allocator stored_allocator_type
 

Public Member Functions

typedef BOOST_CONTAINER_IMPDEF (iterator_impl) iterator
 
typedef BOOST_CONTAINER_IMPDEF (const_iterator_impl) const _iterator
 
typedef BOOST_CONTAINER_IMPDEF (container_detail::reverse_iterator< iterator >) reverse_iterator
 
typedef BOOST_CONTAINER_IMPDEF (container_detail::reverse_iterator< const_iterator >) const _reverse_iterator
 
 vector () BOOST_CONTAINER_NOEXCEPT_IF(
 Effects: Constructs a vector taking the allocator as parameter. More...
 
 vector (const Allocator &a) BOOST_CONTAINER_NOEXCEPT
 Effects: Constructs a vector taking the allocator as parameter. More...
 
 vector (size_type n)
 Effects: Constructs a vector that will use a copy of allocator a and inserts n value initialized values. More...
 
 vector (size_type n, default_init_t)
 Effects: Constructs a vector that will use a copy of allocator a and inserts n default initialized values. More...
 
 vector (size_type n, const T &value)
 Effects: Constructs a vector and inserts n copies of value. More...
 
 vector (size_type n, const T &value, const allocator_type &a)
 Effects: Constructs a vector that will use a copy of allocator a and inserts n copies of value. More...
 
template<class InIt >
 vector (InIt first, InIt last)
 Effects: Constructs a vector and inserts a copy of the range [first, last) in the vector. More...
 
template<class InIt >
 vector (InIt first, InIt last, const allocator_type &a)
 Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [first, last) in the vector. More...
 
 vector (const vector &x)
 Effects: Copy constructs a vector. More...
 
 vector (std::initializer_list< value_type > il, const allocator_type &a=allocator_type())
 Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [il.begin(), il.last()) in the vector More...
 
 vector (BOOST_RV_REF(vector) x) BOOST_CONTAINER_NOEXCEPT
 Effects: Move constructor. More...
 
template<class OtherAllocator >
 vector (BOOST_RV_REF_BEG vector< T, OtherAllocator > BOOST_RV_REF_END x, typename container_detail::enable_if_c< container_detail::is_version< OtherAllocator, 0 >::value >::type *=0)
 Effects: Move constructor. More...
 
 vector (const vector &x, const allocator_type &a)
 defined(BOOST_CONTAINER_DOXYGEN_INVOKED) More...
 
 vector (BOOST_RV_REF(vector) x, const allocator_type &a)
 Effects: Move constructor using the specified allocator. More...
 
 ~vector () BOOST_CONTAINER_NOEXCEPT
 Effects: Destroys the vector. More...
 
vectoroperator= (BOOST_COPY_ASSIGN_REF(vector) x)
 Effects: Makes *this contain the same elements as x. More...
 
vectoroperator= (std::initializer_list< value_type > il)
 Effects: Make *this container contains elements from il. More...
 
vectoroperator= (BOOST_RV_REF(vector) x) BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type
 Effects: Move assignment. More...
 
template<class OtherAllocator >
container_detail::enable_if_c
< container_detail::is_version
< OtherAllocator, 0 >::value
&&!container_detail::is_same
< OtherAllocator,
allocator_type >::value,
vector & >::type 
operator= (BOOST_RV_REF_BEG vector< value_type, OtherAllocator > BOOST_RV_REF_END x)
 Effects: Move assignment. More...
 
template<class OtherAllocator >
container_detail::enable_if_c
< container_detail::is_version
< OtherAllocator, 0 >::value
&&!container_detail::is_same
< OtherAllocator,
allocator_type >::value,
vector & >::type 
operator= (const vector< value_type, OtherAllocator > &x)
 Effects: Copy assignment. More...
 
template<class InIt >
void assign (InIt first, InIt last BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< InIt BOOST_CONTAINER_I size_type >::value &&(container_detail::is_input_iterator< InIt >::value||container_detail::is_same< alloc_version BOOST_CONTAINER_I allocator_v0 >::value) >::type *=0))
 Effects: Assigns the the range [first, last) to *this. More...
 
void assign (std::initializer_list< T > il)
 Effects: Assigns the the range [il.begin(), il.end()) to *this. More...
 
template<class FwdIt >
void assign (FwdIt first, FwdIt last BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< FwdIt BOOST_CONTAINER_I size_type >::value &&(!container_detail::is_input_iterator< FwdIt >::value &&!container_detail::is_same< alloc_version BOOST_CONTAINER_I allocator_v0 >::value) >::type *=0))
 Effects: Assigns the the range [first, last) to *this. More...
 
void assign (size_type n, const value_type &val)
 Effects: Assigns the n copies of val to *this. More...
 
allocator_type get_allocator () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a copy of the internal allocator. More...
 
stored_allocator_typeget_stored_allocator () BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a reference to the internal allocator. More...
 
const stored_allocator_typeget_stored_allocator () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a reference to the internal allocator. More...
 
iterator begin () BOOST_CONTAINER_NOEXCEPT
 Effects: Returns an iterator to the first element contained in the vector. More...
 
const_iterator begin () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_iterator to the first element contained in the vector. More...
 
iterator end () BOOST_CONTAINER_NOEXCEPT
 Effects: Returns an iterator to the end of the vector. More...
 
const_iterator end () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_iterator to the end of the vector. More...
 
reverse_iterator rbegin () BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a reverse_iterator pointing to the beginning of the reversed vector. More...
 
const_reverse_iterator rbegin () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector. More...
 
reverse_iterator rend () BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a reverse_iterator pointing to the end of the reversed vector. More...
 
const_reverse_iterator rend () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector. More...
 
const_iterator cbegin () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_iterator to the first element contained in the vector. More...
 
const_iterator cend () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_iterator to the end of the vector. More...
 
const_reverse_iterator crbegin () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector. More...
 
const_reverse_iterator crend () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector. More...
 
bool empty () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns true if the vector contains no elements. More...
 
size_type size () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns the number of the elements contained in the vector. More...
 
size_type max_size () const BOOST_CONTAINER_NOEXCEPT
 Effects: Returns the largest possible size of the vector. More...
 
void resize (size_type new_size)
 Effects: Inserts or erases elements at the end such that the size becomes n. More...
 
void resize (size_type new_size, default_init_t)
 Effects: Inserts or erases elements at the end such that the size becomes n. More...
 
void resize (size_type new_size, const T &x)
 Effects: Inserts or erases elements at the end such that the size becomes n. More...
 
size_type capacity () const BOOST_CONTAINER_NOEXCEPT
 Effects: Number of elements for which memory has been allocated. More...
 
void reserve (size_type new_cap)
 Effects: If n is less than or equal to capacity(), this call has no effect. More...
 
void shrink_to_fit ()
 Effects: Tries to deallocate the excess of memory created with previous allocations. More...
 
reference front () BOOST_CONTAINER_NOEXCEPT
 Requires: !empty() More...
 
const_reference front () const BOOST_CONTAINER_NOEXCEPT
 Requires: !empty() More...
 
reference back () BOOST_CONTAINER_NOEXCEPT
 Requires: !empty() More...
 
const_reference back () const BOOST_CONTAINER_NOEXCEPT
 Requires: !empty() More...
 
reference operator[] (size_type n) BOOST_CONTAINER_NOEXCEPT
 Requires: size() > n. More...
 
const_reference operator[] (size_type n) const BOOST_CONTAINER_NOEXCEPT
 Requires: size() > n. More...
 
reference at (size_type n)
 Requires: size() > n. More...
 
const_reference at (size_type n) const
 Requires: size() > n. More...
 
Tdata () BOOST_CONTAINER_NOEXCEPT
 Returns: Allocator pointer such that [data(),data() + size()) is a valid range. More...
 
const Tdata () const BOOST_CONTAINER_NOEXCEPT
 Returns: Allocator pointer such that [data(),data() + size()) is a valid range. More...
 
iterator insert (const_iterator p, size_type n, const T &x)
 Requires: p must be a valid iterator of *this. More...
 
template<class InIt >
iterator insert (const_iterator pos, InIt first, InIt last BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< InIt BOOST_CONTAINER_I size_type >::value &&container_detail::is_input_iterator< InIt >::value >::type *=0))
 Requires: p must be a valid iterator of *this. More...
 
template<class FwdIt >
iterator insert (const_iterator pos, FwdIt first, FwdIt last, typename container_detail::enable_if_c< !container_detail::is_convertible< FwdIt, size_type >::value &&!container_detail::is_input_iterator< FwdIt >::value >::type *=0)
 
template<class InIt >
iterator insert (const_iterator pos, size_type num, InIt first, InIt last)
 Requires: p must be a valid iterator of *this. More...
 
iterator insert (const_iterator position, std::initializer_list< value_type > il)
 Requires: position must be a valid iterator of *this. More...
 
void pop_back () BOOST_CONTAINER_NOEXCEPT
 Effects: Removes the last element from the vector. More...
 
iterator erase (const_iterator position)
 Effects: Erases the element at position pos. More...
 
iterator erase (const_iterator first, const_iterator last)
 Effects: Erases the elements pointed by [first, last). More...
 
void swap (vector &x) BOOST_CONTAINER_NOEXCEPT_IF((!container_detail
 Effects: Swaps the contents of *this and x. More...
 
template<class OtherAllocator >
void swap (vector< T, OtherAllocator > &x, typename container_detail::enable_if_c< container_detail::is_version< OtherAllocator, 0 >::value &&!container_detail::is_same< OtherAllocator, allocator_type >::value >::type *=0)
 Effects: Swaps the contents of *this and x. More...
 
void clear () BOOST_CONTAINER_NOEXCEPT
 Effects: Erases all the elements of the vector. More...
 
bool stable_reserve (size_type new_cap)
 Effects: If n is less than or equal to capacity(), this call has no effect. More...
 
template<class BiDirPosConstIt , class BiDirValueIt >
void insert_ordered_at (const size_type element_count, BiDirPosConstIt last_position_it, BiDirValueIt last_value_it)
 

Friends

template<class U , class UAllocator >
class vector
 
bool operator== (const vector &x, const vector &y)
 Effects: Returns true if x and y are equal More...
 
bool operator!= (const vector &x, const vector &y)
 Effects: Returns true if x and y are unequal More...
 
bool operator< (const vector &x, const vector &y)
 Effects: Returns true if x is less than y More...
 
bool operator> (const vector &x, const vector &y)
 Effects: Returns true if x is greater than y More...
 
bool operator<= (const vector &x, const vector &y)
 Effects: Returns true if x is equal or less than y More...
 
bool operator>= (const vector &x, const vector &y)
 Effects: Returns true if x is equal or greater than y More...
 
void swap (vector &x, vector &y)
 Effects: x.swap(y) More...
 

Detailed Description

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
class boost::container::vector< T, BOOST_CONTAINER_DOCONLY >

A vector is a sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle.

The number of elements in a vector may vary dynamically; memory management is automatic.

Template Parameters
TThe type of object that is stored in the vector
AllocatorThe allocator used for all internal memory management

Member Typedef Documentation

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef Allocator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::allocator_type
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::const_pointer boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::const_pointer
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::const_reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::const_reference
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::difference_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::difference_type
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::pointer boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::pointer
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::reference
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef ::boost::container::allocator_traits<Allocator>::size_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::size_type
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef Allocator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::stored_allocator_type
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef T boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::value_type

Constructor & Destructor Documentation

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( )
inline

Effects: Constructs a vector taking the allocator as parameter.

Throws: If allocator_type's default constructor throws.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( const Allocator &  a)
inlineexplicit

Effects: Constructs a vector taking the allocator as parameter.

Throws: Nothing

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( size_type  n)
inlineexplicit

Effects: Constructs a vector that will use a copy of allocator a and inserts n value initialized values.

Throws: If allocator_type's default constructor or allocation throws or T's value initialization throws.

Complexity: Linear to n.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( size_type  n,
default_init_t   
)
inline

Effects: Constructs a vector that will use a copy of allocator a and inserts n default initialized values.

Throws: If allocator_type's default constructor or allocation throws or T's default initialization throws.

Complexity: Linear to n.

Note: Non-standard extension

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( size_type  n,
const T value 
)
inline

Effects: Constructs a vector and inserts n copies of value.

Throws: If allocator_type's default constructor or allocation throws or T's copy constructor throws.

Complexity: Linear to n.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( size_type  n,
const T value,
const allocator_type a 
)
inline

Effects: Constructs a vector that will use a copy of allocator a and inserts n copies of value.

Throws: If allocation throws or T's copy constructor throws.

Complexity: Linear to n.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class InIt >
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( InIt  first,
InIt  last 
)
inline

Effects: Constructs a vector and inserts a copy of the range [first, last) in the vector.

Throws: If allocator_type's default constructor or allocation throws or T's constructor taking a dereferenced InIt throws.

Complexity: Linear to the range [first, last).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class InIt >
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( InIt  first,
InIt  last,
const allocator_type a 
)
inline

Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [first, last) in the vector.

Throws: If allocator_type's default constructor or allocation throws or T's constructor taking a dereferenced InIt throws.

Complexity: Linear to the range [first, last).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x)
inline

Effects: Copy constructs a vector.

Postcondition: x == *this.

Throws: If allocator_type's default constructor or allocation throws or T's copy constructor throws.

Complexity: Linear to the elements x contains.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( std::initializer_list< value_type il,
const allocator_type a = allocator_type() 
)
inline

Effects: Constructs a vector that will use a copy of allocator a and inserts a copy of the range [il.begin(), il.last()) in the vector

Throws: If allocator_type's default constructor throws or T's constructor taking a dereferenced initializer_list iterator throws.

Complexity: Linear to the range [il.begin(), il.end()).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( BOOST_RV_REF(vector< T, BOOST_CONTAINER_DOCONLY >)  x)
inline

Effects: Move constructor.

Moves x's resources to *this.

Throws: Nothing

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class OtherAllocator >
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( BOOST_RV_REF_BEG vector< T, OtherAllocator > BOOST_RV_REF_END  x,
typename container_detail::enable_if_c< container_detail::is_version< OtherAllocator, 0 >::value >::type = 0 
)
inline

Effects: Move constructor.

Moves x's resources to *this.

Throws: If T's move constructor or allocation throws

Complexity: Linear.

Note: Non-standard extension to support static_vector

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const allocator_type a 
)
inline

defined(BOOST_CONTAINER_DOXYGEN_INVOKED)

Effects: Copy constructs a vector using the specified allocator.

Postcondition: x == *this.

Throws: If allocation throws or T's copy constructor throws.

Complexity: Linear to the elements x contains.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::vector ( BOOST_RV_REF(vector< T, BOOST_CONTAINER_DOCONLY >)  x,
const allocator_type a 
)
inline

Effects: Move constructor using the specified allocator.

Moves x's resources to *this if a == allocator_type(). Otherwise copies values from x to *this.

Throws: If allocation or T's copy constructor throws.

Complexity: Constant if a == x.get_allocator(), linear otherwise.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::~vector ( )
inline

Effects: Destroys the vector.

All stored values are destroyed and used memory is deallocated.

Throws: Nothing.

Complexity: Linear to the number of elements.

Member Function Documentation

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class InIt >
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::assign ( InIt  first,
InIt last   BOOST_CONTAINER_DOCIGNBOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< InIt BOOST_CONTAINER_I size_type >::value &&(container_detail::is_input_iterator< InIt >::value||container_detail::is_same< alloc_version BOOST_CONTAINER_I allocator_v0 >::value) >::type *=0 
)
inline

Effects: Assigns the the range [first, last) to *this.

Throws: If memory allocation throws or T's copy/move constructor/assignment or T's constructor/assignment from dereferencing InpIt throws.

Complexity: Linear to n.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::assign().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::assign ( std::initializer_list< T il)
inline

Effects: Assigns the the range [il.begin(), il.end()) to *this.

Throws: If memory allocation throws or T's constructor from dereferencing iniializer_list iterator throws.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class FwdIt >
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::assign ( FwdIt  first,
FwdIt last   BOOST_CONTAINER_DOCIGNBOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< FwdIt BOOST_CONTAINER_I size_type >::value &&(!container_detail::is_input_iterator< FwdIt >::value &&!container_detail::is_same< alloc_version BOOST_CONTAINER_I allocator_v0 >::value) >::type *=0 
)
inline

Effects: Assigns the the range [first, last) to *this.

Throws: If memory allocation throws or T's copy/move constructor/assignment or T's constructor/assignment from dereferencing InpIt throws.

Complexity: Linear to n.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::assign ( size_type  n,
const value_type val 
)
inline

Effects: Assigns the n copies of val to *this.

Throws: If memory allocation throws or T's copy/move constructor/assignment throws.

Complexity: Linear to n.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::at ( size_type  n)
inline

Requires: size() > n.

Effects: Returns a reference to the nth element from the beginning of the container.

Throws: std::range_error if n >= size()

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::at ( size_type  n) const
inline

Requires: size() > n.

Effects: Returns a const reference to the nth element from the beginning of the container.

Throws: std::range_error if n >= size()

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::back ( )
inline

Requires: !empty()

Effects: Returns a reference to the last element of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::back ( ) const
inline

Requires: !empty()

Effects: Returns a const reference to the last element of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::begin ( )
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::begin ( ) const
inline

Effects: Returns a const_iterator to the first element contained in the vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::BOOST_CONTAINER_IMPDEF ( iterator_impl  )
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::BOOST_CONTAINER_IMPDEF ( const_iterator_impl  ) const
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::BOOST_CONTAINER_IMPDEF ( container_detail::reverse_iterator< iterator >  )
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
typedef boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::BOOST_CONTAINER_IMPDEF ( container_detail::reverse_iterator< const_iterator >  ) const
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
size_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::capacity ( ) const
inline

Effects: Number of elements for which memory has been allocated.

capacity() is always greater than or equal to size().

Throws: Nothing.

Complexity: Constant.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::assign(), and boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::reserve().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::cbegin ( ) const
inline

Effects: Returns a const_iterator to the first element contained in the vector.

Throws: Nothing.

Complexity: Constant.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::insert().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::cend ( ) const
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::clear ( )
inline

Effects: Erases all the elements of the vector.

Throws: Nothing.

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::crbegin ( ) const
inline

Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.

Throws: Nothing.

Complexity: Constant.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::rbegin().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::crend ( ) const
inline

Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.

Throws: Nothing.

Complexity: Constant.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::rend().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
T* boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::data ( )
inline

Returns: Allocator pointer such that [data(),data() + size()) is a valid range.

For a non-empty vector, data() == &front().

Throws: Nothing.

Complexity: Constant.

Referenced by boost::container::stable_vector_detail::index_traits< VoidPtr, VoidAllocator >::initialize_end_node().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const T* boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::data ( ) const
inline

Returns: Allocator pointer such that [data(),data() + size()) is a valid range.

For a non-empty vector, data() == &front().

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::empty ( ) const
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::end ( ) const
inline

Effects: Returns a const_iterator to the end of the vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::erase ( const_iterator  position)
inline

Effects: Erases the element at position pos.

Throws: Nothing.

Complexity: Linear to the elements between pos and the last element. Constant if pos is the last element.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Effects: Erases the elements pointed by [first, last).

Throws: Nothing.

Complexity: Linear to the distance between first and last plus linear to the elements between pos and the last element.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::front ( )
inline

Requires: !empty()

Effects: Returns a reference to the first element of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::front ( ) const
inline

Requires: !empty()

Effects: Returns a const reference to the first element of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
allocator_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::get_allocator ( ) const
inline

Effects: Returns a copy of the internal allocator.

Throws: If allocator's copy constructor throws.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
stored_allocator_type& boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::get_stored_allocator ( )
inline

Effects: Returns a reference to the internal allocator.

Throws: Nothing

Complexity: Constant.

Note: Non-standard extension.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::~vector().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const stored_allocator_type& boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::get_stored_allocator ( ) const
inline

Effects: Returns a reference to the internal allocator.

Throws: Nothing

Complexity: Constant.

Note: Non-standard extension.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert ( const_iterator  p,
size_type  n,
const T x 
)
inline

Requires: p must be a valid iterator of *this.

Effects: Insert n copies of x before pos.

Returns: an iterator to the first inserted element or p if n is 0.

Throws: If memory allocation throws or T's copy/move constructor throws.

Complexity: Linear to n.

Referenced by boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::assign(), and boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::vector().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class InIt >
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert ( const_iterator  pos,
InIt  first,
InIt last   BOOST_CONTAINER_DOCIGNBOOST_CONTAINER_I typename container_detail::enable_if_c< !container_detail::is_convertible< InIt BOOST_CONTAINER_I size_type >::value &&container_detail::is_input_iterator< InIt >::value >::type *=0 
)
inline

Requires: p must be a valid iterator of *this.

Effects: Insert a copy of the [first, last) range before pos.

Returns: an iterator to the first inserted element or pos if first == last.

Throws: If memory allocation throws, T's constructor from a dereferenced InpIt throws or T's copy/move constructor/assignment throws.

Complexity: Linear to std::distance [first, last).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class FwdIt >
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert ( const_iterator  pos,
FwdIt  first,
FwdIt  last,
typename container_detail::enable_if_c< !container_detail::is_convertible< FwdIt, size_type >::value &&!container_detail::is_input_iterator< FwdIt >::value >::type = 0 
)
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class InIt >
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert ( const_iterator  pos,
size_type  num,
InIt  first,
InIt  last 
)
inline

Requires: p must be a valid iterator of *this.

num, must be equal to std::distance(first, last)

Effects: Insert a copy of the [first, last) range before pos.

Returns: an iterator to the first inserted element or pos if first == last.

Throws: If memory allocation throws, T's constructor from a dereferenced InpIt throws or T's copy/move constructor/assignment throws.

Complexity: Linear to std::distance [first, last).

Note: This function avoids a linear operation to calculate std::distance[first, last) for forward and bidirectional iterators, and a one by one insertion for input iterators. This is a a non-standard extension.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert ( const_iterator  position,
std::initializer_list< value_type il 
)
inline

Requires: position must be a valid iterator of *this.

Effects: Insert a copy of the [il.begin(), il.end()) range before position.

Returns: an iterator to the first inserted element or position if first == last.

Complexity: Linear to the range [il.begin(), il.end()).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class BiDirPosConstIt , class BiDirValueIt >
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::insert_ordered_at ( const size_type  element_count,
BiDirPosConstIt  last_position_it,
BiDirValueIt  last_value_it 
)
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
size_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::max_size ( ) const
inline

Effects: Returns the largest possible size of the vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
vector& boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator= ( BOOST_COPY_ASSIGN_REF(vector< T, BOOST_CONTAINER_DOCONLY >)  x)
inline

Effects: Makes *this contain the same elements as x.

Postcondition: this->size() == x.size(). *this contains a copy of each of x's elements.

Throws: If memory allocation throws or T's copy/move constructor/assignment throws.

Complexity: Linear to the number of elements in x.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
vector& boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator= ( std::initializer_list< value_type il)
inline

Effects: Make *this container contains elements from il.

Complexity: Linear to the range [il.begin(), il.end()).

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
vector& boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator= ( BOOST_RV_REF(vector< T, BOOST_CONTAINER_DOCONLY >)  x)
inline

Effects: Move assignment.

All x's values are transferred to *this.

Postcondition: x.empty(). *this contains a the elements x had before the function.

Throws: If allocator_traits_type::propagate_on_container_move_assignment is false and (allocation throws or value_type's move constructor throws)

Complexity: Constant if allocator_traits_type:: propagate_on_container_move_assignment is true or this->get>allocator() == x.get_allocator(). Linear otherwise.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class OtherAllocator >
container_detail::enable_if_c< container_detail::is_version<OtherAllocator, 0>::value && !container_detail::is_same<OtherAllocator, allocator_type>::value , vector& >::type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator= ( BOOST_RV_REF_BEG vector< value_type, OtherAllocator > BOOST_RV_REF_END  x)
inline

Effects: Move assignment.

All x's values are transferred to *this.

Postcondition: x.empty(). *this contains a the elements x had before the function.

Throws: If move constructor/assignment of T throws or allocation throws

Complexity: Linear.

Note: Non-standard extension to support static_vector

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class OtherAllocator >
container_detail::enable_if_c< container_detail::is_version<OtherAllocator, 0>::value && !container_detail::is_same<OtherAllocator, allocator_type>::value , vector& >::type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator= ( const vector< value_type, OtherAllocator > &  x)
inline

Effects: Copy assignment.

All x's values are copied to *this.

Postcondition: x.empty(). *this contains a the elements x had before the function.

Throws: If move constructor/assignment of T throws or allocation throws

Complexity: Linear.

Note: Non-standard extension to support static_vector

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator[] ( size_type  n)
inline

Requires: size() > n.

Effects: Returns a reference to the nth element from the beginning of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reference boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::operator[] ( size_type  n) const
inline

Requires: size() > n.

Effects: Returns a const reference to the nth element from the beginning of the container.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::pop_back ( )
inline

Effects: Removes the last element from the vector.

Throws: Nothing.

Complexity: Constant time.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::rbegin ( )
inline

Effects: Returns a reverse_iterator pointing to the beginning of the reversed vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::rbegin ( ) const
inline

Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::rend ( )
inline

Effects: Returns a reverse_iterator pointing to the end of the reversed vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
const_reverse_iterator boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::rend ( ) const
inline

Effects: Returns a const_reverse_iterator pointing to the end of the reversed vector.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::reserve ( size_type  new_cap)
inline

Effects: If n is less than or equal to capacity(), this call has no effect.

Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.

Throws: If memory allocation allocation throws or T's copy/move constructor throws.

Referenced by boost::container::stable_vector_detail::index_traits< VoidPtr, VoidAllocator >::initialize_end_node(), and boost::container::vector< Value, container_detail::static_storage_allocator< Value, Capacity > >::insert_ordered_at().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::resize ( size_type  new_size)
inline

Effects: Inserts or erases elements at the end such that the size becomes n.

New elements are value initialized.

Throws: If memory allocation throws, or T's copy/move or value initialization throws.

Complexity: Linear to the difference between size() and new_size.

Referenced by boost::container::stable_vector_detail::index_traits< VoidPtr, VoidAllocator >::initialize_end_node().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::resize ( size_type  new_size,
default_init_t   
)
inline

Effects: Inserts or erases elements at the end such that the size becomes n.

New elements are default initialized.

Throws: If memory allocation throws, or T's copy/move or default initialization throws.

Complexity: Linear to the difference between size() and new_size.

Note: Non-standard extension

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::resize ( size_type  new_size,
const T x 
)
inline

Effects: Inserts or erases elements at the end such that the size becomes n.

New elements are copy constructed from x.

Throws: If memory allocation throws, or T's copy/move constructor throws.

Complexity: Linear to the difference between size() and new_size.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::shrink_to_fit ( )
inline

Effects: Tries to deallocate the excess of memory created with previous allocations.

The size of the vector is unchanged

Throws: If memory allocation throws, or T's copy/move constructor throws.

Complexity: Linear to size().

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
size_type boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::size ( ) const
inline
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::stable_reserve ( size_type  new_cap)
inline

Effects: If n is less than or equal to capacity(), this call has no effect.

Otherwise, it is a request for allocation of additional memory (memory expansion) that will not invalidate iterators. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.

Throws: If memory allocation allocation throws or T's copy/move constructor throws.

Note: Non-standard extension.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::swap ( vector< T, BOOST_CONTAINER_DOCONLY > &  x)
inline

Effects: Swaps the contents of *this and x.

Throws: Nothing.

Complexity: Constant.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class OtherAllocator >
void boost::container::vector< T, BOOST_CONTAINER_DOCONLY >::swap ( vector< T, OtherAllocator > &  x,
typename container_detail::enable_if_c< container_detail::is_version< OtherAllocator, 0 >::value &&!container_detail::is_same< OtherAllocator, allocator_type >::value >::type = 0 
)
inline

Effects: Swaps the contents of *this and x.

Throws: Nothing.

Complexity: Linear

Note: Non-standard extension to support static_vector

Friends And Related Function Documentation

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
template<class U , class UAllocator >
friend class vector
friend
template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator!= ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x and y are unequal

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator< ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x is less than y

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator<= ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x is equal or less than y

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator== ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x and y are equal

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator> ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x is greater than y

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
bool operator>= ( const vector< T, BOOST_CONTAINER_DOCONLY > &  x,
const vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: Returns true if x is equal or greater than y

Complexity: Linear to the number of elements in the container.

template<class T, class Allocator BOOST_CONTAINER_DOCONLY>
void swap ( vector< T, BOOST_CONTAINER_DOCONLY > &  x,
vector< T, BOOST_CONTAINER_DOCONLY > &  y 
)
friend

Effects: x.swap(y)

Complexity: Constant.


The documentation for this class was generated from the following files: