BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsl::vector< VALUE_TYPE, ALLOCATOR > Class Template Reference

#include <bslstl_vector.h>

Inheritance diagram for bsl::vector< VALUE_TYPE, ALLOCATOR >:
bsl::vectorBase< VALUE_TYPE >

Public Types

typedef VALUE_TYPE value_type
 
typedef ALLOCATOR allocator_type
 
typedef VALUE_TYPE & reference
 
typedef const VALUE_TYPE & const_reference
 
typedef AllocatorTraits::size_type size_type
 
typedef AllocatorTraits::difference_type difference_type
 
typedef AllocatorTraits::pointer pointer
 
typedef AllocatorTraits::const_pointer const_pointer
 
typedef VALUE_TYPE * iterator
 
typedef VALUE_TYPE const * const_iterator
 
typedef bsl::reverse_iterator< iteratorreverse_iterator
 
typedef bsl::reverse_iterator< const_iteratorconst_reverse_iterator
 
- Public Types inherited from bsl::vectorBase< VALUE_TYPE >
typedef VALUE_TYPE value_type
 
typedef VALUE_TYPE & reference
 
typedef VALUE_TYPE const & const_reference
 
typedef VALUE_TYPE * iterator
 
typedef VALUE_TYPE const * const_iterator
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef bsl::reverse_iterator< iteratorreverse_iterator
 
typedef bsl::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 vector () BSLS_KEYWORD_NOEXCEPT
 
 vector (const ALLOCATOR &basicAllocator) BSLS_KEYWORD_NOEXCEPT
 
 vector (size_type initialSize, const ALLOCATOR &basicAllocator=ALLOCATOR())
 
 vector (size_type initialSize, const VALUE_TYPE &value, const ALLOCATOR &basicAllocator=ALLOCATOR())
 
template<class INPUT_ITER >
 vector (INPUT_ITER first, INPUT_ITER last, const ALLOCATOR &basicAllocator=ALLOCATOR())
 
 vector (const vector &original)
 
 vector (BloombergLP::bslmf::MovableRef< vector > original) BSLS_KEYWORD_NOEXCEPT
 
 vector (const vector &original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
 
 vector (BloombergLP::bslmf::MovableRef< vector > original, const typename type_identity< ALLOCATOR >::type &basicAllocator)
 
 ~vector ()
 Destroy this vector.
 
vectoroperator= (const vector &rhs)
 
template<class INPUT_ITER >
vector &operator=(BloombergLP::bslmf::MovableRef< vector< VALUE_TYPE, ALLOCATOR > > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void assign (INPUT_ITER first, INPUT_ITER last)
 
void assign (size_type numElements, const VALUE_TYPE &value)
 
void resize (size_type newSize)
 
void resize (size_type newSize, const VALUE_TYPE &value)
 
void reserve (size_type newCapacity)
 
void shrink_to_fit ()
 
template<class... Args>
VALUE_TYPE & emplace_back (Args &&... arguments)
 
void push_back (const VALUE_TYPE &value)
 
void push_back (BloombergLP::bslmf::MovableRef< VALUE_TYPE > value)
 
void pop_back ()
 
template<class... Args>
iterator emplace (const_iterator position, Args &&... arguments)
 
iterator insert (const_iterator position, const VALUE_TYPE &value)
 
iterator insert (const_iterator position, BloombergLP::bslmf::MovableRef< VALUE_TYPE > value)
 
iterator insert (const_iterator position, size_type numElements, const VALUE_TYPE &value)
 
template<class INPUT_ITER >
iterator insert (const_iterator position, INPUT_ITER first, INPUT_ITER last)
 
iterator erase (const_iterator position)
 
iterator erase (const_iterator first, const_iterator last)
 
allocator_type get_allocator () const BSLS_KEYWORD_NOEXCEPT
 
size_type max_size () const BSLS_KEYWORD_NOEXCEPT
 
template<class INPUT_ITER >
BSLS_PLATFORM_AGGRESSIVE_INLINE vector (INPUT_ITER first, INPUT_ITER last, const ALLOCATOR &basicAllocator)
 
template<class INPUT_ITER >
void assign (INPUT_ITER first, INPUT_ITER last)
 
- Public Member Functions inherited from bsl::vectorBase< VALUE_TYPE >
 vectorBase ()
 Create an empty base object with no capacity.
 
void adopt (BloombergLP::bslmf::MovableRef< vectorBase > base)
 
iterator begin () BSLS_KEYWORD_NOEXCEPT
 
iterator end () BSLS_KEYWORD_NOEXCEPT
 
reverse_iterator rbegin () BSLS_KEYWORD_NOEXCEPT
 
reverse_iterator rend () BSLS_KEYWORD_NOEXCEPT
 
reference operator[] (size_type position)
 
reference at (size_type position)
 
reference front ()
 
reference back ()
 
VALUE_TYPE * data () BSLS_KEYWORD_NOEXCEPT
 
const_iterator begin () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator cbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator end () const BSLS_KEYWORD_NOEXCEPT
 
const_iterator cend () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator rbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator crbegin () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator rend () const BSLS_KEYWORD_NOEXCEPT
 
const_reverse_iterator crend () const BSLS_KEYWORD_NOEXCEPT
 
size_type size () const BSLS_KEYWORD_NOEXCEPT
 Return the number of elements in this vector.
 
size_type capacity () const BSLS_KEYWORD_NOEXCEPT
 
bool empty () const BSLS_KEYWORD_NOEXCEPT
 Return true if this vector has size 0, and false otherwise.
 
const_reference operator[] (size_type position) const
 
const_reference at (size_type position) const
 
const_reference front () const
 
const_reference back () const
 
const VALUE_TYPE * data () const BSLS_KEYWORD_NOEXCEPT
 

Public Attributes

void swap(vector &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void clear () BSLS_KEYWORD_NOEXCEPT
 

Additional Inherited Members

- Protected Attributes inherited from bsl::vectorBase< VALUE_TYPE >
VALUE_TYPE * d_dataBegin_p
 
VALUE_TYPE * d_dataEnd_p
 
std::size_t d_capacity
 

Detailed Description

template<class VALUE_TYPE, class ALLOCATOR = allocator<VALUE_TYPE>>
class bsl::vector< VALUE_TYPE, ALLOCATOR >

This class template provides an STL-compliant vector that conforms to the bslma::Allocator model. For the requirements of a vector class, consult the C++11 standard. In particular, this implementation offers the general rules that:

  1. A call to any method that would result in a vector having a size or capacity greater than the value returned by max_size triggers a call to bslstl::StdExceptUtil::throwLengthError.
  2. A call to an at method that attempts to access a position outside of the valid range of a vector triggers a call to bslstl::StdExceptUtil::throwOutOfRange.

Note that portions of the standard methods are implemented in vectorBase, which is parameterized on only VALUE_TYPE in order to generate smaller debug strings.

This class:

  • supports a complete set of value-semantic operations
    • except for BDEX serialization
  • is exception-neutral
  • is alias-safe
  • is const thread-safe For terminology see bsldoc_glossary .

In addition, the following members offer a full guarantee of rollback: if an exception is thrown during the invocation of push_back or insert with a single element at the end of a pre-existing object, the object is left in a valid state and its value is unchanged.

Member Typedef Documentation

◆ allocator_type

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef ALLOCATOR bsl::vector< VALUE_TYPE, ALLOCATOR >::allocator_type

◆ const_iterator

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef VALUE_TYPE const* bsl::vector< VALUE_TYPE, ALLOCATOR >::const_iterator

◆ const_pointer

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef AllocatorTraits::const_pointer bsl::vector< VALUE_TYPE, ALLOCATOR >::const_pointer

◆ const_reference

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef const VALUE_TYPE& bsl::vector< VALUE_TYPE, ALLOCATOR >::const_reference

◆ const_reverse_iterator

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef bsl::reverse_iterator<const_iterator> bsl::vector< VALUE_TYPE, ALLOCATOR >::const_reverse_iterator

◆ difference_type

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef AllocatorTraits::difference_type bsl::vector< VALUE_TYPE, ALLOCATOR >::difference_type

◆ iterator

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef VALUE_TYPE* bsl::vector< VALUE_TYPE, ALLOCATOR >::iterator

◆ pointer

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef AllocatorTraits::pointer bsl::vector< VALUE_TYPE, ALLOCATOR >::pointer

◆ reference

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef VALUE_TYPE& bsl::vector< VALUE_TYPE, ALLOCATOR >::reference

◆ reverse_iterator

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef bsl::reverse_iterator<iterator> bsl::vector< VALUE_TYPE, ALLOCATOR >::reverse_iterator

◆ size_type

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef AllocatorTraits::size_type bsl::vector< VALUE_TYPE, ALLOCATOR >::size_type

◆ value_type

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
typedef VALUE_TYPE bsl::vector< VALUE_TYPE, ALLOCATOR >::value_type

Constructor & Destructor Documentation

◆ vector() [1/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( )
inline

◆ vector() [2/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( const ALLOCATOR &  basicAllocator)
inlineexplicit

Create an empty vector. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ vector() [3/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( size_type  initialSize,
const ALLOCATOR &  basicAllocator = ALLOCATOR() 
)
explicit

Create a vector of the specified initialSize whose every element is a default-constructed object of the (template parameter) type VALUE_TYPE. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. Throw std::length_error if initialSize > max_size(). This method requires that the type VALUE_TYPE be default-insertable into this vector (see {Requirements on VALUE_TYPE}). Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ vector() [4/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( size_type  initialSize,
const VALUE_TYPE &  value,
const ALLOCATOR &  basicAllocator = ALLOCATOR() 
)

Create a vector of the specified initialSize whose every element is a copy of the specified value. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. Throw std::length_error if initialSize > max_size(). This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}). Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ vector() [5/10]

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( INPUT_ITER  first,
INPUT_ITER  last,
const ALLOCATOR &  basicAllocator = ALLOCATOR() 
)

Create a vector, and insert (in order) each VALUE_TYPE object in the range starting at the specified first element, and ending immediately before the specified last element. Optionally specify a basicAllocator used to supply memory. If basicAllocator is not specified, a default-constructed object of the (template parameter) type ALLOCATOR is used. If the type ALLOCATOR is bsl::allocator and basicAllocator is not supplied, the currently installed default allocator is used. Throw std::length_error if the number of elements in [first .. last) exceeds the value returned by the method max_size . The (template parameter) type INPUT_ITER shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this vector, where i is a dereferenceable iterator in the range [first .. last) (see {Requirements on VALUE_TYPE}). The behavior is undefined unless first and last refer to a range of valid values where first is at a position at or before last. Note that a bslma::Allocator * can be supplied for basicAllocator if the type ALLOCATOR is bsl::allocator (the default).

◆ vector() [6/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( const vector< VALUE_TYPE, ALLOCATOR > &  original)

Create a vector having the same value as the specified original object. Use the allocator returned by 'bsl::allocator_traits<ALLOCATOR>:: select_on_container_copy_construction(original.get_allocator())' to allocate memory. This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ vector() [7/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( BloombergLP::bslmf::MovableRef< vector< VALUE_TYPE, ALLOCATOR > >  original)

Create a vector having the same value as the specified original object by moving (in constant time) the contents of original to the new vector. The allocator associated with original is propagated for use in the newly-created vector. original is left in a valid but unspecified state.

◆ vector() [8/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( const vector< VALUE_TYPE, ALLOCATOR > &  original,
const typename type_identity< ALLOCATOR >::type &  basicAllocator 
)

Create a vector having the same value as the specified original object that uses the specified basicAllocator to supply memory. This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}). Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) type ALLOCATOR is bsl::allocator (the default).

◆ vector() [9/10]

template<class VALUE_TYPE , class ALLOCATOR >
bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( BloombergLP::bslmf::MovableRef< vector< VALUE_TYPE, ALLOCATOR > >  original,
const typename type_identity< ALLOCATOR >::type &  basicAllocator 
)

Create a vector having the same value as the specified original object that uses the specified basicAllocator to supply memory. The contents of original are moved (in constant time) to the new vector if basicAllocator == original.get_allocator(), and are move-inserted (in linear time) using basicAllocator otherwise. original is left in a valid but unspecified state. This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector (see {Requirements on VALUE_TYPE}). Note that a bslma::Allocator * can be supplied for basicAllocator if the (template parameter) type ALLOCATOR is bsl::allocator (the default).

◆ ~vector()

template<class VALUE_TYPE , class ALLOCATOR >
BSLS_PLATFORM_AGGRESSIVE_INLINE bsl::vector< VALUE_TYPE, ALLOCATOR >::~vector ( )

◆ vector() [10/10]

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
BSLS_PLATFORM_AGGRESSIVE_INLINE bsl::vector< VALUE_TYPE, ALLOCATOR >::vector ( INPUT_ITER  first,
INPUT_ITER  last,
const ALLOCATOR &  basicAllocator 
)

Member Function Documentation

◆ assign() [1/3]

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
vector &operator=(BloombergLP::bslmf::MovableRef< vector< VALUE_TYPE, ALLOCATOR > > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocatorTraits void bsl::vector< VALUE_TYPE, ALLOCATOR >::assign ( INPUT_ITER  first,
INPUT_ITER  last 
)

Assign to this object the value resulting from first clearing this vector and then inserting (in order) each value_type object in the range starting at the specified first element, and ending immediately before the specified last element. If an exception is thrown, *this is left in a valid but unspecified state. Throw std::length_error if distance(first,last) > max_size(). The (template parameter) type INPUT_ITER shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this vector, where i is a dereferenceable iterator in the range [first .. last) (see {Requirements on VALUE_TYPE}). The behavior is undefined unless first and last refer to a range of valid values where first is at a position at or before last.

◆ assign() [2/3]

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::assign ( INPUT_ITER  first,
INPUT_ITER  last 
)
inline

◆ assign() [3/3]

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::assign ( size_type  numElements,
const VALUE_TYPE &  value 
)
inline

Assign to this object the value resulting from first clearing this vector and then inserting the specified numElements copies of the specified value. If an exception is thrown, *this is left in a valid but unspecified state. Throw std::length_error if numElements > max_size(). This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ emplace()

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class... Args>
iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::emplace ( const_iterator  position,
Args &&...  arguments 
)
inline

Insert at the specified position in this vector a newly created value_type object, constructed by forwarding get_allocator() (if required) and the specified (variable number of) arguments to the corresponding constructor of value_type, and return an iterator referring to the newly created and inserted element. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, or move assignment operator of value_type), *this is unaffected. Throw std::length_error if size() == max_size(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included). This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector and emplace-constructible from arguments (see {Requirements on VALUE_TYPE}).

NOTE: This function has been implemented inline due to an issue with the Sun compiler.

◆ emplace_back()

template<class VALUE_TYPE , class ALLOCATOR >
template<class... Args>
VALUE_TYPE & bsl::vector< VALUE_TYPE, ALLOCATOR >::emplace_back ( Args &&...  arguments)
inline

Append to the end of this vector a newly created value_type object, constructed by forwarding get_allocator() (if required) and the specified (variable number of) arguments to the corresponding constructor of value_type. Return a reference providing modifiable access to the inserted element. If an exception is thrown (other than by the move constructor of a non-copy-insertable value_type), *this is unaffected. Throw std::length_error if size() == max_size(). This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector and emplace-constructible from arguments (see {Requirements on VALUE_TYPE}).

◆ erase() [1/2]

template<class VALUE_TYPE , class ALLOCATOR >
BSLS_PLATFORM_AGGRESSIVE_INLINE vector< VALUE_TYPE, ALLOCATOR >::iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::erase ( const_iterator  first,
const_iterator  last 
)

◆ erase() [2/2]

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::erase ( const_iterator  position)
inline

Remove from this vector the element at the specified position, and return an iterator providing modifiable access to the element immediately following the removed element, or the position returned by the method end if the removed element was the last in the sequence. The behavior is undefined unless position is an iterator in the range [cbegin() .. cend()).

◆ get_allocator()

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::allocator_type bsl::vector< VALUE_TYPE, ALLOCATOR >::get_allocator ( ) const
inline

Return (a copy of) the allocator used for memory allocation by this vector.

◆ insert() [1/4]

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::insert ( const_iterator  position,
BloombergLP::bslmf::MovableRef< VALUE_TYPE >  value 
)

Insert at the specified position in this vector the specified move-insertable value, and return an iterator referring to the newly inserted element. value is left in a valid but unspecified state. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, or move assignment operator of VALUE_TYPE), this is unaffected. Throw std::length_error if size() == max_size(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included). This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ insert() [2/4]

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::insert ( const_iterator  position,
const VALUE_TYPE &  value 
)
inline

Insert at the specified position in this vector a copy of the specified value, and return an iterator referring to the newly inserted element. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, or move assignment operator of VALUE_TYPE), *this is unaffected. Throw std::length_error if size() == max_size(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included). This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ insert() [3/4]

template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::insert ( const_iterator  position,
INPUT_ITER  first,
INPUT_ITER  last 
)
inline

Insert at the specified position in this vector the values in the range starting at the specified first element, and ending immediately before the specified last element. Return an iterator referring to the first newly inserted element. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, or move assignment operator of value_type), *this is unaffected. Throw std::length_error if size() + distance(first, last) > max_size(). The (template parameter) type INPUT_ITER shall meet the requirements of an input iterator defined in the C++11 standard [24.2.3] providing access to values of a type convertible to value_type, and value_type must be emplace-constructible from *i into this vector, where i is a dereferenceable iterator in the range [first .. last) (see {Requirements on VALUE_TYPE}). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included), and first and last refer to a range of valid values where first is at a position at or before last.

NOTE: This function has been implemented inline due to an issue with the Sun compiler.

◆ insert() [4/4]

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::iterator bsl::vector< VALUE_TYPE, ALLOCATOR >::insert ( const_iterator  position,
size_type  numElements,
const VALUE_TYPE &  value 
)

Insert at the specified position in this vector the specified numElements copies of the specified value, and return an iterator referring to the first newly inserted element. If an exception is thrown (other than by the copy constructor, move constructor, assignment operator, or move assignment operator of VALUE_TYPE), *this is unaffected. Throw std::length_error if size() + numElements > max_size(). The behavior is undefined unless position is an iterator in the range [begin() .. end()] (both endpoints included). This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ max_size()

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR >::size_type bsl::vector< VALUE_TYPE, ALLOCATOR >::max_size ( ) const
inline

Return a theoretical upper bound on the largest number of elements that this vector could possibly hold. Note that there is no guarantee that the vector can successfully grow to the returned size, or even close to that size without running out of resources. Also note that requests to create a vector longer than this number of elements are guaranteed to raise a std::length_error exception.

◆ operator=()

template<class VALUE_TYPE , class ALLOCATOR >
vector< VALUE_TYPE, ALLOCATOR > & bsl::vector< VALUE_TYPE, ALLOCATOR >::operator= ( const vector< VALUE_TYPE, ALLOCATOR > &  rhs)

Assign to this object the value of the specified rhs object, propagate to this object the allocator of rhs if the ALLOCATOR type has trait propagate_on_container_copy_assignment, and return a reference providing modifiable access to this object. If an exception is thrown, *this is left in a valid but unspecified state. This method requires that the (template parameter) type VALUE_TYPE be copy-assignable and copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ pop_back()

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::pop_back ( )
inline

Erase the last element from this vector. The behavior is undefined if this vector is empty.

◆ push_back() [1/2]

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::push_back ( BloombergLP::bslmf::MovableRef< VALUE_TYPE >  value)
inline

Append to the end of this vector the specified move-insertable value. value is left in a valid but unspecified state. If an exception is thrown (other than by the move constructor of a non-copy-insertable value_type), *this is unaffected. Throw std::length_error if size() == max_size(). This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ push_back() [2/2]

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::push_back ( const VALUE_TYPE &  value)
inline

Append to the end of this vector a copy of the specified value. If an exception is thrown, *this is unaffected. Throw std::length_error if size() == max_size(). This method requires that the (template parameter) type VALUE_TYPE be copy-constructible (see {Requirements on VALUE_TYPE}).

◆ reserve()

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::reserve ( size_type  newCapacity)

Change the capacity of this vector to the specified newCapacity. If an exception is thrown (other than by the move constructor of a non-copy-insertable value_type), *this is unaffected. Throw bsl::length_error if newCapacity > max_size(). This method requires that the (template parameter) type VALUE_TYPE be move-insertable into this vector (see {Requirements on VALUE_TYPE}). Note that the capacity of this vector after this operation has completed may be greater than newCapacity.

◆ resize() [1/2]

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::resize ( size_type  newSize)

Change the size of this vector to the specified newSize. If newSize < size(), the elements in the range [newSize .. size()) are erased, and this function does not throw. If newSize > size(), the (newly created) elements in the range [size() .. newSize) are default-constructed value_type objects, and if an exception is thrown (other than by the move constructor of a non-copy-insertable value_type), *this is unaffected. Throw std::length_error if newSize > max_size(). This method requires that the (template parameter) type VALUE_TYPE be default-insertable and move-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ resize() [2/2]

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::resize ( size_type  newSize,
const VALUE_TYPE &  value 
)

Change the size of this vector to the specified newSize, inserting newSize - size() copies of the specified value at the end of this vector if newSize > size(). If newSize < size(), the elements in the range [newSize .. size()) are erased, value is ignored, and this method does not throw. If newSize > size() and an exception is thrown, *this is unaffected. Throw std::length_error if newSize > max_size(). This method requires that the (template parameter) type VALUE_TYPE be copy-insertable into this vector (see {Requirements on VALUE_TYPE}).

◆ shrink_to_fit()

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::shrink_to_fit ( )

Reduce the capacity of this vector to its size. If an exception is thrown (other than by the move constructor of a non-copy-insertable value_type), *this is unaffected. Note that this method has no effect if the capacity is equivalent to the size.

Member Data Documentation

◆ clear

template<class VALUE_TYPE , class ALLOCATOR >
void bsl::vector< VALUE_TYPE, ALLOCATOR >::clear
inline

Remove from this vector the sequence of elements starting at the specified first position and ending before the specified last position, and return an iterator providing modifiable access to the element immediately following the last removed element, or the position returned by the method end if the removed elements were last in the sequence. The behavior is undefined unless first is an iterator in the range [cbegin() .. cend()] (both endpoints included) and last is an iterator in the range [first .. cend()] (both endpoints included). Remove all elements from this vector making its size 0. Note that although this vector is empty after this method returns, it preserves the same capacity it had before the method was called.


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