[#bsl-vector-00d]
= xref:bsl.adoc[bsl]::vector
:relfileprefix: ../
:mrdocs:

STL&hyphen;compliant sequence container conforming to the `bslma` model&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;vector&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class VALUE&lowbar;TYPE,
    class ALLOCATOR = xref:bsl/allocator-0df.adoc[allocator&lt;VALUE&lowbar;TYPE&gt;]&gt;
class vector
    : public xref:bsl/vectorBase-06.adoc[vectorBase&lt;VALUE&lowbar;TYPE&gt;]
----

== Description

This class template provides an STL&hyphen;compliant `vector` that conforms to the `bslma&colon;&colon;Allocator` model&period; For the requirements of a vector class, consult the C&plus;&plus;11 standard&period; In particular, this implementation offers the general rules that&colon;

1&period; A call to any method that would result in a vector having a size or capacity greater than the value returned by `max&lowbar;size` triggers a call to `bslstl&colon;&colon;StdExceptUtil&colon;&colon;throwLengthError`&period; 2&period; 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&colon;&colon;StdExceptUtil&colon;&colon;throwOutOfRange`&period;

Note that portions of the standard methods are implemented in `vectorBase`, which is parameterized on only `VALUE&lowbar;TYPE` in order to generate smaller debug strings&period;

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations

* except for `BDEX` serialization &ast; is _exception&hyphen;neutral_ &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see &lcub;`bsldoc&lowbar;glossary`&rcub;&period;

In addition, the following members offer a full guarantee of rollback&colon; if an exception is thrown during the invocation of `push&lowbar;back` or `insert` with a single element at the end of a pre&hyphen;existing object, the object is left in a valid state and its value is unchanged&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/vectorBase-06.adoc[vectorBase&lt;VALUE&lowbar;TYPE&gt;]`
| Allocator&hyphen;independent storage layout shared by `vector`&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/vector-00d/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/vector-00d/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias to `VALUE&lowbar;TYPE const &ast;`&period;
| xref:bsl/vector-00d/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;const&lowbar;pointer`&period;
| xref:bsl/vector-00d/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to `VALUE&lowbar;TYPE const&amp;`&period;
| xref:bsl/vector-00d/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| This `typedef` is an alias to `bsl&colon;&colon;reverse&lowbar;iterator&lt;const&lowbar;iterator&gt;`&period;
| xref:bsl/vector-00d/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;difference&lowbar;type`&period;
| xref:bsl/vector-00d/iterator.adoc[`iterator`] 
| This `typedef` is an alias to `VALUE&lowbar;TYPE &ast;`&period;
| xref:bsl/vector-00d/pointer.adoc[`pointer`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;pointer`&period;
| xref:bsl/vector-00d/reference.adoc[`reference`] 
| This `typedef` is an alias to `VALUE&lowbar;TYPE&amp;`&period;
| xref:bsl/vector-00d/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| This `typedef` is an alias to `bsl&colon;&colon;reverse&lowbar;iterator&lt;iterator&gt;`&period;
| xref:bsl/vector-00d/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;size&lowbar;type`&period;
| xref:bsl/vector-00d/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `VALUE&lowbar;TYPE`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/vector-00d/2constructor-037.adoc[`vector`]         [.small]#[constructor]#
| Constructors
| xref:bsl/vector-00d/2destructor.adoc[`&#126;vector`] [.small]#[destructor]#
| Destroy this vector&period;
| xref:bsl/vector-00d/operator_assign-0bc.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/vectorBase-06/adopt.adoc[`adopt`] 
| Adopt memory allocations from the specified `base` object&period;
| xref:bsl/vector-00d/append_range.adoc[`append&lowbar;range`] 
| Append elements from a range to this vector&period;
| xref:bsl/vector-00d/assign-00.adoc[`assign`] 
| Assign a new value to this vector&period;
| xref:bsl/vector-00d/assign_range.adoc[`assign&lowbar;range`] 
| Assign elements from a range to this vector&period;
| xref:bsl/vectorBase-06/at-0cb.adoc[`at`] 
| `at` overloads
| xref:bsl/vectorBase-06/back-04.adoc[`back`] 
| `back` overloads
| xref:bsl/vectorBase-06/begin-0ce8.adoc[`begin`] 
| `begin` overloads
| xref:bsl/vectorBase-06/capacity.adoc[`capacity`] 
| Return the capacity of this vector, i&period;e&period;, the maximum number of elements for which resizing is guaranteed not to trigger a reallocation&period;
| xref:bsl/vectorBase-06/cbegin.adoc[`cbegin`] 
| Return a const iterator to the first element&period;
| xref:bsl/vectorBase-06/cend.adoc[`cend`] 
| Return the past&hyphen;the&hyphen;end (forward) iterator providing non&hyphen;modifiable access to this vector&period;
| xref:bsl/vector-00d/clear.adoc[`clear`] 
| Remove all elements from this vector&period;
| xref:bsl/vectorBase-06/crbegin.adoc[`crbegin`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the last element in this vector, and the past&hyphen;the&hyphen;end reverse iterator if this vector is empty&period;
| xref:bsl/vectorBase-06/crend.adoc[`crend`] 
| Return the past&hyphen;the&hyphen;end reverse iterator providing non&hyphen;modifiable access to this vector&period;
| xref:bsl/vectorBase-06/data-0e.adoc[`data`] 
| `data` overloads
| xref:bsl/vector-00d/emplace.adoc[`emplace`] 
| Emplace a newly constructed element at the specified position&period;
| xref:bsl/vector-00d/emplace_back.adoc[`emplace&lowbar;back`] 
| Emplace a newly constructed element at the end&period;
| xref:bsl/vectorBase-06/empty.adoc[`empty`] 
| Return `true` if this vector has size 0, and `false` otherwise&period;
| xref:bsl/vectorBase-06/end-0c.adoc[`end`] 
| `end` overloads
| xref:bsl/vector-00d/erase-00.adoc[`erase`] 
| Erase elements from this vector&period;
| xref:bsl/vectorBase-06/front-05.adoc[`front`] 
| `front` overloads
| xref:bsl/vector-00d/get_allocator.adoc[`get&lowbar;allocator`] 
| Return (a copy of) the allocator used for memory allocation by this vector&period;
| xref:bsl/vector-00d/insert-06b7.adoc[`insert`] 
| `insert` overloads
| xref:bsl/vector-00d/insert_range.adoc[`insert&lowbar;range`] 
| Insert the elements of `range` before `position`&period;
| xref:bsl/vector-00d/max_size.adoc[`max&lowbar;size`] 
| Return a theoretical upper bound on this vector&apos;s size&period;
| xref:bsl/vectorBase-06/operator_subs-02.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:bsl/vector-00d/pop_back.adoc[`pop&lowbar;back`] 
| Erase the last element from this vector&period; The behavior is undefined if this vector is empty&period;
| xref:bsl/vector-00d/push_back-0b.adoc[`push&lowbar;back`] 
| `push&lowbar;back` overloads
| xref:bsl/vectorBase-06/rbegin-09.adoc[`rbegin`] 
| `rbegin` overloads
| xref:bsl/vectorBase-06/rend-01.adoc[`rend`] 
| `rend` overloads
| xref:bsl/vector-00d/reserve.adoc[`reserve`] 
| Increase capacity to at least `newCapacity` if needed&period;
| xref:bsl/vector-00d/resize-03.adoc[`resize`] 
| `resize` overloads
| xref:bsl/vector-00d/shrink_to_fit.adoc[`shrink&lowbar;to&lowbar;fit`] 
| Request that unused capacity be released&period;
| xref:bsl/vectorBase-06/size.adoc[`size`] 
| Return the number of elements in this vector&period;
| xref:bsl/vector-00d/swap.adoc[`swap`] 
| Exchange the value of this object with `other`&period;
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:bsl/vectorBase-06/d_capacity.adoc[`d&lowbar;capacity`] 
| Capacity of data storage in number of elements&period;
| xref:bsl/vectorBase-06/d_dataBegin_p.adoc[`d&lowbar;dataBegin&lowbar;p`] 
| Beginning of data storage (owned)&period;
| xref:bsl/vectorBase-06/d_dataEnd_p.adoc[`d&lowbar;dataEnd&lowbar;p`] 
| One past the end of data storage&period;
|===


== Specializations

[cols="1,4"]
|===
| Name| Description
| xref:bsl/vector-086.adoc[`vector&lt;VALUE&lowbar;TYPE*, ALLOCATOR&gt;`] 
| This partial specialization of `vector` for pointer types to a (template parameter) `VALUE&lowbar;TYPE` type is implemented in terms of `vector&lt;UintPtr&gt;` to reduce&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/vector-07.adoc[`vector&lt;VALUE&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `vector`&period;
| xref:bsl/vector-083.adoc[`vector&lt;VALUE&gt;`] 
| Deduce template arguments for `vector` from constructor arguments&period;
| xref:bsl/vector-04b.adoc[`vector&lt;VALUE&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `vector`&period;
| xref:bsl/vector-009.adoc[`vector&lt;VALUE&gt;`] 
| Deduce the template parameter `VALUE` from the corresponding parameter supplied to the constructor of `vector`&period;
| xref:bsl/vector-042.adoc[`vector&lt;VALUE, ALLOCATOR&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `vector`&period;
| xref:bsl/vector-0a.adoc[`vector&lt;ranges::range&lowbar;value&lowbar;t&lt;t&lowbar;RANGE&gt;, t&lowbar;ALLOCATOR&gt;`] 
| Deduce the template parameters `VALUE&lowbar;TYPE` and `ALLOCATOR` from the parameters supplied to the constructor of `vector`&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/bdlat_valueTypeAssign.adoc[`bdlat&lowbar;valueTypeAssign`]
| Assign the specified `rhs` vector to the specified `lhs` vector&period;
| xref:bsl/erase-0c.adoc[`erase`]
| Erase all the elements in the specified vector `vec` that compare equal to the specified `value`&period; Return the number of elements erased&period;
| xref:bsl/erase_if-03a.adoc[`erase&lowbar;if`]
| Erase all the elements in the specified vector `vec` that satisfy the specified predicate `predicate`&period; Return the number of elements erased&period;
| xref:bsl/operator_3way-01c.adoc[`operator&lt;&equals;&gt;`]
| Perform a three&hyphen;way comparison of the operands&period;
| xref:bsl/operator_eq-013.adoc[`operator&equals;&equals;`]
| Return whether the operands have the same value&period;
| xref:bsl/swap-0a1.adoc[`swap`]
| Exchange the contents of two vectors&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arrayAccessElement.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arrayAccessElement`]
| Invoke the specified `accessor` on the element at the specified `index` of the specified `array`&period; Return the value from the invocation of `accessor`&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arrayManipulateElement.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arrayManipulateElement`]
| Apply the specified `manipulator` to the element at the specified `index` in the specified `array`&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arrayReserve-01.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arrayReserve`]
| Reserve capacity for the specified `array` to hold at least the specified `numElements` elements&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arrayResize.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arrayResize`]
| Resize the specified `array` to contain the specified `newSize` elements&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arraySize.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arraySize`]
| Return the number of elements in the specified `array`&period;
| xref:BloombergLP/bdlat_ArrayFunctions/bdlat_arraySupportsReserve-06.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayFunctions&colon;&colon;bdlat&lowbar;arraySupportsReserve`]
| Return `true` if the specified `array` supports the `reserve` method&period;
| xref:BloombergLP/bdlat_ArrayIterators/backInserter-0c.adoc[`&colon;&colon;BloombergLP&colon;&colon;bdlat&lowbar;ArrayIterators&colon;&colon;backInserter`]
| Specialization of `backInserter` for `bsl&colon;&colon;vector`&period; Return `bsl&colon;&colon;back&lowbar;insert&lowbar;iterator` instead of `BackInsertIterator`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
