bsl::deque

STL-compliant double-ended sequence container using the bslma model.

Synopsis

Declared in <bslstl_deque.h>

template<
    class VALUE_TYPE,
    class ALLOCATOR = allocator<VALUE_TYPE>>
class deque
    : public Deque_Base<VALUE_TYPE>

Description

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

Note that portions of the standard methods are implemented in Deque_Base, 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 insert, push_front, or push_back on a pre-existing object, the object is left in a valid state and its value is unchanged.

Base Classes

NameDescription
Deque_Base<VALUE_TYPE>Allocator-independent layout and accessors shared by deque.

Type Aliases

NameDescription
allocator_type This typedef is an alias to the (template parameter) ALLOCATOR.
const_iterator This typedef is an alias for const_iterator.
const_pointer This typedef is an alias for const_pointer.
const_reference This typedef is an alias for const_reference.
const_reverse_iterator This typedef is an alias to bsl::reverse_iterator<const_iterator>.
difference_type This typedef is an alias for difference_type.
iterator This typedef is an alias to Iterator.
pointer This typedef is an alias to AllocatorTraits::pointer.
reference This typedef is an alias for reference.
reverse_iterator This typedef is an alias to bsl::reverse_iterator<iterator>.
size_type This typedef is an alias for size_type.
value_type This typedef is an alias for value_type.

Member Functions

NameDescription
deque [constructor]Constructors
~deque [destructor]Destroy this object.
operator= Assignment operators
append_range Append the elements of range to the back of this deque.
assign assign overloads
assign_range Assign to this deque the elements of range.
at at overloads
back back overloads
begin begin overloads
capacity Return how many end insertions remain before iterators are invalidated.
cbegin Return an iterator providing non-modifiable access to the first element in this deque, and the past-the-end iterator if this deque is empty.
cend Return the past-the-end (forward) iterator providing non-modifiable access to this deque.
clear Remove all elements from this deque, leaving its capacity unchanged.
crbegin Return a reverse iterator providing non-modifiable access to the last element in this deque, and the past-the-end reverse iterator if this deque is empty.
crend Return the past-the-end reverse iterator providing non-modifiable access to this deque.
emplace Emplace a newly constructed element before position.
emplace_back Emplace a newly constructed element at the back of this deque.
emplace_front Emplace a newly constructed element at the front of this deque.
empty Return true if this deque contains no elements, and false otherwise.
end end overloads
erase erase overloads
front front overloads
get_allocator Return the allocator used by this deque to supply memory.
insert insert overloads
insert_range Insert the elements of range before position.
max_size Return the theoretical maximum size of this deque.
operator[] Subscript operators
pop_back Erase the last element from this deque. The behavior is undefined if this deque is empty.
pop_front Erase the first element from this deque. The behavior is undefined if this deque is empty.
prepend_range Prepend the elements of range to the front of this deque.
push_back push_back overloads
push_front push_front overloads
rbegin rbegin overloads
rend rend overloads
reserve Ensure capacity for numElements pushes without invalidating iterators.
resize resize overloads
shrink_to_fit Minimize unused capacity without moving contained elements.
size Return the number of elements contained by this deque.
swap Exchange the value of this deque with that of other.

Protected Data Members

NameDescription
d_blocksLength Length of the d_blocks_p array.
d_blocks_p Array of pointers to blocks (owned).
d_finish The d_finish data member.
d_start The d_start data member.

Deduction Guides

NameDescription
deque<VALUE> Deduce the template parameter VALUE from the value_type of the iterators supplied to the constructor of deque.
deque<VALUE> Deduce VALUE from an initializer-list constructor argument.
deque<VALUE> Deduce VALUE from iterator pair constructor arguments.
deque<VALUE> Deduce VALUE from size/value constructor arguments.
deque<VALUE, ALLOCATOR> Deduce VALUE and ALLOCATOR from iterator-pair construction.
deque<ranges::range_value_t<t_RANGE>, t_ALLOCATOR> Deduce the template parameters VALUE_TYPE and ALLOCATOR from the parameters supplied to the constructor of deque.

Friends

NameDescription
bsl::Deque_GuardProctor for uncommitted elements constructed at one end of a deque.
bsl::Deque_BlockProctorProctor that deallocates empty blocks at one end of a deque.
bsl::Deque_BlockCreatorHelper that allocates tentative blocks at either end of a deque.

Non-Member Functions

NameDescription
eraseErase every element of deq that compares equal to value.
erase_ifErase every element of deq that satisfies predicate.
operator<=>Perform a lexicographic three-way comparison of lhs and rhs.
operator==Return true if lhs and rhs have the same value.
swapExchange the values of the specified a and b deques.