|
| | 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.
|
| |
| vector & | operator= (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) |
| |
| | 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 |
| |
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:
- 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.
- 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.
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).
template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
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.
template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class... Args>
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.
template<class VALUE_TYPE , class ALLOCATOR >
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}).
template<class VALUE_TYPE , class ALLOCATOR >
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}).
template<class VALUE_TYPE , class ALLOCATOR = allocator<VALUE_TYPE>>
template<class INPUT_ITER >
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.
template<class VALUE_TYPE , class ALLOCATOR >
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}).
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}).
template<class VALUE_TYPE , class ALLOCATOR >
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}).
template<class VALUE_TYPE , class ALLOCATOR >
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}).
template<class VALUE_TYPE , class ALLOCATOR >
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.