# std::__debug::vector< _Tp, _Allocator > Class Template Reference

Inheritance diagram for std::__debug::vector< _Tp, _Allocator >:

List of all members.

## Detailed Description

### template<typename _Tp, typename _Allocator = std::allocator<_Tp>>
class std::__debug::vector< _Tp, _Allocator >

Definition at line 49 of file debug/vector.

## Public Types

- typedef _Allocator allocator_type
- typedef __gnu_debug::_Safe_iterator<
  typename _Base::const_iterator,
  vector > const_iterator
- typedef _Base::const_pointer const_pointer
- typedef _Base::const_reference const_reference
- typedef std::reverse_iterator<
  const_iterator > const_reverse_iterator
- typedef _Base::difference_type difference_type
- typedef __gnu_debug::_Safe_iterator<
  typename _Base::iterator,
  vector > iterator
- typedef _Base::pointer pointer
- typedef _Base::reference reference
- typedef std::reverse_iterator<
  iterator > reverse_iterator
- typedef _Base::size_type size_type
- typedef _Tp value_type

## Public Member Functions

- const _Base & _M_base () const
- _Base & _M_base ()
- void _M_invalidate_all () const
- template<typename _Predicate> void _M_invalidate_if (_Predicate __pred)
- template<typename _Iterator> void _M_transfer_iter (const _Safe_iterator< _Iterator, _Sequence > &__x)
- void assign (size_type __n, const value_type &__val)
- void assign (size_type __n, const _Tp &__u)
- template<typename _InputIterator> void assign (_InputIterator __first, _InputIterator __last)
- const_reference at (size_type __n) const
- reference at (size_type __n)
- const_reference back () const
- reference back ()
- const_iterator begin () const
- iterator begin ()
- size_type capacity () const
- void clear ()
- const_pointer data () const
- pointer data ()
- bool empty () const
- const_iterator end () const
- iterator end ()
- iterator erase (iterator __first, iterator __last)
- iterator erase (iterator __position)
- iterator erase (iterator __first, iterator __last)
- iterator erase (iterator __position)
- const_reference front () const
- reference front ()
- void insert (iterator __position, _InputIterator __first, _InputIterator __last)
- void insert (iterator __position, size_type __n, const value_type &__x)
- iterator insert (iterator __position, const value_type &__x)
- template<class _InputIterator> void insert (iterator __position, _InputIterator __first, _InputIterator __last)
- void insert (iterator __position, size_type __n, const _Tp &__x)
- iterator insert (iterator __position, const _Tp &__x)
- size_type max_size () const
- vector< _Tp, _Allocator > & operator= (const vector< _Tp, _Allocator > &__x)
- const_reference operator[] (size_type __n) const
- reference operator[] (size_type __n)
- const_reference operator[] (size_type __n) const
- reference operator[] (size_type __n)
- void pop_back ()
- void push_back (const _Tp &__x)
- const_reverse_iterator rbegin () const
- reverse_iterator rbegin ()
- const_reverse_iterator rend () const
- reverse_iterator rend ()
- void reserve (size_type __n)
- void reserve (size_type __n)
- void resize (size_type __new_size, value_type __x=value_type())
- void resize (size_type __sz, _Tp __c=_Tp())
- size_type size () const
- void swap (vector &__x)
- void swap (vector< _Tp, _Allocator > &__x)
- vector (const _Base &__x)
- vector (const vector< _Tp, _Allocator > &__x)
- template<class _InputIterator> vector (_InputIterator __first, _InputIterator __last, const _Allocator &__a=_Allocator())
- vector (size_type __n, const _Tp &__value=_Tp(), const _Allocator &__a=_Allocator())
- vector (const _Allocator &__a=_Allocator())
- ~vector ()

## Public Attributes

- _Safe_iterator_base * _M_const_iterators
- _Safe_iterator_base * _M_iterators
- unsigned int _M_version

## Protected Member Functions

- _Tp * _M_allocate (size_t __n)
- pointer _M_allocate_and_copy (size_type __n, _ForwardIterator __first, _ForwardIterator __last)
- void _M_assign_aux (_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)
- void _M_assign_aux (_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
- void _M_assign_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
- void _M_assign_dispatch (_Integer __n, _Integer __val, __true_type)
- void _M_deallocate (_Tp *__p, size_t __n)
- void _M_detach_all ()
- void _M_detach_singular ()
- void _M_erase_at_end (pointer __pos)
- void _M_fill_assign (size_type __n, const value_type &__val)
- void _M_fill_insert (iterator __pos, size_type __n, const value_type &__x)
- __gnu_cxx::__mutex & _M_get_mutex ()
- const _Tp_alloc_type & _M_get_Tp_allocator () const
- _Tp_alloc_type & _M_get_Tp_allocator ()
- void _M_initialize_dispatch (_InputIterator __first, _InputIterator __last, __false_type)
- void _M_initialize_dispatch (_Integer __n, _Integer __value, __true_type)
- void _M_insert_aux (iterator __position, const value_type &__x)
- void _M_insert_dispatch (iterator __pos, _InputIterator __first, _InputIterator __last, __false_type)
- void _M_insert_dispatch (iterator __pos, _Integer __n, _Integer __val, __true_type)
- void _M_range_check (size_type __n) const
- void _M_range_initialize (_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)
- void _M_range_initialize (_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
- void _M_range_insert (iterator __pos, _ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag)
- void _M_range_insert (iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag)
- void _M_revalidate_singular ()
- void _M_swap (_Safe_sequence_base &__x)
- allocator_type get_allocator () const

## Protected Attributes

- _Vector_impl _M_impl

## Constructor & Destructor Documentation

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

std::__debug::vector< _Tp, _Allocator >::vector | ( | const _Allocator & | __a = `_Allocator()` | ) | `[inline, explicit]`

Default constructor creates no elements.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 79 of file debug/vector.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>
template<class _InputIterator>

std::__debug::vector< _Tp, _Allocator >::vector | ( | _InputIterator | __first,
|  | _InputIterator | __last,
|  | const _Allocator & | __a = `_Allocator()` |
| ) |  |  | `[inline]`

Builds a vector from a range.

Parameters:

  | first | An input iterator.
  | last | An input iterator.

Create a vector consisting of copies of the elements from [first,last).

If the iterators are forward, bidirectional, or random-access, then this will call the elements' copy constructor N times (where N is distance(first,last)) and do no memory reallocation. But if only input iterators are used, then this will do at most 2N calls to the copy constructor, and logN memory reallocations.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 87 of file debug/vector.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

std::__debug::vector< _Tp, _Allocator >::vector | ( | const _Base & | __x | ) | `[inline]`

Construction from a release-mode vector.

Definition at line 98 of file debug/vector.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

std::__debug::vector< _Tp, _Allocator >::~vector | ( |  | ) | `[inline]`

The dtor only erases the elements, and note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 101 of file debug/vector.

## Member Function Documentation

void __gnu_debug::_Safe_sequence_base::_M_detach_all | ( |  | ) | `[protected, inherited]`

Detach all iterators, leaving them singular.

Referenced by __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base().

void __gnu_debug::_Safe_sequence_base::_M_detach_singular | ( |  | ) | `[protected, inherited]`

Detach all singular iterators.

Postcondition:
  for all iterators i attached to this sequence, i->_M_version == _M_version.

Referenced by std::__debug::deque< _Tp, _Allocator >::erase(), and std::__debug::list< _Tp, _Allocator >::resize().

__gnu_cxx::__mutex& __gnu_debug::_Safe_sequence_base::_M_get_mutex | ( |  | ) | `[protected, inherited]`

For use in _Safe_sequence.

void __gnu_debug::_Safe_sequence_base::_M_invalidate_all | ( |  | ) | const`[inline, inherited]`

Invalidates all iterators.

Definition at line 220 of file safe_base.h.

References __gnu_debug::_Safe_sequence_base::_M_version.

Referenced by __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::append(), std::__debug::vector< _Tp, _Allocator >::assign(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::assign(), std::__debug::deque< _Tp, _Allocator >::assign(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::c_str(), std::__debug::vector< _Tp, _Allocator >::clear(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::clear(), std::__debug::deque< _Tp, _Allocator >::clear(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::data(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::erase(), std::__debug::deque< _Tp, _Allocator >::erase(), __gnu_debug::getline(), std::__debug::vector< _Tp, _Allocator >::insert(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::insert(), std::__debug::deque< _Tp, _Allocator >::insert(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::operator+=(), std::__debug::vector< _Tp, _Allocator >::operator=(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::operator=(), std::__debug::deque< _Tp, _Allocator >::operator=(), __gnu_debug::operator>>(), std::__debug::vector< _Tp, _Allocator >::push_back(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::push_back(), std::__debug::deque< _Tp, _Allocator >::push_back(), std::__debug::deque< _Tp, _Allocator >::push_front(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::replace(), std::__debug::vector< _Tp, _Allocator >::reserve(), std::__debug::vector< _Tp, _Allocator >::resize(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::resize(), std::__debug::deque< _Tp, _Allocator >::resize(), and __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::swap().

template<typename _Sequence>
template<typename _Predicate>

void __gnu_debug::_Safe_sequence< _Sequence >::_M_invalidate_if | ( | _Predicate | __pred | ) | `[inherited]`

Invalidates all iterators `x` that reference this sequence, are not singular, and for which `pred(x)` returns `true`. The user of this routine should be careful not to make copies of the iterators passed to `pred`, as the copies may interfere with the invalidation.

Definition at line 126 of file safe_sequence.h.

References __gnu_debug::_Safe_sequence_base::_M_const_iterators, and __gnu_debug::_Safe_sequence_base::_M_iterators.

Referenced by std::__debug::vector< _Tp, _Allocator >::erase(), std::__debug::vector< _Tp, _Allocator >::insert(), std::__debug::vector< _Tp, _Allocator >::resize(), and std::__debug::deque< _Tp, _Allocator >::resize().

void __gnu_debug::_Safe_sequence_base::_M_revalidate_singular | ( |  | ) | `[protected, inherited]`

Revalidates all attached singular iterators. This method may be used to validate iterators that were invalidated before (but for some reasion, such as an exception, need to become valid again).

Referenced by std::__debug::deque< _Tp, _Allocator >::erase(), and std::__debug::list< _Tp, _Allocator >::resize().

void __gnu_debug::_Safe_sequence_base::_M_swap | ( | _Safe_sequence_base & | __x | ) | `[protected, inherited]`

Swap this sequence with the given sequence. This operation also swaps ownership of the iterators, so that when the operation is complete all iterators that originally referenced one container now reference the other container.

Referenced by std::__debug::vector< _Tp, _Allocator >::swap(), __gnu_debug::basic_string< _CharT, _Traits, _Allocator >::swap(), std::__debug::set< _Key, _Compare, _Allocator >::swap(), std::__debug::multiset< _Key, _Compare, _Allocator >::swap(), std::__debug::multimap< _Key, _Tp, _Compare, _Allocator >::swap(), std::__debug::map< _Key, _Tp, _Compare, _Allocator >::swap(), std::__debug::list< _Tp, _Allocator >::swap(), __gnu_cxx::__debug::hash_set< _Value, _HashFcn, _EqualKey, _Alloc >::swap(), __gnu_cxx::__debug::hash_multiset< _Value, _HashFcn, _EqualKey, _Alloc >::swap(), __gnu_cxx::__debug::hash_multimap< _Value, _Tp, _HashFcn, _EqualKey, _Alloc >::swap(), __gnu_cxx::__debug::hash_map< _Value, _Tp, _HashFcn, _EqualKey, _Alloc >::swap(), and std::__debug::deque< _Tp, _Allocator >::swap().

template<typename _Sequence>
template<typename _Iterator>

void __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_iter | ( | const _Safe_iterator< _Iterator, _Sequence > & | __x | ) | `[inherited]`

Transfers all iterators that reference this memory location to this sequence from whatever sequence they are attached to.

Definition at line 159 of file safe_sequence.h.

References __gnu_debug::_Safe_sequence_base::_M_const_iterators, __gnu_debug::_Safe_sequence_base::_M_iterators, __gnu_debug::_Safe_iterator_base::_M_sequence, and __gnu_debug::_Safe_iterator< _Iterator, _Sequence >::base().

Referenced by std::__debug::list< _Tp, _Allocator >::splice().

void std::vector< _Tp , _Allocator >::assign | ( | size_type | __n,
|  | const value_type & | __val |
| ) |  |  | `[inline, inherited]`

Assigns a given value to a vector.

Parameters:

  | n | Number of elements to be assigned.
  | val | Value to be assigned.

This function fills a vector with n copies of the given value. Note that the assignment completely changes the vector and that the resulting vector's size is the same as the number of elements assigned. Old data may be lost.

Definition at line 293 of file stl_vector.h.

Referenced by std::__debug::vector< _Tp, _Allocator >::assign().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>
template<typename _InputIterator>

void std::__debug::vector< _Tp, _Allocator >::assign | ( | _InputIterator | __first,
|  | _InputIterator | __last |
| ) |  |  | `[inline]`

Assigns a range to a vector.

Parameters:

  | first | An input iterator.
  | last | An input iterator.

This function fills a vector with copies of the elements in the range [first,last).

Note that the assignment completely changes the vector and that the resulting vector's size is the same as the number of elements assigned. Old data may be lost.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 114 of file debug/vector.

References __glibcxx_check_valid_range, __gnu_debug::_Safe_sequence_base::_M_invalidate_all(), and std::vector< _Tp, _Allocator >::assign().

const_reference std::vector< _Tp , _Allocator >::at | ( | size_type | __n | ) | const`[inline, inherited]`

Provides access to the data contained in the vector.

Parameters:

  | n | The index of the element for which data should be accessed.

Returns:
  Read-only (constant) reference to data.

Exceptions:

  | std::out_of_range | If n is an invalid index.

This function provides for safer data access. The parameter is first checked that it is in the range of the vector. The function throws out_of_range if the check fails.

Definition at line 532 of file stl_vector.h.

reference std::vector< _Tp , _Allocator >::at | ( | size_type | __n | ) | `[inline, inherited]`

Provides access to the data contained in the vector.

Parameters:

  | n | The index of the element for which data should be accessed.

Returns:
  Read/write reference to data.

Exceptions:

  | std::out_of_range | If n is an invalid index.

This function provides for safer data access. The parameter is first checked that it is in the range of the vector. The function throws out_of_range if the check fails.

Definition at line 514 of file stl_vector.h.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_reference std::__debug::vector< _Tp, _Allocator >::back | ( |  | ) | const`[inline]`

Returns a read-only (constant) reference to the data at the last element of the vector.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 233 of file debug/vector.

References __glibcxx_check_nonempty, and std::vector< _Tp, _Allocator >::back().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

reference std::__debug::vector< _Tp, _Allocator >::back | ( |  | ) | `[inline]`

Returns a read/write reference to the data at the last element of the vector.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 226 of file debug/vector.

References __glibcxx_check_nonempty, and std::vector< _Tp, _Allocator >::back().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_iterator std::__debug::vector< _Tp, _Allocator >::begin | ( |  | ) | const`[inline]`

Returns a read-only (constant) iterator that points to the first element in the vector. Iteration is done in ordinary element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 138 of file debug/vector.

References std::vector< _Tp, _Allocator >::begin().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

iterator std::__debug::vector< _Tp, _Allocator >::begin | ( |  | ) | `[inline]`

Returns a read/write iterator that points to the first element in the vector. Iteration is done in ordinary element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 134 of file debug/vector.

References std::vector< _Tp, _Allocator >::begin().

Referenced by std::__debug::vector< _Tp, _Allocator >::erase(), std::__debug::vector< _Tp, _Allocator >::insert(), std::__debug::vector< _Tp, _Allocator >::rend(), and std::__debug::vector< _Tp, _Allocator >::resize().

size_type std::vector< _Tp , _Allocator >::capacity | ( |  | ) | const`[inline, inherited]`

Returns the total number of elements that the vector can hold before needing to allocate more memory.

Definition at line 429 of file stl_vector.h.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

void std::__debug::vector< _Tp, _Allocator >::clear | ( |  | ) | `[inline]`

Erases all the elements. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 346 of file debug/vector.

References __gnu_debug::_Safe_sequence_base::_M_invalidate_all(), and std::vector< _Tp, _Allocator >::clear().

pointer std::vector< _Tp , _Allocator >::data | ( |  | ) | `[inline, inherited]`

Returns a pointer such that [data(), data() + size()) is a valid range. For a non-empty vector, data() == &front().

Definition at line 578 of file stl_vector.h.

bool std::vector< _Tp , _Allocator >::empty | ( |  | ) | const`[inline, inherited]`

Returns true if the vector is empty. (Thus begin() would equal end().)

Definition at line 438 of file stl_vector.h.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_iterator std::__debug::vector< _Tp, _Allocator >::end | ( |  | ) | const`[inline]`

Returns a read-only (constant) iterator that points one past the last element in the vector. Iteration is done in ordinary element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 146 of file debug/vector.

References std::vector< _Tp, _Allocator >::end().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

iterator std::__debug::vector< _Tp, _Allocator >::end | ( |  | ) | `[inline]`

Returns a read/write iterator that points one past the last element in the vector. Iteration is done in ordinary element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 142 of file debug/vector.

References std::vector< _Tp, _Allocator >::end().

Referenced by std::__debug::vector< _Tp, _Allocator >::pop_back(), and std::__debug::vector< _Tp, _Allocator >::rbegin().

iterator std::vector< _Tp , _Allocator >::erase | ( | iterator | __first,
|  | iterator | __last |
| ) |  |  | `[inherited]`

Remove a range of elements.

Parameters:

  | first | Iterator pointing to the first element to be erased.
  | last | Iterator pointing to one past the last element to be erased.

Returns:
  An iterator pointing to the element pointed to by last prior to erasing (or end()).

This function will erase the elements in the range [first,last) and shorten the vector accordingly.

Note This operation could be expensive and if it is frequently used the user should consider using std::list. The user is also cautioned that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

iterator std::vector< _Tp , _Allocator >::erase | ( | iterator | __position | ) | `[inherited]`

Remove element at given position.

Parameters:

  | position | Iterator pointing to element to be erased.

Returns:
  An iterator pointing to the next element (or end()).

This function will erase the element at the given position and thus shorten the vector by one.

Note This operation could be expensive and if it is frequently used the user should consider using std::list. The user is also cautioned that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibilty.

Referenced by std::__debug::vector< _Tp, _Allocator >::erase().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_reference std::__debug::vector< _Tp, _Allocator >::front | ( |  | ) | const`[inline]`

Returns a read-only (constant) reference to the data at the first element of the vector.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 219 of file debug/vector.

References __glibcxx_check_nonempty, and std::vector< _Tp, _Allocator >::front().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

reference std::__debug::vector< _Tp, _Allocator >::front | ( |  | ) | `[inline]`

Returns a read/write reference to the data at the first element of the vector.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 212 of file debug/vector.

References __glibcxx_check_nonempty, and std::vector< _Tp, _Allocator >::front().

void std::vector< _Tp , _Allocator >::insert | ( | iterator | __position,
|  | _InputIterator | __first,
|  | _InputIterator | __last |
| ) |  |  | `[inline, inherited]`

Inserts a range into the vector.

Parameters:

  | position | An iterator into the vector.
  | first | An input iterator.
  | last | An input iterator.

This function will insert copies of the data in the range [first,last) into the vector before the location specified by pos.

Note that this kind of operation could be expensive for a vector and if it is frequently used the user should consider using std::list.

Definition at line 671 of file stl_vector.h.

void std::vector< _Tp , _Allocator >::insert | ( | iterator | __position,
|  | size_type | __n,
|  | const value_type & | __x |
| ) |  |  | `[inline, inherited]`

Inserts a number of copies of given data into the vector.

Parameters:

  | position | An iterator into the vector.
  | n | Number of elements to be inserted.
  | x | Data to be inserted.

This function will insert a specified number of copies of the given data before the location specified by position.

Note that this kind of operation could be expensive for a vector and if it is frequently used the user should consider using std::list.

Definition at line 652 of file stl_vector.h.

iterator std::vector< _Tp , _Allocator >::insert | ( | iterator | __position,
|  | const value_type & | __x |
| ) |  |  | `[inherited]`

Inserts given value into vector before specified iterator.

Parameters:

  | position | An iterator into the vector.
  | x | Data to be inserted.

Returns:
  An iterator that points to the inserted data.

This function will insert a copy of the given value before the specified location. Note that this kind of operation could be expensive for a vector and if it is frequently used the user should consider using std::list.

Referenced by std::__debug::vector< _Tp, _Allocator >::insert().

size_type std::vector< _Tp , _Allocator >::max_size | ( |  | ) | const`[inline, inherited]`

Returns the size() of the largest possible vector.

Definition at line 401 of file stl_vector.h.

const_reference std::vector< _Tp , _Allocator >::operator[] | ( | size_type | __n | ) | const`[inline, inherited]`

Subscript access to the data contained in the vector.

Parameters:

  | n | The index of the element for which data should be accessed.

Returns:
  Read-only (constant) reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

Definition at line 489 of file stl_vector.h.

reference std::vector< _Tp , _Allocator >::operator[] | ( | size_type | __n | ) | `[inline, inherited]`

Subscript access to the data contained in the vector.

Parameters:

  | n | The index of the element for which data should be accessed.

Returns:
  Read/write reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

Definition at line 474 of file stl_vector.h.

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

void std::__debug::vector< _Tp, _Allocator >::pop_back | ( |  | ) | `[inline]`

Removes last element.

This is a typical stack operation. It shrinks the vector by one.

Note that no data is returned, and if the last element's data is needed, it should be retrieved before pop_back() is called.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 255 of file debug/vector.

References __glibcxx_check_nonempty, __gnu_debug::_Safe_iterator< _Iterator, _Sequence >::_M_invalidate(), std::__debug::vector< _Tp, _Allocator >::end(), and std::vector< _Tp, _Allocator >::pop_back().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

void std::__debug::vector< _Tp, _Allocator >::push_back | ( | const _Tp & | __x | ) | `[inline]`

Add data to the end of the vector.

Parameters:

  | x | Data to be added.

This is a typical stack operation. The function creates an element at the end of the vector and assigns the given data to it. Due to the nature of a vector this operation can be done in constant time if the vector has preallocated space available.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 245 of file debug/vector.

References __gnu_debug::_Safe_sequence_base::_M_invalidate_all(), and std::vector< _Tp, _Allocator >::push_back().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_reverse_iterator std::__debug::vector< _Tp, _Allocator >::rbegin | ( |  | ) | const`[inline]`

Returns a read-only (constant) reverse iterator that points to the last element in the vector. Iteration is done in reverse element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 154 of file debug/vector.

References std::__debug::vector< _Tp, _Allocator >::end().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

reverse_iterator std::__debug::vector< _Tp, _Allocator >::rbegin | ( |  | ) | `[inline]`

Returns a read/write reverse iterator that points to the last element in the vector. Iteration is done in reverse element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 150 of file debug/vector.

References std::__debug::vector< _Tp, _Allocator >::end().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

const_reverse_iterator std::__debug::vector< _Tp, _Allocator >::rend | ( |  | ) | const`[inline]`

Returns a read-only (constant) reverse iterator that points to one before the first element in the vector. Iteration is done in reverse element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 162 of file debug/vector.

References std::__debug::vector< _Tp, _Allocator >::begin().

template<typename _Tp, typename _Allocator = std::allocator<_Tp>>

reverse_iterator std::__debug::vector< _Tp, _Allocator >::rend | ( |  | ) | `[inline]`

Returns a read/write reverse iterator that points to one before the first element in the vector. Iteration is done in reverse element order.

Reimplemented from std::vector< _Tp, _Allocator >.

Definition at line 158 of file debug/vector.

References std::__debug::vector< _Tp, _Allocator >::begin().

void std::vector< _Tp , _Allocator >::reserve | ( | size_type | __n | ) | `[inherited]`

Attempt to preallocate enough memory for specified number of elements.

Parameters:

  | n | Number of elements required.

Exceptions:

  | std::length_error | If n exceeds `max_size()`.

This function attempts to reserve enough memory for the vector to hold the specified number of elements. If the number requested is more than max_size(), length_error is thrown.

The advantage of this function is that if optimal code is a necessity and the user can determine the number of elements that will be required, the user can reserve the memory in advance, and thus prevent a possible reallocation of memory and copying of vector data.

Referenced by std::__debug::vector< _Tp, _Allocator >::reserve().

void std::vector< _Tp , _Allocator >::resize | ( | size_type | __new_size,
|  | value_type | __x = `value_type()` |
| ) |  |  | `[inline, inherited]`

Resizes the vector to the specified number of elements.

Parameters:

  | new_size | Number of elements the vector should contain.
  | x | Data with which new elements should be populated.

This function will resize the vector to the specified number of elements. If the number is smaller than the vector's current size the vector is truncated, otherwise the vector is extended and new elements are populated with given data.

Definition at line 416 of file stl_vector.h.

Referenced by std::__debug::vector< _Tp, _Allocator >::resize().

size_type std::vector< _Tp , _Allocator >::size | ( |  | ) | const`[inline, inherited]`

Returns the number of elements in the vector.

Definition at line 396 of file stl_vector.h.

Referenced by std::__debug::vector< _Tp, _Allocator >::resize().

void std::vector< _Tp , _Allocator >::swap | ( | vector< _Tp, _Allocator > & | __x | ) | `[inline, inherited]`

Swaps data with another vector.

Parameters:

  | x | A vector of the same element and allocator types.

This exchanges the elements between two vectors in constant time. (Three pointers, so it should be quite fast.) Note that the global std::swap() function is specialized such that std::swap(v1,v2) will feed to this function.

Definition at line 728 of file stl_vector.h.

References std::_Vector_base< _Tp, _Alloc >::_M_get_Tp_allocator(), std::_Vector_base< _Tp, _Alloc >::_M_impl, std::__alloc_swap< _Alloc, >::_S_do_it(), and std::swap().

## Member Data Documentation

_Safe_iterator_base* __gnu_debug::_Safe_sequence_base::_M_const_iterators `[inherited]`

The list of constant iterators that reference this container.

Definition at line 171 of file safe_base.h.

Referenced by __gnu_debug::_Safe_sequence< _Sequence >::_M_invalidate_if(), __gnu_debug::_Safe_iterator< _Iterator, _Sequence >::_M_invalidate_single(), and __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_iter().

_Safe_iterator_base* __gnu_debug::_Safe_sequence_base::_M_iterators `[inherited]`

The list of mutable iterators that reference this container.

Definition at line 168 of file safe_base.h.

Referenced by __gnu_debug::_Safe_sequence< _Sequence >::_M_invalidate_if(), __gnu_debug::_Safe_iterator< _Iterator, _Sequence >::_M_invalidate_single(), and __gnu_debug::_Safe_sequence< _Sequence >::_M_transfer_iter().

unsigned int __gnu_debug::_Safe_sequence_base::_M_version `[mutable, inherited]`

The container version number. This number may never be 0.

Definition at line 174 of file safe_base.h.

Referenced by __gnu_debug::_Safe_sequence_base::_M_invalidate_all().

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

- debug/vector