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:
Synopsis
Declared in <bslstl_vector.h>
template<>
class vector<UserFieldValue>
: public vectorBase<UserFieldValue>
Description
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
BDEXserialization * is exception‐neutral * is alias‐safe * isconstthread‐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.
Base Classes
Name |
Description |
This class describes the basic layout for a vector class, to be included into the |
Type Aliases
Name |
Description |
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
|
This |
Member Functions
Name |
Description |
|
Constructors |
|
Destroy this vector. |
Assignment operators |
|
Adopt all outstanding memory allocations associated with the specified |
|
Append to the end of this object the elements of the specified |
|
|
|
Assign to this object the elements of the specified |
|
|
|
|
|
|
|
Return the capacity of this vector, i.e., the maximum number of elements for which resizing is guaranteed not to trigger a reallocation. |
|
Return an iterator providing non‐modifiable access to the first element in this vector, and the past‐the‐end iterator if this vector is empty. |
|
Return the past‐the‐end (forward) iterator providing non‐modifiable access to this vector. |
|
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. |
|
Return a reverse iterator providing non‐modifiable access to the last element in this vector, and the past‐the‐end reverse iterator if this vector is empty. |
|
Return the past‐the‐end reverse iterator providing non‐modifiable access to this vector. |
|
|
|
Insert at the specified |
|
Append to the end of this vector a newly created |
|
Return |
|
|
|
|
|
|
|
Return (a copy of) the allocator used for memory allocation by this vector. |
|
|
|
Insert at the specified |
|
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 |
|
Subscript operators |
|
Erase the last element from this vector. The behavior is undefined if this vector is empty. |
|
|
|
|
|
|
|
Change the capacity of this vector to the specified |
|
|
|
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 |
|
Return the number of elements in this vector. |
|
Exchange the value of this object with that of the specified |
Protected Data Members
Name |
Description |
Capacity of data storage in number of elements. |
|
Beginning of data storage (owned). |
|
One past the end of data storage. |
Created with MrDocs