[#bsl-deque-0c]
= xref:bsl.adoc[bsl]::deque
:relfileprefix: ../
:mrdocs:

STL&hyphen;compliant double&hyphen;ended sequence container using the `bslma` model&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;deque&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 deque
    : public xref:bsl/Deque_Base.adoc[Deque&lowbar;Base&lt;VALUE&lowbar;TYPE&gt;]
----

== Description

This class template provides an STL&hyphen;compliant `deque` that conforms to the `bslma&colon;&colon;Allocator` model&period; For the requirements of a deque 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 deque having a size 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 deque triggers a call to `bslstl&colon;&colon;StdExceptUtil&colon;&colon;throwOutOfRange`&period;

Note that portions of the standard methods are implemented in `Deque&lowbar;Base`, 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 &hyphen; 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 `insert`, `push&lowbar;front`, or `push&lowbar;back` on 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/Deque_Base.adoc[Deque&lowbar;Base&lt;VALUE&lowbar;TYPE&gt;]`
| Allocator&hyphen;independent layout and accessors shared by `deque`&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/deque-0c/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias to the (template parameter) `ALLOCATOR`&period;
| xref:bsl/deque-0c/const_iterator.adoc[`const&lowbar;iterator`] 
| This `typedef` is an alias for `const&lowbar;iterator`&period;
| xref:bsl/deque-0c/const_pointer.adoc[`const&lowbar;pointer`] 
| This `typedef` is an alias for `const&lowbar;pointer`&period;
| xref:bsl/deque-0c/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias for `const&lowbar;reference`&period;
| xref:bsl/deque-0c/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/deque-0c/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias for `difference&lowbar;type`&period;
| xref:bsl/deque-0c/iterator-02.adoc[`iterator`] 
| This `typedef` is an alias to `Iterator`&period;
| xref:bsl/deque-0c/pointer.adoc[`pointer`] 
| This `typedef` is an alias to `AllocatorTraits&colon;&colon;pointer`&period;
| xref:bsl/deque-0c/reference.adoc[`reference`] 
| This `typedef` is an alias for `reference`&period;
| xref:bsl/deque-0c/reverse_iterator.adoc[`reverse&lowbar;iterator`] 
| This `typedef` is an alias to `bsl&colon;&colon;reverse&lowbar;iterator&lt;iterator&gt;`&period;
| xref:bsl/deque-0c/size_type.adoc[`size&lowbar;type`] 
| This `typedef` is an alias for `size&lowbar;type`&period;
| xref:bsl/deque-0c/value_type.adoc[`value&lowbar;type`] 
| This `typedef` is an alias for `value&lowbar;type`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/deque-0c/2constructor-0f62.adoc[`deque`]         [.small]#[constructor]#
| Constructors
| xref:bsl/deque-0c/2destructor.adoc[`&#126;deque`] [.small]#[destructor]#
| Destroy this object&period;
| xref:bsl/deque-0c/operator_assign-05f.adoc[`operator&equals;`] 
| Assignment operators
| xref:bsl/deque-0c/append_range.adoc[`append&lowbar;range`] 
| Append the elements of `range` to the back of this deque&period;
| xref:bsl/deque-0c/assign-0e.adoc[`assign`] 
| `assign` overloads
| xref:bsl/deque-0c/assign_range.adoc[`assign&lowbar;range`] 
| Assign to this deque the elements of `range`&period;
| xref:bsl/Deque_Base/at-04.adoc[`at`] 
| `at` overloads
| xref:bsl/Deque_Base/back-06.adoc[`back`] 
| `back` overloads
| xref:bsl/Deque_Base/begin-0fd.adoc[`begin`] 
| `begin` overloads
| xref:bsl/Deque_Base/capacity.adoc[`capacity`] 
| Return how many end insertions remain before iterators are invalidated&period;
| xref:bsl/Deque_Base/cbegin.adoc[`cbegin`] 
| Return an iterator providing non&hyphen;modifiable access to the first element in this deque, and the past&hyphen;the&hyphen;end iterator if this deque is empty&period;
| xref:bsl/Deque_Base/cend.adoc[`cend`] 
| Return the past&hyphen;the&hyphen;end (forward) iterator providing non&hyphen;modifiable access to this deque&period;
| xref:bsl/deque-0c/clear.adoc[`clear`] 
| Remove all elements from this deque, leaving its capacity unchanged&period;
| xref:bsl/Deque_Base/crbegin.adoc[`crbegin`] 
| Return a reverse iterator providing non&hyphen;modifiable access to the last element in this deque, and the past&hyphen;the&hyphen;end reverse iterator if this deque is empty&period;
| xref:bsl/Deque_Base/crend.adoc[`crend`] 
| Return the past&hyphen;the&hyphen;end reverse iterator providing non&hyphen;modifiable access to this deque&period;
| xref:bsl/deque-0c/emplace.adoc[`emplace`] 
| Emplace a newly constructed element before `position`&period;
| xref:bsl/deque-0c/emplace_back.adoc[`emplace&lowbar;back`] 
| Emplace a newly constructed element at the back of this deque&period;
| xref:bsl/deque-0c/emplace_front.adoc[`emplace&lowbar;front`] 
| Emplace a newly constructed element at the front of this deque&period;
| xref:bsl/Deque_Base/empty.adoc[`empty`] 
| Return `true` if this deque contains no elements, and `false` otherwise&period;
| xref:bsl/Deque_Base/end-01.adoc[`end`] 
| `end` overloads
| xref:bsl/deque-0c/erase-0f.adoc[`erase`] 
| `erase` overloads
| xref:bsl/Deque_Base/front-04.adoc[`front`] 
| `front` overloads
| xref:bsl/deque-0c/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used by this deque to supply memory&period;
| xref:bsl/deque-0c/insert-07.adoc[`insert`] 
| `insert` overloads
| xref:bsl/deque-0c/insert_range.adoc[`insert&lowbar;range`] 
| Insert the elements of `range` before `position`&period;
| xref:bsl/deque-0c/max_size.adoc[`max&lowbar;size`] 
| Return the theoretical maximum size of this deque&period;
| xref:bsl/Deque_Base/operator_subs-09.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:bsl/deque-0c/pop_back.adoc[`pop&lowbar;back`] 
| Erase the last element from this deque&period; The behavior is undefined if this deque is empty&period;
| xref:bsl/deque-0c/pop_front.adoc[`pop&lowbar;front`] 
| Erase the first element from this deque&period; The behavior is undefined if this deque is empty&period;
| xref:bsl/deque-0c/prepend_range.adoc[`prepend&lowbar;range`] 
| Prepend the elements of `range` to the front of this deque&period;
| xref:bsl/deque-0c/push_back-0f.adoc[`push&lowbar;back`] 
| `push&lowbar;back` overloads
| xref:bsl/deque-0c/push_front-0e.adoc[`push&lowbar;front`] 
| `push&lowbar;front` overloads
| xref:bsl/Deque_Base/rbegin-09.adoc[`rbegin`] 
| `rbegin` overloads
| xref:bsl/Deque_Base/rend-02.adoc[`rend`] 
| `rend` overloads
| xref:bsl/deque-0c/reserve.adoc[`reserve`] 
| Ensure capacity for `numElements` pushes without invalidating iterators&period;
| xref:bsl/deque-0c/resize-04.adoc[`resize`] 
| `resize` overloads
| xref:bsl/deque-0c/shrink_to_fit.adoc[`shrink&lowbar;to&lowbar;fit`] 
| Minimize unused capacity without moving contained elements&period;
| xref:bsl/Deque_Base/size.adoc[`size`] 
| Return the number of elements contained by this deque&period;
| xref:bsl/deque-0c/swap.adoc[`swap`] 
| Exchange the value of this deque with that of `other`&period;
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:bsl/Deque_Base/d_blocksLength.adoc[`d&lowbar;blocksLength`] 
| Length of the `d&lowbar;blocks&lowbar;p` array&period;
| xref:bsl/Deque_Base/d_blocks_p.adoc[`d&lowbar;blocks&lowbar;p`] 
| Array of pointers to blocks (owned)&period;
| xref:bsl/Deque_Base/d_finish.adoc[`d&lowbar;finish`] 
| The `d&lowbar;finish` data member&period;
| xref:bsl/Deque_Base/d_start.adoc[`d&lowbar;start`] 
| The `d&lowbar;start` data member&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/deque-017.adoc[`deque&lt;VALUE&gt;`] 
| Deduce the template parameter `VALUE` from the `value&lowbar;type` of the iterators supplied to the constructor of `deque`&period;
| xref:bsl/deque-01a.adoc[`deque&lt;VALUE&gt;`] 
| Deduce `VALUE` from an initializer&hyphen;list constructor argument&period;
| xref:bsl/deque-05f.adoc[`deque&lt;VALUE&gt;`] 
| Deduce `VALUE` from iterator pair constructor arguments&period;
| xref:bsl/deque-04.adoc[`deque&lt;VALUE&gt;`] 
| Deduce `VALUE` from size&sol;value constructor arguments&period;
| xref:bsl/deque-00.adoc[`deque&lt;VALUE, ALLOCATOR&gt;`] 
| Deduce `VALUE` and `ALLOCATOR` from iterator&hyphen;pair construction&period;
| xref:bsl/deque-05e.adoc[`deque&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 `deque`&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/Deque_Guard.adoc[bsl::Deque&lowbar;Guard]`
| Proctor for uncommitted elements constructed at one end of a deque&period;
| `xref:bsl/Deque_BlockProctor.adoc[bsl::Deque&lowbar;BlockProctor]`
| Proctor that deallocates empty blocks at one end of a deque&period;
| `xref:bsl/Deque_BlockCreator.adoc[bsl::Deque&lowbar;BlockCreator]`
| Helper that allocates tentative blocks at either end of a deque&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/erase-082.adoc[`erase`]
| Erase every element of `deq` that compares equal to `value`&period;
| xref:bsl/erase_if-0b.adoc[`erase&lowbar;if`]
| Erase every element of `deq` that satisfies `predicate`&period;
| xref:bsl/operator_3way-07cc.adoc[`operator&lt;&equals;&gt;`]
| Perform a lexicographic three&hyphen;way comparison of `lhs` and `rhs`&period;
| xref:bsl/operator_eq-0ce.adoc[`operator&equals;&equals;`]
| Return `true` if `lhs` and `rhs` have the same value&period;
| xref:bsl/swap-096.adoc[`swap`]
| Exchange the values of the specified `a` and `b` deques&period;
|===


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