11#ifndef INCLUDED_BSLSTL_DEQUE_CPP03
12#define INCLUDED_BSLSTL_DEQUE_CPP03
63#ifdef COMPILING_BSLSTL_DEQUE_H
67template <
class VALUE_TYPE,
class ALLOCATOR>
68class Deque_BlockCreator;
69template <
class VALUE_TYPE,
class ALLOCATOR>
70class Deque_BlockProctor;
71template <
class VALUE_TYPE,
class ALLOCATOR>
72class Deque_ClearGuard;
73template <
class VALUE_TYPE,
class ALLOCATOR>
83template <
class VALUE_TYPE>
84struct Deque_BlockLengthCalcUtil {
112 static void move(
void *dst,
void *src);
116 static void swap(
void *a,
void *b);
132template <
class VALUE_TYPE>
140 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
142 typedef typename Imp::Block Block;
143 typedef typename Imp::BlockPtr BlockPtr;
144 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
145 BLOCK_LENGTH> IteratorImp;
146 typedef BloombergLP::
147 bslstl::RandomAccessIterator<VALUE_TYPE, IteratorImp>
150 typedef BloombergLP::
151 bslstl::RandomAccessIterator<const VALUE_TYPE, IteratorImp>
324template <class VALUE_TYPE, class ALLOCATOR = allocator<VALUE_TYPE> >
325class deque : public Deque_Base<VALUE_TYPE>
326 , private BloombergLP::
bslalg::ContainerBase<ALLOCATOR> {
333 typedef Deque_Base<VALUE_TYPE> Base;
335 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
337 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
339 typedef typename Imp::Block Block;
340 typedef typename Imp::BlockPtr BlockPtr;
342 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
343 BLOCK_LENGTH> IteratorImp;
345 typedef BloombergLP::
346 bslstl::RandomAccessIterator<VALUE_TYPE,
347 IteratorImp> Iterator;
349 typedef BloombergLP::
350 bslstl::RandomAccessIterator<
const VALUE_TYPE,
351 IteratorImp> ConstIterator;
353 typedef Deque_BlockCreator<VALUE_TYPE, ALLOCATOR> BlockCreator;
354 typedef Deque_BlockProctor<VALUE_TYPE, ALLOCATOR> BlockProctor;
355 typedef Deque_ClearGuard<VALUE_TYPE, ALLOCATOR> ClearGuard;
356 typedef Deque_Guard<VALUE_TYPE, ALLOCATOR> Guard;
358 typedef BloombergLP::bslalg::DequePrimitives<VALUE_TYPE,
359 BLOCK_LENGTH> DequePrimitives;
361 typedef BloombergLP::bslma::AllocatorUtil AllocatorUtil;
366 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
370 enum RawInit { k_RAW_INIT = 0 };
382 typedef ALLOCATOR allocator_type;
383 typedef typename AllocatorTraits::pointer pointer;
384 typedef typename AllocatorTraits::const_pointer const_pointer;
396 typename Base::const_reference>::value));
412 deque(RawInit,
const allocator_type& allocator);
418 Block *allocateBlock();
423 BlockPtr *allocateBlockPtrs(std::size_t n);
428 void deallocateBlock(Block *p);
434 void deallocateBlockPtrs(BlockPtr *p, std::size_t n);
441 template <
class INPUT_ITERATOR>
442 size_type privateAppend(INPUT_ITERATOR first,
444 std::input_iterator_tag);
445 template <
class INPUT_ITERATOR>
446 size_type privateAppend(INPUT_ITERATOR first,
448 std::random_access_iterator_tag);
452 void privateAppendDefaultInsertable(
size_type numElements);
456 void privateAppendRaw(
size_type numElements,
const VALUE_TYPE& value);
473 template <
class INTEGER_TYPE>
474 void privateInsertDispatch(
476 INTEGER_TYPE numElements,
478 BloombergLP::bslmf::MatchArithmeticType,
479 BloombergLP::bslmf::Nil);
488 template <
class INPUT_ITERATOR>
490 INPUT_ITERATOR first,
492 BloombergLP::bslmf::MatchAnyType,
493 BloombergLP::bslmf::MatchAnyType);
496 template <
class INPUT_ITERATOR>
498 INPUT_ITERATOR first,
500 std::input_iterator_tag);
504 template <
class INPUT_ITERATOR>
506 INPUT_ITERATOR first,
508 std::random_access_iterator_tag);
513 void privateJoinPrepend(deque *other);
518 void privateJoinAppend(deque *other);
525 template <
class INPUT_ITERATOR>
526 size_type privatePrepend(INPUT_ITERATOR first,
528 std::input_iterator_tag);
529 template <
class INPUT_ITERATOR>
530 size_type privatePrepend(INPUT_ITERATOR first,
532 std::bidirectional_iterator_tag);
533 template <
class INPUT_ITERATOR>
534 size_type privatePrepend(INPUT_ITERATOR first,
536 std::random_access_iterator_tag);
540 void privatePrependRaw(
size_type numElements,
const VALUE_TYPE& value);
548 void privateSplit(deque *other, IteratorImp pos);
551 template <
class VALUE_TYPE2,
class ALLOCATOR2>
552 friend class Deque_BlockCreator;
554 template <
class VALUE_TYPE2,
class ALLOCATOR2>
555 friend class Deque_BlockProctor;
557 template <
class VALUE_TYPE2,
class ALLOCATOR2>
558 friend class Deque_Guard;
574 explicit deque(
const ALLOCATOR& basicAllocator);
590 const ALLOCATOR& basicAllocator = ALLOCATOR());
606 const VALUE_TYPE& value,
607 const ALLOCATOR& basicAllocator = ALLOCATOR());
630 template <
class INPUT_ITERATOR>
631 deque(INPUT_ITERATOR first,
633 const ALLOCATOR& basicAllocator = ALLOCATOR());
644 deque(
const deque& original);
653 deque(
const deque& original,
661 deque(BloombergLP::bslmf::MovableRef<deque> original);
674 deque(BloombergLP::bslmf::MovableRef<deque> original,
677#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
689 deque(std::initializer_list<value_type> values,
690 const ALLOCATOR& basicAllocator = ALLOCATOR());
706 deque& operator=(
const deque& rhs);
708 deque& operator=(BloombergLP::bslmf::MovableRef<deque> rhs)
710 AllocatorTraits::is_always_equal::value);
726#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
733 deque& operator=(std::initializer_list<value_type> values);
748 template <
class INPUT_ITERATOR>
749 void assign(INPUT_ITERATOR first, INPUT_ITERATOR last);
758#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
764 void assign(std::initializer_list<value_type> values);
797 void shrink_to_fit();
806 void push_front(
const VALUE_TYPE& value);
815 void push_front(BloombergLP::bslmf::MovableRef<value_type> value);
822 void push_back(
const VALUE_TYPE& value);
831 void push_back(BloombergLP::bslmf::MovableRef<value_type> value);
833#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
836#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
837#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
839#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_A
840#define BSLSTL_DEQUE_VARIADIC_LIMIT_A BSLSTL_DEQUE_VARIADIC_LIMIT
842#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
847#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
848 template <
class Args_01>
853#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
854 template <
class Args_01,
861#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
862 template <
class Args_01,
871#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
872 template <
class Args_01,
883#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
884 template <
class Args_01,
897#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
898 template <
class Args_01,
913#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
914 template <
class Args_01,
931#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
932 template <
class Args_01,
951#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
952 template <
class Args_01,
973#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
974 template <
class Args_01,
998#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
1003#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
1004 template <
class Args_01>
1009#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
1010 template <
class Args_01,
1017#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
1018 template <
class Args_01,
1027#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
1028 template <
class Args_01,
1039#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
1040 template <
class Args_01,
1053#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
1054 template <
class Args_01,
1069#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
1070 template <
class Args_01,
1087#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
1088 template <
class Args_01,
1107#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
1108 template <
class Args_01,
1129#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
1130 template <
class Args_01,
1156 template <
class... Args>
1160 template <
class... Args>
1166#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1169#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
1170#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
1172#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_B
1173#define BSLSTL_DEQUE_VARIADIC_LIMIT_B BSLSTL_DEQUE_VARIADIC_LIMIT
1175#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 0
1179#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 1
1180 template <
class Args_01>
1185#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 2
1186 template <
class Args_01,
1193#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 3
1194 template <
class Args_01,
1203#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 4
1204 template <
class Args_01,
1215#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 5
1216 template <
class Args_01,
1229#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 6
1230 template <
class Args_01,
1245#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 7
1246 template <
class Args_01,
1263#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 8
1264 template <
class Args_01,
1283#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 9
1284 template <
class Args_01,
1305#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 10
1306 template <
class Args_01,
1332 template <
class... Args>
1370 BloombergLP::bslmf::MovableRef<value_type> value);
1385 const VALUE_TYPE& value);
1404 template <
class INPUT_ITERATOR>
1406 INPUT_ITERATOR first,
1407 INPUT_ITERATOR last);
1409#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1422 std::initializer_list<value_type> values);
1444 void swap(deque<VALUE_TYPE, ALLOCATOR>& other)
1446 AllocatorTraits::is_always_equal::value);
1482#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1494 class = bsl::enable_if_t<
1495 bsl::is_convertible_v<
1498 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1500deque(SIZE_TYPE, VALUE, ALLOC *) -> deque<VALUE>;
1505 class INPUT_ITERATOR,
1507 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
1509deque(INPUT_ITERATOR, INPUT_ITERATOR) -> deque<VALUE>;
1516 class INPUT_ITERATOR,
1519 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1520 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>>
1521deque(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR) -> deque<VALUE, ALLOCATOR>;
1528 class INPUT_ITERATOR,
1531 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1533 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1535deque(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1546 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1548deque(std::initializer_list<VALUE>, ALLOC *)
1562template <
class VALUE_TYPE,
class ALLOCATOR>
1563bool operator==(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1564 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1566#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1567template <
class VALUE_TYPE,
class ALLOCATOR>
1568bool operator!=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1569 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1580#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1585template <
class VALUE_TYPE,
class ALLOCATOR>
1586BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
1587 const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1588 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1592template <
class VALUE_TYPE,
class ALLOCATOR>
1593bool operator<(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1594 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1607template <
class VALUE_TYPE,
class ALLOCATOR>
1608bool operator>(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1609 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1618template <
class VALUE_TYPE,
class ALLOCATOR>
1619bool operator<=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1620 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1629template <
class VALUE_TYPE,
class ALLOCATOR>
1630bool operator>=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1631 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1646template <
class VALUE_TYPE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
1647typename deque<VALUE_TYPE, ALLOCATOR>::size_type
1648erase(deque<VALUE_TYPE, ALLOCATOR>& deq,
const BDE_OTHER_TYPE& value);
1652template <
class VALUE_TYPE,
class ALLOCATOR,
class PREDICATE>
1653typename deque<VALUE_TYPE, ALLOCATOR>::size_type
1654erase_if(deque<VALUE_TYPE, ALLOCATOR>& deq, PREDICATE predicate);
1656template <
class VALUE_TYPE,
class ALLOCATOR>
1657void swap(deque<VALUE_TYPE, ALLOCATOR>& a, deque<VALUE_TYPE, ALLOCATOR>& b)
1685template <
class VALUE_TYPE,
class ALLOCATOR>
1686class Deque_BlockCreator {
1690 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
1693 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
1695 typedef typename Imp::Block Block;
1696 typedef typename Imp::BlockPtr BlockPtr;
1697 typedef std::size_t size_type;
1700 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
1701 BlockPtr *d_boundary_p;
1705 Deque_BlockCreator(
const Deque_BlockCreator&);
1706 Deque_BlockCreator& operator=(
const Deque_BlockCreator&);
1713 Deque_BlockCreator(deque<VALUE_TYPE, ALLOCATOR> *deque);
1717 ~Deque_BlockCreator();
1724 void insertAtFront(size_type n);
1729 void insertAtBack(size_type n);
1739 BlockPtr *reserveBlockSlots(size_type numNewBlocks,
bool atFront);
1757template <
class VALUE_TYPE,
class ALLOCATOR>
1758class Deque_BlockProctor {
1762 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
1765 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
1768 typedef typename Imp::BlockPtr BlockPtr;
1771 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
1773 BlockPtr *d_boundary_p;
1783 Deque_BlockProctor(
const Deque_BlockProctor&);
1784 Deque_BlockProctor& operator=(
const Deque_BlockProctor&);
1794 Deque_BlockProctor(deque<VALUE_TYPE, ALLOCATOR> *deque,
bool atFront);
1800 ~Deque_BlockProctor();
1818template <
class VALUE_TYPE,
class ALLOCATOR>
1819class Deque_ClearGuard {
1822 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
1825 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
1829 Deque_ClearGuard(
const Deque_ClearGuard&);
1830 Deque_ClearGuard& operator=(
const Deque_ClearGuard&);
1837 Deque_ClearGuard(deque<VALUE_TYPE, ALLOCATOR> *deque);
1841 ~Deque_ClearGuard();
1866template <
class VALUE_TYPE,
class ALLOCATOR>
1871 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
1874 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
1875 BLOCK_LENGTH> IteratorImp;
1876 typedef BloombergLP::bslalg::DequePrimitives<VALUE_TYPE,
1877 BLOCK_LENGTH> DequePrimitives;
1880 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
1881 std::size_t d_count;
1886 Deque_Guard(
const Deque_Guard&);
1887 Deque_Guard& operator=(
const Deque_Guard&);
1895 Deque_Guard(deque<VALUE_TYPE, ALLOCATOR> *deque,
bool isTail);
1940template <class VALUE_TYPE>
1942typename Deque_Base<VALUE_TYPE>::iterator
1948template <
class VALUE_TYPE>
1950typename Deque_Base<VALUE_TYPE>::iterator
1956template <
class VALUE_TYPE>
1958typename Deque_Base<VALUE_TYPE>::reverse_iterator
1961 return reverse_iterator(
end());
1964template <
class VALUE_TYPE>
1966typename Deque_Base<VALUE_TYPE>::reverse_iterator
1969 return reverse_iterator(
begin());
1972template <
class VALUE_TYPE>
1974typename Deque_Base<VALUE_TYPE>::reference
1975Deque_Base<VALUE_TYPE>::operator[](size_type position)
1979 return *(
begin() + position);
1982template <
class VALUE_TYPE>
1983typename Deque_Base<VALUE_TYPE>::reference
1984Deque_Base<VALUE_TYPE>::at(size_type position)
1989 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
1990 "deque<...>::at(n): invalid position");
1992 return *(
begin() + position);
1995template <
class VALUE_TYPE>
1997typename Deque_Base<VALUE_TYPE>::reference
1998Deque_Base<VALUE_TYPE>::front()
2005template <
class VALUE_TYPE>
2007typename Deque_Base<VALUE_TYPE>::reference
2008Deque_Base<VALUE_TYPE>::back()
2012 IteratorImp backIterator = d_finish;
2014 return *backIterator;
2018template <
class VALUE_TYPE>
2020typename Deque_Base<VALUE_TYPE>::const_iterator
2026template <
class VALUE_TYPE>
2028typename Deque_Base<VALUE_TYPE>::const_iterator
2034template <
class VALUE_TYPE>
2036typename Deque_Base<VALUE_TYPE>::const_iterator
2042template <
class VALUE_TYPE>
2044typename Deque_Base<VALUE_TYPE>::const_iterator
2050template <
class VALUE_TYPE>
2052typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2055 return const_reverse_iterator(
end());
2058template <
class VALUE_TYPE>
2060typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2063 return const_reverse_iterator(
end());
2066template <
class VALUE_TYPE>
2068typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2071 return const_reverse_iterator(
begin());
2074template <
class VALUE_TYPE>
2076typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2079 return const_reverse_iterator(
begin());
2082template <
class VALUE_TYPE>
2084typename Deque_Base<VALUE_TYPE>::size_type
2087 return d_finish - d_start;
2090template <
class VALUE_TYPE>
2091typename Deque_Base<VALUE_TYPE>::size_type
2102 if (d_start.blockPtr() > d_blocks_p) {
2105 if (d_finish.blockPtr() < d_blocks_p + d_blocksLength - 1) {
2106 d_blocks_p[d_blocksLength - 1] = 0;
2109 const IteratorImp first(d_blocks_p);
2114 IteratorImp last(d_blocks_p + d_blocksLength - 1);
2115 last += BLOCK_LENGTH - 1;
2120 const size_type frontCapacity = d_finish - first;
2121 const size_type backCapacity = last - d_start;
2126 return frontCapacity < backCapacity ? frontCapacity : backCapacity;
2129template <
class VALUE_TYPE>
2133 return d_start == d_finish;
2136template <
class VALUE_TYPE>
2138typename Deque_Base<VALUE_TYPE>::const_reference
2139Deque_Base<VALUE_TYPE>::operator[](size_type position)
const
2143 return *(
begin() + position);
2146template <
class VALUE_TYPE>
2147typename Deque_Base<VALUE_TYPE>::const_reference
2148Deque_Base<VALUE_TYPE>::at(size_type position)
const
2153 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
2154 "const deque<...>::at(n): invalid position");
2156 return *(
begin() + position);
2159template <
class VALUE_TYPE>
2161typename Deque_Base<VALUE_TYPE>::const_reference
2162Deque_Base<VALUE_TYPE>::front()
const
2169template <
class VALUE_TYPE>
2171typename Deque_Base<VALUE_TYPE>::const_reference
2172Deque_Base<VALUE_TYPE>::back()
const
2176 IteratorImp backIterator = d_finish;
2178 return *backIterator;
2186template <
class VALUE_TYPE,
class ALLOCATOR>
2188deque<VALUE_TYPE, ALLOCATOR>::deque(RawInit,
const ALLOCATOR& allocator)
2189: Deque_Base<VALUE_TYPE>()
2190, ContainerBase(allocator)
2192 this->d_blocks_p = 0;
2196template <
class VALUE_TYPE,
class ALLOCATOR>
2198typename deque<VALUE_TYPE, ALLOCATOR>::Block *
2199deque<VALUE_TYPE, ALLOCATOR>::allocateBlock()
2201 return AllocatorUtil::allocateObject<Block>(this->allocatorRef());
2204template <
class VALUE_TYPE,
class ALLOCATOR>
2206typename deque<VALUE_TYPE, ALLOCATOR>::BlockPtr *
2207deque<VALUE_TYPE, ALLOCATOR>::allocateBlockPtrs(std::size_t n)
2209 return AllocatorUtil::allocateObject<BlockPtr>(this->allocatorRef(), n);
2212template <
class VALUE_TYPE,
class ALLOCATOR>
2214void deque<VALUE_TYPE, ALLOCATOR>::deallocateBlock(Block *p)
2216 AllocatorUtil::deallocateObject(this->allocatorRef(), p);
2219template <
class VALUE_TYPE,
class ALLOCATOR>
2222deque<VALUE_TYPE, ALLOCATOR>::deallocateBlockPtrs(BlockPtr *p, std::size_t n)
2224 AllocatorUtil::deallocateObject(this->allocatorRef(), p, n);
2227template <
class VALUE_TYPE,
class ALLOCATOR>
2228template <
class INPUT_ITERATOR>
2229typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2230deque<VALUE_TYPE, ALLOCATOR>::privateAppend(
2231 INPUT_ITERATOR first,
2232 INPUT_ITERATOR last,
2233 std::random_access_iterator_tag)
2235 BlockCreator newBlocks(
this);
2236 Guard guard(
this,
true);
2238 const size_type numElements = bsl::distance(first, last);
2240 numElements > max_size() - this->
size())) {
2243 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2244 "deque<...>::insert(pos,n,v): deque too big");
2247 for ( ; first != last; ++first) {
2248 IteratorImp insertPoint = guard.end();
2256 if (1 == insertPoint.remainingInBlock()) {
2257 newBlocks.insertAtBack(1);
2258 insertPoint = guard.end();
2261 AllocatorTraits::construct(this->allocatorRef(),
2267 this->d_finish += guard.count();
2273template <
class VALUE_TYPE,
class ALLOCATOR>
2274template <
class INPUT_ITERATOR>
2275typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2276deque<VALUE_TYPE, ALLOCATOR>::privateAppend(INPUT_ITERATOR first,
2277 INPUT_ITERATOR last,
2278 std::input_iterator_tag)
2280 BlockCreator newBlocks(
this);
2281 Guard guard(
this,
true);
2283 size_type numElements = 0;
2284 size_type maxNumElements = max_size() - this->
size();
2285 for ( ; first != last; ++first) {
2288 numElements > maxNumElements)) {
2291 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2292 "deque<...>::insert(pos,n,v): deque too big");
2294 IteratorImp insertPoint = guard.end();
2302 if (1 == insertPoint.remainingInBlock()) {
2303 newBlocks.insertAtBack(1);
2304 insertPoint = guard.end();
2308 AllocatorTraits::construct(this->allocatorRef(),
2314 this->d_finish += guard.count();
2320template <
class VALUE_TYPE,
class ALLOCATOR>
2321void deque<VALUE_TYPE, ALLOCATOR>::privateAppendDefaultInsertable(
2322 size_type numElements)
2327 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements) /
2329 BlockCreator newBlocks(
this);
2330 newBlocks.insertAtBack(numNewBlocks);
2331 DequePrimitives::valueInititalizeN(&this->d_finish,
2334 this->allocatorRef());
2337template <
class VALUE_TYPE,
class ALLOCATOR>
2338void deque<VALUE_TYPE, ALLOCATOR>::privateAppendRaw(
2339 size_type numElements,
2340 const VALUE_TYPE& value)
2345 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements) /
2347 BlockCreator newBlocks(
this);
2348 newBlocks.insertAtBack(numNewBlocks);
2350 DequePrimitives::uninitializedFillNBack(&this->d_finish,
2354 this->allocatorRef());
2357template <
class VALUE_TYPE,
class ALLOCATOR>
2358void deque<VALUE_TYPE, ALLOCATOR>::privateInit(size_type numElements)
2360 size_type blocksLength = numElements / BLOCK_LENGTH + 1 +
2361 2 * Imp::BLOCK_ARRAY_PADDING;
2365 this->d_blocks_p = this->allocateBlockPtrs(blocksLength);
2367 this->d_blocksLength = blocksLength;
2372 BlockPtr *firstBlockPtr = &this->d_blocks_p[Imp::BLOCK_ARRAY_PADDING];
2373 *firstBlockPtr = this->allocateBlock();
2383 const int offset =
static_cast<int>(
2384 (BLOCK_LENGTH - 1 - numElements % BLOCK_LENGTH) / 2);
2388 this->d_start = this->d_finish = IteratorImp(
2390 (*firstBlockPtr)->d_data + offset);
2393template <
class VALUE_TYPE,
class ALLOCATOR>
2394template <
class INTEGRAL_TYPE>
2396void deque<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
2397 const_iterator position,
2398 INTEGRAL_TYPE numElements,
2399 INTEGRAL_TYPE value,
2400 BloombergLP::bslmf::MatchArithmeticType,
2401 BloombergLP::bslmf::Nil)
2404 static_cast<size_type
>(numElements),
2405 static_cast<VALUE_TYPE
>(value));
2408template <
class VALUE_TYPE,
class ALLOCATOR>
2409template <
class INPUT_ITERATOR>
2410void deque<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
2411 const_iterator position,
2412 INPUT_ITERATOR first,
2413 INPUT_ITERATOR last,
2414 BloombergLP::bslmf::MatchAnyType,
2415 BloombergLP::bslmf::MatchAnyType)
2417 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
2419 if (first == last) {
2423 if (position == this->
cbegin()) {
2424 privatePrepend(first, last, Tag());
2428 if (position == this->
cend()) {
2429 privateAppend(first, last, Tag());
2433 privateInsert(position, first, last, Tag());
2436template <
class VALUE_TYPE,
class ALLOCATOR>
2437template <
class INPUT_ITERATOR>
2438void deque<VALUE_TYPE, ALLOCATOR>::privateInsert(
2439 const_iterator position,
2440 INPUT_ITERATOR first,
2441 INPUT_ITERATOR last,
2442 std::input_iterator_tag tag)
2446 iterator pos(position.imp());
2447 const size_type currentSize = this->
size();
2448 const size_type posIdx = pos - this->
begin();
2450 deque temp(k_RAW_INIT, this->get_allocator());
2451 privateSplit(&temp, position.imp());
2453 if (posIdx <= currentSize / 2) {
2455 static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2456 privatePrepend(first, last, tag);
2457 privateJoinPrepend(&temp);
2460 privateAppend(first, last, tag);
2461 privateJoinAppend(&temp);
2465template <
class VALUE_TYPE,
class ALLOCATOR>
2466void deque<VALUE_TYPE, ALLOCATOR>::privateSplit(
2467 deque<VALUE_TYPE, ALLOCATOR> *other,
2502 if (pos.blockPtr() == this->d_finish.blockPtr()) {
2506 difference_type numAfter = this->d_finish.valuePtr() - pos.valuePtr();
2507 other->privateInit(numAfter);
2508 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2509 other->d_start.valuePtr(),
2511 this->d_finish.valuePtr(),
2512 this->allocatorRef());
2513 other->d_finish += numAfter;
2514 this->d_finish = pos;
2518 if (pos.blockPtr() == this->d_start.blockPtr()) {
2522 difference_type numBefore = pos.valuePtr() - this->d_start.valuePtr();
2523 other->privateInit(numBefore);
2524 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2525 other->d_start.valuePtr(),
2526 this->d_start.valuePtr(),
2528 this->allocatorRef());
2529 other->d_finish += numBefore;
2530 this->d_start = pos;
2532 static_cast<Base *
>(
this),
static_cast<Base *
>(other));
2538 difference_type numMoveBlocks = this->d_finish.blockPtr() - pos.blockPtr();
2540 size_type otherBlocksLength = numMoveBlocks + 1 +
2541 2 * Imp::BLOCK_ARRAY_PADDING;
2543 other->d_blocks_p = this->allocateBlockPtrs(otherBlocksLength);
2544 other->d_blocksLength = otherBlocksLength;
2548 Block *newBlock = this->allocateBlock();
2553 std::memcpy(other->d_blocks_p + 1 + Imp::BLOCK_ARRAY_PADDING,
2555 sizeof(BlockPtr) * numMoveBlocks);
2557 other->d_start = IteratorImp(&other->d_blocks_p[
2558 1 + Imp::BLOCK_ARRAY_PADDING]);
2559 other->d_finish = IteratorImp(other->d_start.blockPtr() +
2561 this->d_finish.valuePtr());
2563 BlockPtr *newBlockPtr = pos.blockPtr() + 1;
2564 *newBlockPtr = newBlock;
2565 this->d_finish = IteratorImp(newBlockPtr);
2591 size_type splitOffset = pos.offsetInBlock();
2592 if (splitOffset >= pos.remainingInBlock()) {
2595 value_type *splitValuePtr = newBlock->d_data + splitOffset;
2596 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2600 this->allocatorRef());
2606 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2610 this->allocatorRef());
2611 *newBlockPtr = *pos.blockPtr();
2612 *pos.blockPtr() = newBlock;
2617 this->d_finish = IteratorImp(&newBlockPtr[-1],
2618 newBlockPtr[-1]->d_data + splitOffset);
2619 other->d_start.previousBlock();
2620 *(other->d_start.blockPtr()) = *newBlockPtr;
2621 other->d_start = IteratorImp(other->d_start.blockPtr(),
2622 other->d_start.blockBegin() + splitOffset);
2625template <
class VALUE_TYPE,
class ALLOCATOR>
2627void deque<VALUE_TYPE, ALLOCATOR>::privateJoinPrepend(
2628 deque<VALUE_TYPE, ALLOCATOR> *other)
2630 privatePrepend(other->begin(),
2632 std::random_access_iterator_tag());
2636 deque<VALUE_TYPE, ALLOCATOR> temp(k_RAW_INIT, other->allocatorRef());
2637 Deque_Util::move(
static_cast<Base *
>(&temp),
static_cast<Base *
>(other));
2640template <
class VALUE_TYPE,
class ALLOCATOR>
2642void deque<VALUE_TYPE, ALLOCATOR>::privateJoinAppend(
2643 deque<VALUE_TYPE, ALLOCATOR> *other)
2645 privateAppend(other->begin(),
2647 std::random_access_iterator_tag());
2651 deque<VALUE_TYPE, ALLOCATOR> temp(k_RAW_INIT, other->allocatorRef());
2652 Deque_Util::move(
static_cast<Base *
>(&temp),
static_cast<Base *
>(other));
2655template <
class VALUE_TYPE,
class ALLOCATOR>
2656template <
class INPUT_ITERATOR>
2657void deque<VALUE_TYPE, ALLOCATOR>::privateInsert(
2658 const_iterator position,
2659 INPUT_ITERATOR first,
2660 INPUT_ITERATOR last,
2661 std::random_access_iterator_tag tag)
2665 if (position == this->
cbegin()) {
2666 privatePrepend(first, last, tag);
2670 if (position == this->
cend()) {
2671 privateAppend(first, last, tag);
2675 const size_type currentSize = this->
size();
2676 const size_type numElements = bsl::distance(first, last);
2678 numElements > max_size() - currentSize)) {
2681 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2682 "deque<...>::insert(pos,n,v): deque too big");
2685 iterator pos(position.imp());
2686 const size_type posIdx = position - this->
cbegin();
2687 if (posIdx <= currentSize / 2) {
2691 size_type numNewBlocks = (this->d_start.remainingInBlock()
2692 + numElements - 1) / BLOCK_LENGTH;
2693 BlockCreator newBlocks(
this);
2694 newBlocks.insertAtFront(numNewBlocks);
2696 DequePrimitives::insertAndMoveToFront(&this->d_start,
2698 this->d_start + posIdx,
2702 this->allocatorRef());
2707 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements)
2709 BlockCreator newBlocks(
this);
2710 newBlocks.insertAtBack(numNewBlocks);
2712 DequePrimitives::insertAndMoveToBack(&this->d_finish,
2714 this->d_start + posIdx,
2718 this->allocatorRef());
2722template <
class VALUE_TYPE,
class ALLOCATOR>
2723void deque<VALUE_TYPE, ALLOCATOR>::privatePrependRaw(
2724 size_type numElements,
2725 const VALUE_TYPE& value)
2730 size_type numNewBlocks = (this->d_start.remainingInBlock() +
2731 numElements - 1) / BLOCK_LENGTH;
2732 BlockCreator newBlocks(
this);
2733 newBlocks.insertAtFront(numNewBlocks);
2735 DequePrimitives::uninitializedFillNFront(&this->d_start,
2739 this->allocatorRef());
2742template <
class VALUE_TYPE,
class ALLOCATOR>
2743template <
class INPUT_ITERATOR>
2744typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2745deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(INPUT_ITERATOR first,
2746 INPUT_ITERATOR last,
2747 std::input_iterator_tag tag)
2749 deque temp(k_RAW_INIT, this->get_allocator());
2750 temp.privateInit(this->
size() + 1);
2751 size_type numElements = temp.privateAppend(first, last, tag);
2755 if (numElements > this->
size()) {
2756 Deque_Util::swap((Base *)
this, (Base *)&temp);
2757 privateJoinAppend(&temp);
2760 privateJoinPrepend(&temp);
2766template <
class VALUE_TYPE,
class ALLOCATOR>
2767template <
class INPUT_ITERATOR>
2768typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2769deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(
2770 INPUT_ITERATOR first,
2771 INPUT_ITERATOR last,
2772 std::bidirectional_iterator_tag)
2775 BlockCreator newBlocks(
this);
2776 Guard guard(
this,
false);
2778 size_type numElements = 0;
2779 size_type maxNumElements = max_size() - this->
size();
2783 numElements > maxNumElements)) {
2786 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2787 "deque<...>::insert(pos,n,v): deque too big");
2790 IteratorImp insertPoint = guard.begin();
2795 if (insertPoint.valuePtr() == insertPoint.blockBegin()) {
2796 newBlocks.insertAtFront(1);
2797 insertPoint = guard.begin();
2801 AllocatorTraits::construct(this->allocatorRef(),
2805 }
while (first != last);
2807 this->d_start -= guard.count();
2812template <
class VALUE_TYPE,
class ALLOCATOR>
2813template <
class INPUT_ITERATOR>
2814typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2815deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(
2816 INPUT_ITERATOR first,
2817 INPUT_ITERATOR last,
2818 std::random_access_iterator_tag)
2821 const size_type numElements = bsl::distance(first, last);
2823 numElements > max_size() - this->
size())) {
2826 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2827 "deque<...>::insert(pos,n,v): deque too big");
2830 BlockCreator newBlocks(
this);
2831 Guard guard(
this,
false);
2834 IteratorImp insertPoint = guard.begin();
2839 if (insertPoint.valuePtr() == insertPoint.blockBegin()) {
2840 newBlocks.insertAtFront(1);
2841 insertPoint = guard.begin();
2845 AllocatorTraits::construct(this->allocatorRef(),
2849 }
while (first != last);
2851 this->d_start -= guard.count();
2857template <
class VALUE_TYPE,
class ALLOCATOR>
2858deque<VALUE_TYPE, ALLOCATOR>::deque()
2859: Deque_Base<VALUE_TYPE>()
2860, ContainerBase(ALLOCATOR())
2862 deque temp(k_RAW_INIT, this->get_allocator());
2863 temp.privateInit(0);
2864 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2867template <
class VALUE_TYPE,
class ALLOCATOR>
2868deque<VALUE_TYPE, ALLOCATOR>::deque(
const ALLOCATOR& basicAllocator)
2869: Deque_Base<VALUE_TYPE>()
2870, ContainerBase(basicAllocator)
2872 deque temp(k_RAW_INIT, this->get_allocator());
2873 temp.privateInit(0);
2874 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2877template <
class VALUE_TYPE,
class ALLOCATOR>
2878deque<VALUE_TYPE, ALLOCATOR>::deque(size_type numElements,
2879 const ALLOCATOR& basicAllocator)
2880: Deque_Base<VALUE_TYPE>()
2881, ContainerBase(basicAllocator)
2886 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2887 "deque<...>::deque(n): deque too big");
2889 deque temp(k_RAW_INIT, this->get_allocator());
2890 temp.privateInit(numElements);
2891 temp.privateAppendDefaultInsertable(numElements);
2892 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2895template <
class VALUE_TYPE,
class ALLOCATOR>
2896deque<VALUE_TYPE, ALLOCATOR>::deque(size_type numElements,
2897 const VALUE_TYPE& value,
2898 const ALLOCATOR& basicAllocator)
2899: Deque_Base<VALUE_TYPE>()
2900, ContainerBase(basicAllocator)
2905 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2906 "deque<...>::deque(n,v): deque too big");
2908 deque temp(k_RAW_INIT, this->get_allocator());
2909 temp.privateInit(numElements);
2910 temp.privateAppendRaw(numElements, value);
2911 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2914template <
class VALUE_TYPE,
class ALLOCATOR>
2915template <
class INPUT_ITERATOR>
2916deque<VALUE_TYPE, ALLOCATOR>::deque(INPUT_ITERATOR first,
2917 INPUT_ITERATOR last,
2918 const ALLOCATOR& basicAllocator)
2919: Deque_Base<VALUE_TYPE>()
2920, ContainerBase(basicAllocator)
2922 deque temp(k_RAW_INIT, this->get_allocator());
2923 temp.privateInit(0);
2924 temp.insert(temp.begin(), first, last);
2925 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2928template <
class VALUE_TYPE,
class ALLOCATOR>
2929deque<VALUE_TYPE, ALLOCATOR>::deque(
const deque& original)
2930: Deque_Base<VALUE_TYPE>()
2931, ContainerBase(AllocatorTraits::select_on_container_copy_construction(
2932 original.get_allocator()))
2934 deque temp(k_RAW_INIT, this->get_allocator());
2935 temp.privateInit(original.size());
2936 temp.privateAppend(original.begin(),
2938 std::random_access_iterator_tag());
2939 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2942template <
class VALUE_TYPE,
class ALLOCATOR>
2943deque<VALUE_TYPE, ALLOCATOR>::deque(
2944 const deque& original,
2945 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2946: Deque_Base<VALUE_TYPE>()
2947, ContainerBase(basicAllocator)
2949 deque temp(k_RAW_INIT, this->get_allocator());
2950 temp.privateInit(original.size());
2951 temp.privateAppend(original.begin(),
2953 std::random_access_iterator_tag());
2954 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2957template <
class VALUE_TYPE,
class ALLOCATOR>
2958deque<VALUE_TYPE, ALLOCATOR>::deque(
2959 BloombergLP::bslmf::MovableRef<deque> original)
2960: Deque_Base<VALUE_TYPE>()
2961, ContainerBase(MoveUtil::access(original).get_allocator())
2963 deque temp(k_RAW_INIT, this->get_allocator());
2964 temp.privateInit(0);
2965 Deque_Util::move(
static_cast<Base *
>(
this),
static_cast<Base *
>(&temp));
2967 deque& lvalue = original;
2968 Deque_Util::swap(
static_cast<Base *
>(
this),
static_cast<Base *
>(&lvalue));
2971template <
class VALUE_TYPE,
class ALLOCATOR>
2972deque<VALUE_TYPE, ALLOCATOR>::deque(
2973 BloombergLP::bslmf::MovableRef<deque> original,
2974 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2975: Deque_Base<VALUE_TYPE>()
2976, ContainerBase(basicAllocator)
2978 deque temp(k_RAW_INIT, this->get_allocator());
2979 temp.privateInit(0);
2981 deque& lvalue = original;
2984 get_allocator() == lvalue.get_allocator())) {
2985 Deque_Util::move(
static_cast<Base *
>(
this),
2986 static_cast<Base *
>(&temp));
2987 Deque_Util::swap(
static_cast<Base *
>(
this),
2988 static_cast<Base *
>(&lvalue));
2991 const size_type
size = lvalue.size();
2993 for (size_type pos = 0; pos <
size; ++pos) {
2994 temp.push_back(MoveUtil::move(lvalue[pos]));
2996 Deque_Util::move(
static_cast<Base *
>(
this),
2997 static_cast<Base *
>(&temp));
3001#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3002template <
class VALUE_TYPE,
class ALLOCATOR>
3004deque<VALUE_TYPE, ALLOCATOR>::deque(
3005 std::initializer_list<value_type> values,
3006 const ALLOCATOR& basicAllocator)
3007: deque(values.
begin(), values.
end(), basicAllocator)
3012template <
class VALUE_TYPE,
class ALLOCATOR>
3013deque<VALUE_TYPE, ALLOCATOR>::~deque()
3015 if (0 == this->d_blocks_p) {
3021 if (0 != this->d_start.blockPtr()) {
3026 this->deallocateBlock(*this->d_start.blockPtr());
3030 this->deallocateBlockPtrs(this->d_blocks_p, this->d_blocksLength);
3034template <
class VALUE_TYPE,
class ALLOCATOR>
3035deque<VALUE_TYPE, ALLOCATOR>&
3036deque<VALUE_TYPE, ALLOCATOR>::operator=(
const deque<VALUE_TYPE,ALLOCATOR>& rhs)
3039 AllocatorTraits::propagate_on_container_copy_assignment Propagate;
3042 if (Propagate::value && get_allocator() != rhs.get_allocator()) {
3043 deque other(rhs, rhs.get_allocator());
3045 Deque_Util::swap(
static_cast<Base *
>(
this),
3046 static_cast<Base *
>(&other));
3047 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
3051 size_type origSize = this->size();
3052 size_type rhsSize = rhs.size();
3055 if (origSize > rhsSize) {
3065 privateAppend(rhs.begin() + minSize,
3067 std::random_access_iterator_tag());
3072 IteratorImp from = rhs.d_start;
3073 IteratorImp to = this->d_start;
3074 for (size_type i = 0; i < minSize; ++i) {
3085template <
class VALUE_TYPE,
class ALLOCATOR>
3086deque<VALUE_TYPE, ALLOCATOR>&
3087deque<VALUE_TYPE, ALLOCATOR>::operator=(
3088 BloombergLP::bslmf::MovableRef<deque> rhs)
3090 AllocatorTraits::is_always_equal::value)
3092 deque& lvalue = rhs;
3095 AllocatorTraits::propagate_on_container_move_assignment Propagate;
3097 if (get_allocator() == lvalue.get_allocator()) {
3098 Deque_Util::swap(
static_cast<Base *
>(
this),
3099 static_cast<Base *
>(&lvalue));
3101 else if (Propagate::value) {
3102 deque other(MoveUtil::move(lvalue));
3103 Deque_Util::swap(
static_cast<Base *
>(
this),
3104 static_cast<Base *
>(&other));
3105 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
3109 deque other(MoveUtil::move(lvalue), get_allocator());
3110 Deque_Util::swap(
static_cast<Base *
>(
this),
3111 static_cast<Base *
>(&other));
3117#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3118template <
class VALUE_TYPE,
class ALLOCATOR>
3120deque<VALUE_TYPE, ALLOCATOR>&
3121deque<VALUE_TYPE, ALLOCATOR>::operator=(
3122 std::initializer_list<value_type> values)
3124 assign(values.begin(), values.end());
3129template <
class VALUE_TYPE,
class ALLOCATOR>
3130template <
class INPUT_ITERATOR>
3131void deque<VALUE_TYPE, ALLOCATOR>::assign(INPUT_ITERATOR first,
3132 INPUT_ITERATOR last)
3134 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
3143 ClearGuard guard(
this);
3148 for (i = this->d_start; !(i == this->d_finish) && first != last;
3153 if (!(i == this->d_finish)) {
3161 privateAppend(first, last, Tag());
3167template <
class VALUE_TYPE,
class ALLOCATOR>
3168void deque<VALUE_TYPE, ALLOCATOR>::assign(size_type numElements,
3169 const VALUE_TYPE& value)
3174 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3175 "deque<...>::assign(n,v): deque too big");
3185 ClearGuard guard(
this);
3187 size_type origSize = this->size();
3190 if (numElements < origSize) {
3191 minSize = numElements;
3196 privateAppendRaw(numElements - origSize, value);
3199 IteratorImp to = this->d_start;
3200 for (size_type i = 0; i < minSize; ++i) {
3208#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3209template <
class VALUE_TYPE,
class ALLOCATOR>
3211void deque<VALUE_TYPE, ALLOCATOR>::assign(
3212 std::initializer_list<value_type> values)
3214 assign(values.begin(), values.end());
3218template <
class VALUE_TYPE,
class ALLOCATOR>
3219void deque<VALUE_TYPE, ALLOCATOR>::reserve(size_type numElements)
3225 max_size() - (BLOCK_LENGTH - 1))) {
3228 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3229 "deque<...>::reserve(n): deque too big");
3239 if (this->d_start.blockPtr() > this->d_blocks_p) {
3240 this->d_blocks_p[0] = 0;
3242 if (this->d_finish.blockPtr() < this->d_blocks_p + this->d_blocksLength-1){
3243 this->d_blocks_p[this->d_blocksLength - 1] = 0;
3246 const IteratorImp first(this->d_blocks_p);
3247 IteratorImp last( this->d_blocks_p + this->d_blocksLength - 1);
3248 last += BLOCK_LENGTH - 1;
3250 const size_type frontRoom = this->d_start - first;
3251 const size_type backRoom = last - this->d_finish;
3253 size_type numFrontBlocks = numElements > frontRoom
3254 ? (numElements - frontRoom + BLOCK_LENGTH - 1) /
3257 size_type numBackBlocks = numElements > backRoom
3258 ? (numElements - backRoom + BLOCK_LENGTH - 1) /
3262 if (0 == numFrontBlocks && 0 == numBackBlocks) {
3268 size_type existingSpace = last - first;
3270 (max_size() - existingSpace) / BLOCK_LENGTH
3271 || (existingSpace += numFrontBlocks * BLOCK_LENGTH,
3273 (max_size() - existingSpace) / BLOCK_LENGTH))) {
3276 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3277 "deque<...>::reserve(n): deque too big");
3283 BlockCreator newBlocks(
this);
3284 newBlocks.reserveBlockSlots(numFrontBlocks,
true);
3285 newBlocks.reserveBlockSlots(numBackBlocks,
false);
3288template <
class VALUE_TYPE,
class ALLOCATOR>
3289void deque<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize)
3294 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3295 "deque<...>::resize(n): deque too big");
3298 size_type origSize = this->size();
3300 if (newSize <= origSize) {
3305 IteratorImp oldEnd = this->d_finish;
3306 IteratorImp newEnd = this->d_start + newSize;
3307 DequePrimitives::destruct(newEnd, oldEnd, this->allocatorRef());
3309 for (; oldEnd.blockPtr() != newEnd.blockPtr();
3310 oldEnd.previousBlock()) {
3311 this->deallocateBlock(*oldEnd.blockPtr());
3313 this->d_finish = newEnd;
3316 privateAppendDefaultInsertable(newSize - origSize);
3320template <
class VALUE_TYPE,
class ALLOCATOR>
3321void deque<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize,
3322 const VALUE_TYPE& value)
3327 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3328 "deque<...>::resize(n,v): deque too big");
3331 size_type origSize = this->size();
3333 if (newSize <= origSize) {
3337 privateAppendRaw(newSize - origSize, value);
3341template <
class VALUE_TYPE,
class ALLOCATOR>
3342void deque<VALUE_TYPE, ALLOCATOR>::shrink_to_fit()
3348 const size_type newBlocksLength =
3349 this->d_finish.blockPtr() - this->d_start.blockPtr() + 1;
3351 if (newBlocksLength == this->d_blocksLength) {
3355 const size_type offsetStart = this->d_start.offsetInBlock();
3356 const size_type offsetFinish = this->d_finish.offsetInBlock();
3358 BlockPtr *newBlocks = this->allocateBlockPtrs(newBlocksLength);
3360 std::memmove(newBlocks,
3361 this->d_start.blockPtr(),
3362 newBlocksLength *
sizeof(BlockPtr));
3364 this->deallocateBlockPtrs(this->d_blocks_p, this->d_blocksLength);
3366 this->d_blocks_p = newBlocks;
3367 this->d_blocksLength = newBlocksLength;
3369 this->d_start.setBlock(newBlocks);
3370 this->d_start += offsetStart;
3372 this->d_finish.setBlock(newBlocks + newBlocksLength - 1);
3373 this->d_finish += offsetFinish;
3376template <
class VALUE_TYPE,
class ALLOCATOR>
3377void deque<VALUE_TYPE, ALLOCATOR>::push_front(
const VALUE_TYPE& value)
3382 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3383 "deque<...>::push_front(v): deque too big");
3387 0 == this->d_start.offsetInBlock())) {
3390 BlockCreator newBlocks(
this);
3391 newBlocks.insertAtFront(1);
3393 AllocatorTraits::construct(
3394 this->allocatorRef(), (this->d_start - 1).valuePtr(), value);
3402 AllocatorTraits::construct(
3403 this->allocatorRef(), this->d_start.valuePtr() - 1, value);
3404 this->d_start.valuePtrDecrement();
3408template <
class VALUE_TYPE,
class ALLOCATOR>
3409void deque<VALUE_TYPE, ALLOCATOR>::push_front(
3410 BloombergLP::bslmf::MovableRef<value_type> value)
3415 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3416 "deque<...>::push_front(v): deque too big");
3419 VALUE_TYPE& lvalue = value;
3422 0 == this->d_start.offsetInBlock())) {
3425 BlockCreator newBlocks(
this);
3426 newBlocks.insertAtFront(1);
3428 AllocatorTraits::construct(this->allocatorRef(),
3429 (this->d_start - 1).valuePtr(),
3430 MoveUtil::move(lvalue));
3437 AllocatorTraits::construct(this->allocatorRef(),
3438 this->d_start.valuePtr() - 1,
3439 MoveUtil::move(lvalue));
3440 this->d_start.valuePtrDecrement();
3444template <
class VALUE_TYPE,
class ALLOCATOR>
3445void deque<VALUE_TYPE, ALLOCATOR>::push_back(
const VALUE_TYPE& value)
3450 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3451 "deque<...>::push_back(v): deque too big");
3455 1 < this->d_finish.remainingInBlock())) {
3456 AllocatorTraits::construct(
3457 this->allocatorRef(), this->d_finish.valuePtr(), value);
3458 this->d_finish.valuePtrIncrement();
3463 BlockCreator newBlocks(
this);
3464 newBlocks.insertAtBack(1);
3466 AllocatorTraits::construct(
3467 this->allocatorRef(), this->d_finish.valuePtr(), value);
3468 this->d_finish.nextBlock();
3472template <
class VALUE_TYPE,
class ALLOCATOR>
3473void deque<VALUE_TYPE, ALLOCATOR>::push_back(
3474 BloombergLP::bslmf::MovableRef<value_type> value)
3479 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3480 "deque<...>::push_back(v): deque too big");
3483 VALUE_TYPE& lvalue = value;
3486 1 < this->d_finish.remainingInBlock())) {
3487 AllocatorTraits::construct(this->allocatorRef(),
3488 this->d_finish.valuePtr(),
3489 MoveUtil::move(lvalue));
3490 this->d_finish.valuePtrIncrement();
3495 BlockCreator newBlocks(
this);
3496 newBlocks.insertAtBack(1);
3498 AllocatorTraits::construct(this->allocatorRef(),
3499 this->d_finish.valuePtr(),
3500 MoveUtil::move(lvalue));
3501 this->d_finish.nextBlock();
3505#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3508#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
3509#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
3511#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_C
3512#define BSLSTL_DEQUE_VARIADIC_LIMIT_C BSLSTL_DEQUE_VARIADIC_LIMIT
3514#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
3515template <
class VALUE_TYPE,
class ALLOCATOR>
3516typename deque<VALUE_TYPE, ALLOCATOR>::reference
3517deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3523 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3524 "deque<...>::emplace_front(args): deque too big");
3528 0 == this->d_start.offsetInBlock())) {
3531 BlockCreator newBlocks(
this);
3532 newBlocks.insertAtFront(1);
3534 AllocatorTraits::construct(
3535 this->allocatorRef(),
3536 (this->d_start - 1).valuePtr());
3541 AllocatorTraits::construct(
3542 this->allocatorRef(),
3543 this->d_start.valuePtr() - 1);
3544 this->d_start.valuePtrDecrement();
3546 return *(this->d_start);
3550#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
3551template <
class VALUE_TYPE,
class ALLOCATOR>
3552template <
class Args_01>
3553typename deque<VALUE_TYPE, ALLOCATOR>::reference
3554deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3560 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3561 "deque<...>::emplace_front(args): deque too big");
3565 0 == this->d_start.offsetInBlock())) {
3568 BlockCreator newBlocks(
this);
3569 newBlocks.insertAtFront(1);
3571 AllocatorTraits::construct(
3572 this->allocatorRef(),
3573 (this->d_start - 1).valuePtr(),
3579 AllocatorTraits::construct(
3580 this->allocatorRef(),
3581 this->d_start.valuePtr() - 1,
3583 this->d_start.valuePtrDecrement();
3585 return *(this->d_start);
3589#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
3590template <
class VALUE_TYPE,
class ALLOCATOR>
3591template <
class Args_01,
3593typename deque<VALUE_TYPE, ALLOCATOR>::reference
3594deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3601 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3602 "deque<...>::emplace_front(args): deque too big");
3606 0 == this->d_start.offsetInBlock())) {
3609 BlockCreator newBlocks(
this);
3610 newBlocks.insertAtFront(1);
3612 AllocatorTraits::construct(
3613 this->allocatorRef(),
3614 (this->d_start - 1).valuePtr(),
3621 AllocatorTraits::construct(
3622 this->allocatorRef(),
3623 this->d_start.valuePtr() - 1,
3626 this->d_start.valuePtrDecrement();
3628 return *(this->d_start);
3632#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
3633template <
class VALUE_TYPE,
class ALLOCATOR>
3634template <
class Args_01,
3637typename deque<VALUE_TYPE, ALLOCATOR>::reference
3638deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3646 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3647 "deque<...>::emplace_front(args): deque too big");
3651 0 == this->d_start.offsetInBlock())) {
3654 BlockCreator newBlocks(
this);
3655 newBlocks.insertAtFront(1);
3657 AllocatorTraits::construct(
3658 this->allocatorRef(),
3659 (this->d_start - 1).valuePtr(),
3667 AllocatorTraits::construct(
3668 this->allocatorRef(),
3669 this->d_start.valuePtr() - 1,
3673 this->d_start.valuePtrDecrement();
3675 return *(this->d_start);
3679#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
3680template <
class VALUE_TYPE,
class ALLOCATOR>
3681template <
class Args_01,
3685typename deque<VALUE_TYPE, ALLOCATOR>::reference
3686deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3695 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3696 "deque<...>::emplace_front(args): deque too big");
3700 0 == this->d_start.offsetInBlock())) {
3703 BlockCreator newBlocks(
this);
3704 newBlocks.insertAtFront(1);
3706 AllocatorTraits::construct(
3707 this->allocatorRef(),
3708 (this->d_start - 1).valuePtr(),
3717 AllocatorTraits::construct(
3718 this->allocatorRef(),
3719 this->d_start.valuePtr() - 1,
3724 this->d_start.valuePtrDecrement();
3726 return *(this->d_start);
3730#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
3731template <
class VALUE_TYPE,
class ALLOCATOR>
3732template <
class Args_01,
3737typename deque<VALUE_TYPE, ALLOCATOR>::reference
3738deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3748 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3749 "deque<...>::emplace_front(args): deque too big");
3753 0 == this->d_start.offsetInBlock())) {
3756 BlockCreator newBlocks(
this);
3757 newBlocks.insertAtFront(1);
3759 AllocatorTraits::construct(
3760 this->allocatorRef(),
3761 (this->d_start - 1).valuePtr(),
3771 AllocatorTraits::construct(
3772 this->allocatorRef(),
3773 this->d_start.valuePtr() - 1,
3779 this->d_start.valuePtrDecrement();
3781 return *(this->d_start);
3785#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
3786template <
class VALUE_TYPE,
class ALLOCATOR>
3787template <
class Args_01,
3793typename deque<VALUE_TYPE, ALLOCATOR>::reference
3794deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3805 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3806 "deque<...>::emplace_front(args): deque too big");
3810 0 == this->d_start.offsetInBlock())) {
3813 BlockCreator newBlocks(
this);
3814 newBlocks.insertAtFront(1);
3816 AllocatorTraits::construct(
3817 this->allocatorRef(),
3818 (this->d_start - 1).valuePtr(),
3829 AllocatorTraits::construct(
3830 this->allocatorRef(),
3831 this->d_start.valuePtr() - 1,
3838 this->d_start.valuePtrDecrement();
3840 return *(this->d_start);
3844#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
3845template <
class VALUE_TYPE,
class ALLOCATOR>
3846template <
class Args_01,
3853typename deque<VALUE_TYPE, ALLOCATOR>::reference
3854deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3866 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3867 "deque<...>::emplace_front(args): deque too big");
3871 0 == this->d_start.offsetInBlock())) {
3874 BlockCreator newBlocks(
this);
3875 newBlocks.insertAtFront(1);
3877 AllocatorTraits::construct(
3878 this->allocatorRef(),
3879 (this->d_start - 1).valuePtr(),
3891 AllocatorTraits::construct(
3892 this->allocatorRef(),
3893 this->d_start.valuePtr() - 1,
3901 this->d_start.valuePtrDecrement();
3903 return *(this->d_start);
3907#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
3908template <
class VALUE_TYPE,
class ALLOCATOR>
3909template <
class Args_01,
3917typename deque<VALUE_TYPE, ALLOCATOR>::reference
3918deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3931 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3932 "deque<...>::emplace_front(args): deque too big");
3936 0 == this->d_start.offsetInBlock())) {
3939 BlockCreator newBlocks(
this);
3940 newBlocks.insertAtFront(1);
3942 AllocatorTraits::construct(
3943 this->allocatorRef(),
3944 (this->d_start - 1).valuePtr(),
3957 AllocatorTraits::construct(
3958 this->allocatorRef(),
3959 this->d_start.valuePtr() - 1,
3968 this->d_start.valuePtrDecrement();
3970 return *(this->d_start);
3974#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
3975template <
class VALUE_TYPE,
class ALLOCATOR>
3976template <
class Args_01,
3985typename deque<VALUE_TYPE, ALLOCATOR>::reference
3986deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4000 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4001 "deque<...>::emplace_front(args): deque too big");
4005 0 == this->d_start.offsetInBlock())) {
4008 BlockCreator newBlocks(
this);
4009 newBlocks.insertAtFront(1);
4011 AllocatorTraits::construct(
4012 this->allocatorRef(),
4013 (this->d_start - 1).valuePtr(),
4027 AllocatorTraits::construct(
4028 this->allocatorRef(),
4029 this->d_start.valuePtr() - 1,
4039 this->d_start.valuePtrDecrement();
4041 return *(this->d_start);
4045#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4046template <
class VALUE_TYPE,
class ALLOCATOR>
4047template <
class Args_01,
4057typename deque<VALUE_TYPE, ALLOCATOR>::reference
4058deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4073 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4074 "deque<...>::emplace_front(args): deque too big");
4078 0 == this->d_start.offsetInBlock())) {
4081 BlockCreator newBlocks(
this);
4082 newBlocks.insertAtFront(1);
4084 AllocatorTraits::construct(
4085 this->allocatorRef(),
4086 (this->d_start - 1).valuePtr(),
4101 AllocatorTraits::construct(
4102 this->allocatorRef(),
4103 this->d_start.valuePtr() - 1,
4114 this->d_start.valuePtrDecrement();
4116 return *(this->d_start);
4121#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
4122template <
class VALUE_TYPE,
class ALLOCATOR>
4123typename deque<VALUE_TYPE, ALLOCATOR>::reference
4124deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4130 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4131 "deque<...>::emplace_back(args): deque too big");
4135 1 < this->d_finish.remainingInBlock())) {
4136 AllocatorTraits::construct(
4137 this->allocatorRef(),
4138 this->d_finish.valuePtr());
4139 this->d_finish.valuePtrIncrement();
4144 BlockCreator newBlocks(
this);
4145 newBlocks.insertAtBack(1);
4147 AllocatorTraits::construct(
4148 this->allocatorRef(),
4149 this->d_finish.valuePtr());
4150 this->d_finish.nextBlock();
4152 return *(this->d_finish - 1);
4156#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
4157template <
class VALUE_TYPE,
class ALLOCATOR>
4158template <
class Args_01>
4159typename deque<VALUE_TYPE, ALLOCATOR>::reference
4160deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4166 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4167 "deque<...>::emplace_back(args): deque too big");
4171 1 < this->d_finish.remainingInBlock())) {
4172 AllocatorTraits::construct(
4173 this->allocatorRef(),
4174 this->d_finish.valuePtr(),
4176 this->d_finish.valuePtrIncrement();
4181 BlockCreator newBlocks(
this);
4182 newBlocks.insertAtBack(1);
4184 AllocatorTraits::construct(
4185 this->allocatorRef(),
4186 this->d_finish.valuePtr(),
4188 this->d_finish.nextBlock();
4190 return *(this->d_finish - 1);
4194#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
4195template <
class VALUE_TYPE,
class ALLOCATOR>
4196template <
class Args_01,
4198typename deque<VALUE_TYPE, ALLOCATOR>::reference
4199deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4206 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4207 "deque<...>::emplace_back(args): deque too big");
4211 1 < this->d_finish.remainingInBlock())) {
4212 AllocatorTraits::construct(
4213 this->allocatorRef(),
4214 this->d_finish.valuePtr(),
4217 this->d_finish.valuePtrIncrement();
4222 BlockCreator newBlocks(
this);
4223 newBlocks.insertAtBack(1);
4225 AllocatorTraits::construct(
4226 this->allocatorRef(),
4227 this->d_finish.valuePtr(),
4230 this->d_finish.nextBlock();
4232 return *(this->d_finish - 1);
4236#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
4237template <
class VALUE_TYPE,
class ALLOCATOR>
4238template <
class Args_01,
4241typename deque<VALUE_TYPE, ALLOCATOR>::reference
4242deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4250 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4251 "deque<...>::emplace_back(args): deque too big");
4255 1 < this->d_finish.remainingInBlock())) {
4256 AllocatorTraits::construct(
4257 this->allocatorRef(),
4258 this->d_finish.valuePtr(),
4262 this->d_finish.valuePtrIncrement();
4267 BlockCreator newBlocks(
this);
4268 newBlocks.insertAtBack(1);
4270 AllocatorTraits::construct(
4271 this->allocatorRef(),
4272 this->d_finish.valuePtr(),
4276 this->d_finish.nextBlock();
4278 return *(this->d_finish - 1);
4282#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
4283template <
class VALUE_TYPE,
class ALLOCATOR>
4284template <
class Args_01,
4288typename deque<VALUE_TYPE, ALLOCATOR>::reference
4289deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4298 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4299 "deque<...>::emplace_back(args): deque too big");
4303 1 < this->d_finish.remainingInBlock())) {
4304 AllocatorTraits::construct(
4305 this->allocatorRef(),
4306 this->d_finish.valuePtr(),
4311 this->d_finish.valuePtrIncrement();
4316 BlockCreator newBlocks(
this);
4317 newBlocks.insertAtBack(1);
4319 AllocatorTraits::construct(
4320 this->allocatorRef(),
4321 this->d_finish.valuePtr(),
4326 this->d_finish.nextBlock();
4328 return *(this->d_finish - 1);
4332#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
4333template <
class VALUE_TYPE,
class ALLOCATOR>
4334template <
class Args_01,
4339typename deque<VALUE_TYPE, ALLOCATOR>::reference
4340deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4350 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4351 "deque<...>::emplace_back(args): deque too big");
4355 1 < this->d_finish.remainingInBlock())) {
4356 AllocatorTraits::construct(
4357 this->allocatorRef(),
4358 this->d_finish.valuePtr(),
4364 this->d_finish.valuePtrIncrement();
4369 BlockCreator newBlocks(
this);
4370 newBlocks.insertAtBack(1);
4372 AllocatorTraits::construct(
4373 this->allocatorRef(),
4374 this->d_finish.valuePtr(),
4380 this->d_finish.nextBlock();
4382 return *(this->d_finish - 1);
4386#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
4387template <
class VALUE_TYPE,
class ALLOCATOR>
4388template <
class Args_01,
4394typename deque<VALUE_TYPE, ALLOCATOR>::reference
4395deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4406 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4407 "deque<...>::emplace_back(args): deque too big");
4411 1 < this->d_finish.remainingInBlock())) {
4412 AllocatorTraits::construct(
4413 this->allocatorRef(),
4414 this->d_finish.valuePtr(),
4421 this->d_finish.valuePtrIncrement();
4426 BlockCreator newBlocks(
this);
4427 newBlocks.insertAtBack(1);
4429 AllocatorTraits::construct(
4430 this->allocatorRef(),
4431 this->d_finish.valuePtr(),
4438 this->d_finish.nextBlock();
4440 return *(this->d_finish - 1);
4444#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
4445template <
class VALUE_TYPE,
class ALLOCATOR>
4446template <
class Args_01,
4453typename deque<VALUE_TYPE, ALLOCATOR>::reference
4454deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4466 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4467 "deque<...>::emplace_back(args): deque too big");
4471 1 < this->d_finish.remainingInBlock())) {
4472 AllocatorTraits::construct(
4473 this->allocatorRef(),
4474 this->d_finish.valuePtr(),
4482 this->d_finish.valuePtrIncrement();
4487 BlockCreator newBlocks(
this);
4488 newBlocks.insertAtBack(1);
4490 AllocatorTraits::construct(
4491 this->allocatorRef(),
4492 this->d_finish.valuePtr(),
4500 this->d_finish.nextBlock();
4502 return *(this->d_finish - 1);
4506#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
4507template <
class VALUE_TYPE,
class ALLOCATOR>
4508template <
class Args_01,
4516typename deque<VALUE_TYPE, ALLOCATOR>::reference
4517deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4530 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4531 "deque<...>::emplace_back(args): deque too big");
4535 1 < this->d_finish.remainingInBlock())) {
4536 AllocatorTraits::construct(
4537 this->allocatorRef(),
4538 this->d_finish.valuePtr(),
4547 this->d_finish.valuePtrIncrement();
4552 BlockCreator newBlocks(
this);
4553 newBlocks.insertAtBack(1);
4555 AllocatorTraits::construct(
4556 this->allocatorRef(),
4557 this->d_finish.valuePtr(),
4566 this->d_finish.nextBlock();
4568 return *(this->d_finish - 1);
4572#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
4573template <
class VALUE_TYPE,
class ALLOCATOR>
4574template <
class Args_01,
4583typename deque<VALUE_TYPE, ALLOCATOR>::reference
4584deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4598 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4599 "deque<...>::emplace_back(args): deque too big");
4603 1 < this->d_finish.remainingInBlock())) {
4604 AllocatorTraits::construct(
4605 this->allocatorRef(),
4606 this->d_finish.valuePtr(),
4616 this->d_finish.valuePtrIncrement();
4621 BlockCreator newBlocks(
this);
4622 newBlocks.insertAtBack(1);
4624 AllocatorTraits::construct(
4625 this->allocatorRef(),
4626 this->d_finish.valuePtr(),
4636 this->d_finish.nextBlock();
4638 return *(this->d_finish - 1);
4642#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4643template <
class VALUE_TYPE,
class ALLOCATOR>
4644template <
class Args_01,
4654typename deque<VALUE_TYPE, ALLOCATOR>::reference
4655deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4670 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4671 "deque<...>::emplace_back(args): deque too big");
4675 1 < this->d_finish.remainingInBlock())) {
4676 AllocatorTraits::construct(
4677 this->allocatorRef(),
4678 this->d_finish.valuePtr(),
4689 this->d_finish.valuePtrIncrement();
4694 BlockCreator newBlocks(
this);
4695 newBlocks.insertAtBack(1);
4697 AllocatorTraits::construct(
4698 this->allocatorRef(),
4699 this->d_finish.valuePtr(),
4710 this->d_finish.nextBlock();
4712 return *(this->d_finish - 1);
4719template <
class VALUE_TYPE,
class ALLOCATOR>
4720template <
class... Args>
4721typename deque<VALUE_TYPE, ALLOCATOR>::reference
4722deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4728 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4729 "deque<...>::emplace_front(args): deque too big");
4733 0 == this->d_start.offsetInBlock())) {
4736 BlockCreator newBlocks(
this);
4737 newBlocks.insertAtFront(1);
4739 AllocatorTraits::construct(
4740 this->allocatorRef(),
4741 (this->d_start - 1).valuePtr(),
4747 AllocatorTraits::construct(
4748 this->allocatorRef(),
4749 this->d_start.valuePtr() - 1,
4751 this->d_start.valuePtrDecrement();
4753 return *(this->d_start);
4756template <
class VALUE_TYPE,
class ALLOCATOR>
4757template <
class... Args>
4758typename deque<VALUE_TYPE, ALLOCATOR>::reference
4759deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4765 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4766 "deque<...>::emplace_back(args): deque too big");
4770 1 < this->d_finish.remainingInBlock())) {
4771 AllocatorTraits::construct(
4772 this->allocatorRef(),
4773 this->d_finish.valuePtr(),
4775 this->d_finish.valuePtrIncrement();
4780 BlockCreator newBlocks(
this);
4781 newBlocks.insertAtBack(1);
4783 AllocatorTraits::construct(
4784 this->allocatorRef(),
4785 this->d_finish.valuePtr(),
4787 this->d_finish.nextBlock();
4789 return *(this->d_finish - 1);
4794#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4797#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
4798#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
4800#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_D
4801#define BSLSTL_DEQUE_VARIADIC_LIMIT_D BSLSTL_DEQUE_VARIADIC_LIMIT
4803#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 0
4804template <
class VALUE_TYPE,
class ALLOCATOR>
4805typename deque<VALUE_TYPE, ALLOCATOR>::iterator
4806deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position)
4811 if (position == this->
cbegin()) {
4813 return this->
begin();
4816 if (position == this->
cend()) {
4818 return iterator(this->d_finish - 1);
4822 const size_type currentSize = this->size();
4826 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4827 "deque<...>::emplace(args): deque too big");
4830 iterator pos(position.imp());
4831 const size_type posIdx = position - this->
cbegin();
4832 if (posIdx <= currentSize / 2) {
4833 BlockCreator newBlocks(
this);
4834 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
4835 newBlocks.insertAtFront(1);
4838 BlockProctor proctor(
this,
true);
4839 DequePrimitives::emplaceAndMoveToFront(
4842 this->d_start + posIdx,
4843 this->allocatorRef());
4847 BlockCreator newBlocks(
this);
4848 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
4849 newBlocks.insertAtBack(1);
4852 BlockProctor proctor(
this,
false);
4853 DequePrimitives::emplaceAndMoveToBack(
4856 this->d_start + posIdx,
4857 this->allocatorRef());
4860 return this->
begin() + posIdx;
4864#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 1
4865template <
class VALUE_TYPE,
class ALLOCATOR>
4866template <
class Args_01>
4867typename deque<VALUE_TYPE, ALLOCATOR>::iterator
4868deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
4874 if (position == this->
cbegin()) {
4876 return this->
begin();
4879 if (position == this->
cend()) {
4881 return iterator(this->d_finish - 1);
4885 const size_type currentSize = this->size();
4889 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4890 "deque<...>::emplace(args): deque too big");
4893 iterator pos(position.imp());
4894 const size_type posIdx = position - this->
cbegin();
4895 if (posIdx <= currentSize / 2) {
4896 BlockCreator newBlocks(
this);
4897 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
4898 newBlocks.insertAtFront(1);
4901 BlockProctor proctor(
this,
true);
4902 DequePrimitives::emplaceAndMoveToFront(
4905 this->d_start + posIdx,
4906 this->allocatorRef(),
4911 BlockCreator newBlocks(
this);
4912 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
4913 newBlocks.insertAtBack(1);
4916 BlockProctor proctor(
this,
false);
4917 DequePrimitives::emplaceAndMoveToBack(
4920 this->d_start + posIdx,
4921 this->allocatorRef(),
4925 return this->
begin() + posIdx;
4929#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 2
4930template <
class VALUE_TYPE,
class ALLOCATOR>
4931template <
class Args_01,
4933typename deque<VALUE_TYPE, ALLOCATOR>::iterator
4934deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
4941 if (position == this->
cbegin()) {
4944 return this->
begin();
4947 if (position == this->
cend()) {
4950 return iterator(this->d_finish - 1);
4954 const size_type currentSize = this->size();
4958 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4959 "deque<...>::emplace(args): deque too big");
4962 iterator pos(position.imp());
4963 const size_type posIdx = position - this->
cbegin();
4964 if (posIdx <= currentSize / 2) {
4965 BlockCreator newBlocks(
this);
4966 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
4967 newBlocks.insertAtFront(1);
4970 BlockProctor proctor(
this,
true);
4971 DequePrimitives::emplaceAndMoveToFront(
4974 this->d_start + posIdx,
4975 this->allocatorRef(),
4981 BlockCreator newBlocks(
this);
4982 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
4983 newBlocks.insertAtBack(1);
4986 BlockProctor proctor(
this,
false);
4987 DequePrimitives::emplaceAndMoveToBack(
4990 this->d_start + posIdx,
4991 this->allocatorRef(),
4996 return this->
begin() + posIdx;
5000#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 3
5001template <
class VALUE_TYPE,
class ALLOCATOR>
5002template <
class Args_01,
5005typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5006deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5014 if (position == this->
cbegin()) {
5018 return this->
begin();
5021 if (position == this->
cend()) {
5025 return iterator(this->d_finish - 1);
5029 const size_type currentSize = this->size();
5033 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5034 "deque<...>::emplace(args): deque too big");
5037 iterator pos(position.imp());
5038 const size_type posIdx = position - this->
cbegin();
5039 if (posIdx <= currentSize / 2) {
5040 BlockCreator newBlocks(
this);
5041 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5042 newBlocks.insertAtFront(1);
5045 BlockProctor proctor(
this,
true);
5046 DequePrimitives::emplaceAndMoveToFront(
5049 this->d_start + posIdx,
5050 this->allocatorRef(),
5057 BlockCreator newBlocks(
this);
5058 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5059 newBlocks.insertAtBack(1);
5062 BlockProctor proctor(
this,
false);
5063 DequePrimitives::emplaceAndMoveToBack(
5066 this->d_start + posIdx,
5067 this->allocatorRef(),
5073 return this->
begin() + posIdx;
5077#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 4
5078template <
class VALUE_TYPE,
class ALLOCATOR>
5079template <
class Args_01,
5083typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5084deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5093 if (position == this->
cbegin()) {
5098 return this->
begin();
5101 if (position == this->
cend()) {
5106 return iterator(this->d_finish - 1);
5110 const size_type currentSize = this->size();
5114 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5115 "deque<...>::emplace(args): deque too big");
5118 iterator pos(position.imp());
5119 const size_type posIdx = position - this->
cbegin();
5120 if (posIdx <= currentSize / 2) {
5121 BlockCreator newBlocks(
this);
5122 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5123 newBlocks.insertAtFront(1);
5126 BlockProctor proctor(
this,
true);
5127 DequePrimitives::emplaceAndMoveToFront(
5130 this->d_start + posIdx,
5131 this->allocatorRef(),
5139 BlockCreator newBlocks(
this);
5140 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5141 newBlocks.insertAtBack(1);
5144 BlockProctor proctor(
this,
false);
5145 DequePrimitives::emplaceAndMoveToBack(
5148 this->d_start + posIdx,
5149 this->allocatorRef(),
5156 return this->
begin() + posIdx;
5160#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 5
5161template <
class VALUE_TYPE,
class ALLOCATOR>
5162template <
class Args_01,
5167typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5168deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5178 if (position == this->
cbegin()) {
5184 return this->
begin();
5187 if (position == this->
cend()) {
5193 return iterator(this->d_finish - 1);
5197 const size_type currentSize = this->size();
5201 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5202 "deque<...>::emplace(args): deque too big");
5205 iterator pos(position.imp());
5206 const size_type posIdx = position - this->
cbegin();
5207 if (posIdx <= currentSize / 2) {
5208 BlockCreator newBlocks(
this);
5209 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5210 newBlocks.insertAtFront(1);
5213 BlockProctor proctor(
this,
true);
5214 DequePrimitives::emplaceAndMoveToFront(
5217 this->d_start + posIdx,
5218 this->allocatorRef(),
5227 BlockCreator newBlocks(
this);
5228 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5229 newBlocks.insertAtBack(1);
5232 BlockProctor proctor(
this,
false);
5233 DequePrimitives::emplaceAndMoveToBack(
5236 this->d_start + posIdx,
5237 this->allocatorRef(),
5245 return this->
begin() + posIdx;
5249#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 6
5250template <
class VALUE_TYPE,
class ALLOCATOR>
5251template <
class Args_01,
5257typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5258deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5269 if (position == this->
cbegin()) {
5276 return this->
begin();
5279 if (position == this->
cend()) {
5286 return iterator(this->d_finish - 1);
5290 const size_type currentSize = this->size();
5294 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5295 "deque<...>::emplace(args): deque too big");
5298 iterator pos(position.imp());
5299 const size_type posIdx = position - this->
cbegin();
5300 if (posIdx <= currentSize / 2) {
5301 BlockCreator newBlocks(
this);
5302 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5303 newBlocks.insertAtFront(1);
5306 BlockProctor proctor(
this,
true);
5307 DequePrimitives::emplaceAndMoveToFront(
5310 this->d_start + posIdx,
5311 this->allocatorRef(),
5321 BlockCreator newBlocks(
this);
5322 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5323 newBlocks.insertAtBack(1);
5326 BlockProctor proctor(
this,
false);
5327 DequePrimitives::emplaceAndMoveToBack(
5330 this->d_start + posIdx,
5331 this->allocatorRef(),
5340 return this->
begin() + posIdx;
5344#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 7
5345template <
class VALUE_TYPE,
class ALLOCATOR>
5346template <
class Args_01,
5353typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5354deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5366 if (position == this->
cbegin()) {
5374 return this->
begin();
5377 if (position == this->
cend()) {
5385 return iterator(this->d_finish - 1);
5389 const size_type currentSize = this->size();
5393 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5394 "deque<...>::emplace(args): deque too big");
5397 iterator pos(position.imp());
5398 const size_type posIdx = position - this->
cbegin();
5399 if (posIdx <= currentSize / 2) {
5400 BlockCreator newBlocks(
this);
5401 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5402 newBlocks.insertAtFront(1);
5405 BlockProctor proctor(
this,
true);
5406 DequePrimitives::emplaceAndMoveToFront(
5409 this->d_start + posIdx,
5410 this->allocatorRef(),
5421 BlockCreator newBlocks(
this);
5422 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5423 newBlocks.insertAtBack(1);
5426 BlockProctor proctor(
this,
false);
5427 DequePrimitives::emplaceAndMoveToBack(
5430 this->d_start + posIdx,
5431 this->allocatorRef(),
5441 return this->
begin() + posIdx;
5445#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 8
5446template <
class VALUE_TYPE,
class ALLOCATOR>
5447template <
class Args_01,
5455typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5456deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5469 if (position == this->
cbegin()) {
5478 return this->
begin();
5481 if (position == this->
cend()) {
5490 return iterator(this->d_finish - 1);
5494 const size_type currentSize = this->size();
5498 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5499 "deque<...>::emplace(args): deque too big");
5502 iterator pos(position.imp());
5503 const size_type posIdx = position - this->
cbegin();
5504 if (posIdx <= currentSize / 2) {
5505 BlockCreator newBlocks(
this);
5506 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5507 newBlocks.insertAtFront(1);
5510 BlockProctor proctor(
this,
true);
5511 DequePrimitives::emplaceAndMoveToFront(
5514 this->d_start + posIdx,
5515 this->allocatorRef(),
5527 BlockCreator newBlocks(
this);
5528 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5529 newBlocks.insertAtBack(1);
5532 BlockProctor proctor(
this,
false);
5533 DequePrimitives::emplaceAndMoveToBack(
5536 this->d_start + posIdx,
5537 this->allocatorRef(),
5548 return this->
begin() + posIdx;
5552#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 9
5553template <
class VALUE_TYPE,
class ALLOCATOR>
5554template <
class Args_01,
5563typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5564deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5578 if (position == this->
cbegin()) {
5588 return this->
begin();
5591 if (position == this->
cend()) {
5601 return iterator(this->d_finish - 1);
5605 const size_type currentSize = this->size();
5609 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5610 "deque<...>::emplace(args): deque too big");
5613 iterator pos(position.imp());
5614 const size_type posIdx = position - this->
cbegin();
5615 if (posIdx <= currentSize / 2) {
5616 BlockCreator newBlocks(
this);
5617 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5618 newBlocks.insertAtFront(1);
5621 BlockProctor proctor(
this,
true);
5622 DequePrimitives::emplaceAndMoveToFront(
5625 this->d_start + posIdx,
5626 this->allocatorRef(),
5639 BlockCreator newBlocks(
this);
5640 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5641 newBlocks.insertAtBack(1);
5644 BlockProctor proctor(
this,
false);
5645 DequePrimitives::emplaceAndMoveToBack(
5648 this->d_start + posIdx,
5649 this->allocatorRef(),
5661 return this->
begin() + posIdx;
5665#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 10
5666template <
class VALUE_TYPE,
class ALLOCATOR>
5667template <
class Args_01,
5677typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5678deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5693 if (position == this->
cbegin()) {
5704 return this->
begin();
5707 if (position == this->
cend()) {
5718 return iterator(this->d_finish - 1);
5722 const size_type currentSize = this->size();
5726 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5727 "deque<...>::emplace(args): deque too big");
5730 iterator pos(position.imp());
5731 const size_type posIdx = position - this->
cbegin();
5732 if (posIdx <= currentSize / 2) {
5733 BlockCreator newBlocks(
this);
5734 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5735 newBlocks.insertAtFront(1);
5738 BlockProctor proctor(
this,
true);
5739 DequePrimitives::emplaceAndMoveToFront(
5742 this->d_start + posIdx,
5743 this->allocatorRef(),
5757 BlockCreator newBlocks(
this);
5758 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5759 newBlocks.insertAtBack(1);
5762 BlockProctor proctor(
this,
false);
5763 DequePrimitives::emplaceAndMoveToBack(
5766 this->d_start + posIdx,
5767 this->allocatorRef(),
5780 return this->
begin() + posIdx;
5787template <
class VALUE_TYPE,
class ALLOCATOR>
5788template <
class... Args>
5789typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5790deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5796 if (position == this->
cbegin()) {
5798 return this->
begin();
5801 if (position == this->
cend()) {
5803 return iterator(this->d_finish - 1);
5807 const size_type currentSize = this->size();
5811 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5812 "deque<...>::emplace(args): deque too big");
5815 iterator pos(position.imp());
5816 const size_type posIdx = position - this->
cbegin();
5817 if (posIdx <= currentSize / 2) {
5818 BlockCreator newBlocks(
this);
5819 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5820 newBlocks.insertAtFront(1);
5823 BlockProctor proctor(
this,
true);
5824 DequePrimitives::emplaceAndMoveToFront(
5827 this->d_start + posIdx,
5828 this->allocatorRef(),
5833 BlockCreator newBlocks(
this);
5834 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5835 newBlocks.insertAtBack(1);
5838 BlockProctor proctor(
this,
false);
5839 DequePrimitives::emplaceAndMoveToBack(
5842 this->d_start + posIdx,
5843 this->allocatorRef(),
5847 return this->
begin() + posIdx;
5852template <
class VALUE_TYPE,
class ALLOCATOR>
5853void deque<VALUE_TYPE, ALLOCATOR>::pop_front()
5857 BloombergLP::bslma::DestructionUtil::destroy(this->d_start.valuePtr());
5859 if (1 == this->d_start.remainingInBlock()) {
5860 this->deallocateBlock(*this->d_start.blockPtr());
5861 this->d_start.nextBlock();
5865 this->d_start.valuePtrIncrement();
5868template <
class VALUE_TYPE,
class ALLOCATOR>
5869void deque<VALUE_TYPE, ALLOCATOR>::pop_back()
5873 if (0 == this->d_finish.offsetInBlock()) {
5875 BloombergLP::bslma::DestructionUtil::destroy(
5876 this->d_finish.valuePtr());
5877 this->deallocateBlock(this->d_finish.blockPtr()[1]);
5881 this->d_finish.valuePtrDecrement();
5882 BloombergLP::bslma::DestructionUtil::destroy(this->d_finish.valuePtr());
5885template <
class VALUE_TYPE,
class ALLOCATOR>
5886typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5887deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
5888 const VALUE_TYPE& value)
5893 if (position == this->
cbegin()) {
5895 return this->
begin();
5898 if (position == this->
cend()) {
5900 return iterator(this->d_finish - 1);
5906 const size_type currentSize = this->size();
5910 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5911 "deque<...>::insert(pos,n,v): deque too big");
5914 iterator pos(position.imp());
5915 const size_type posIdx = position - this->
cbegin();
5916 if (posIdx <= currentSize / 2) {
5917 BlockCreator newBlocks(
this);
5918 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5919 newBlocks.insertAtFront(1);
5921 DequePrimitives::insertAndMoveToFront(&this->d_start,
5923 this->d_start + posIdx,
5926 this->allocatorRef());
5929 BlockCreator newBlocks(
this);
5930 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5931 newBlocks.insertAtBack(1);
5933 DequePrimitives::insertAndMoveToBack(&this->d_finish,
5935 this->d_start + posIdx,
5938 this->allocatorRef());
5940 return this->
begin() + posIdx;
5943template <
class VALUE_TYPE,
class ALLOCATOR>
5944typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5945deque<VALUE_TYPE, ALLOCATOR>::insert(
5946 const_iterator position,
5947 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value)
5952 VALUE_TYPE& lvalue = value;
5954 if (position == this->
cbegin()) {
5955 push_front(MoveUtil::move(lvalue));
5956 return this->
begin();
5959 if (position == this->
cend()) {
5960 push_back(MoveUtil::move(lvalue));
5961 return iterator(this->d_finish - 1);
5967 const size_type currentSize = this->size();
5971 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5972 "deque<...>::insert(pos,n,v): deque too big");
5975 iterator pos(position.imp());
5976 const size_type posIdx = position - this->
cbegin();
5977 if (posIdx <= currentSize / 2) {
5978 BlockCreator newBlocks(
this);
5979 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5980 newBlocks.insertAtFront(1);
5982 DequePrimitives::moveInsertAndMoveToFront(&this->d_start,
5984 this->d_start + posIdx,
5985 MoveUtil::move(lvalue),
5986 this->allocatorRef());
5989 BlockCreator newBlocks(
this);
5990 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5991 newBlocks.insertAtBack(1);
5993 DequePrimitives::moveInsertAndMoveToBack(&this->d_finish,
5995 this->d_start + posIdx,
5996 MoveUtil::move(lvalue),
5997 this->allocatorRef());
5999 return this->
begin() + posIdx;
6002template <
class VALUE_TYPE,
class ALLOCATOR>
6003typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6004deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
6005 size_type numElements,
6006 const VALUE_TYPE& value)
6011 const size_type posIdx = position - this->
cbegin();
6013 if (0 == numElements) {
6014 return this->
begin() + posIdx;
6017 const size_type currentSize = this->size();
6019 numElements > max_size() - currentSize)) {
6022 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
6023 "deque<...>::insert(pos,n,v): deque too big");
6026 if (position == this->
cbegin()) {
6027 privatePrependRaw(numElements, value);
6029 return this->
begin();
6032 if (position == this->
cend()) {
6033 privateAppendRaw(numElements, value);
6035 return this->
begin() + posIdx;
6038 if (posIdx <= currentSize / 2) {
6042 size_type numNewBlocks = (this->d_start.remainingInBlock()
6043 + numElements - 1) / BLOCK_LENGTH;
6044 BlockCreator newBlocks(
this);
6045 newBlocks.insertAtFront(numNewBlocks);
6047 DequePrimitives::insertAndMoveToFront(&this->d_start,
6049 this->d_start + posIdx,
6052 this->allocatorRef());
6058 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements)
6060 BlockCreator newBlocks(
this);
6061 newBlocks.insertAtBack(numNewBlocks);
6063 DequePrimitives::insertAndMoveToBack(&this->d_finish,
6065 this->d_start + posIdx,
6068 this->allocatorRef());
6071 return this->
begin() + posIdx;
6074template <
class VALUE_TYPE,
class ALLOCATOR>
6075template <
class INPUT_ITERATOR>
6077typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6078deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
6079 INPUT_ITERATOR first,
6080 INPUT_ITERATOR last)
6085 const size_type posIdx = position - this->
cbegin();
6087 privateInsertDispatch(position,
6091 BloombergLP::bslmf::Nil());
6093 return this->
begin() + posIdx;
6096#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6097template <
class VALUE_TYPE,
class ALLOCATOR>
6099typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6100deque<VALUE_TYPE, ALLOCATOR>::insert(
6101 const_iterator position,
6102 std::initializer_list<value_type> values)
6107 return insert(position, values.begin(), values.end());
6111template <
class VALUE_TYPE,
class ALLOCATOR>
6112typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6113deque<VALUE_TYPE, ALLOCATOR>::erase(const_iterator position)
6118 if (position == const_iterator(this->d_start)) {
6120 return this->
begin();
6123 if (position + 1 == const_iterator(this->d_finish)) {
6128 return erase(position, position + 1);
6131template <
class VALUE_TYPE,
class ALLOCATOR>
6132typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6133deque<VALUE_TYPE, ALLOCATOR>::erase(const_iterator first, const_iterator last)
6140 iterator first_imp = this->
begin() + (first - this->
cbegin());
6141 iterator last_imp = this->
begin() + (last - this->
cbegin());
6142 iterator oldStart = this->
begin();
6143 iterator oldFinish = this->
end();
6144 iterator result = iterator(DequePrimitives::erase(&this->d_start,
6150 this->allocatorRef()));
6154 for ( ; oldStart.imp().blockPtr() != this->d_start.blockPtr();
6155 oldStart.imp().nextBlock()) {
6156 this->deallocateBlock(oldStart.imp().blockPtr()[0]);
6158 for ( ; oldFinish.imp().blockPtr() != this->d_finish.blockPtr();
6159 oldFinish.imp().previousBlock()) {
6160 this->deallocateBlock(oldFinish.imp().blockPtr()[0]);
6165template <
class VALUE_TYPE,
class ALLOCATOR>
6166void deque<VALUE_TYPE, ALLOCATOR>::swap(deque<VALUE_TYPE, ALLOCATOR>& other)
6168 AllocatorTraits::is_always_equal::value)
6171 AllocatorTraits::propagate_on_container_swap Propagate;
6172 if (Propagate::value) {
6173 Deque_Util::swap(
static_cast<Base *
>(
this),
6174 static_cast<Base *
>(&other));
6175 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
6180 this->get_allocator() == other.get_allocator())) {
6181 Deque_Util::swap(
static_cast<Base *
>(
this),
6182 static_cast<Base *
>(&other));
6187 deque toOtherCopy(MoveUtil::move(*
this), other.get_allocator());
6188 deque toThisCopy( MoveUtil::move(other), this->get_allocator());
6190 Deque_Util::swap(
static_cast<Base *
>(&toThisCopy),
6191 static_cast<Base *
>(
this));
6192 Deque_Util::swap(
static_cast<Base *
>(&toOtherCopy),
6193 static_cast<Base *
>(&other));
6198template <
class VALUE_TYPE,
class ALLOCATOR>
6201 DequePrimitives::destruct(this->d_start,
6203 this->allocatorRef());
6207 BlockPtr *startBlock = this->d_start.blockPtr();
6208 BlockPtr *finishBlock = this->d_finish.blockPtr();
6209 for ( ; startBlock != finishBlock; ++startBlock) {
6210 this->deallocateBlock(*startBlock);
6215 size_type blockOffset = this->d_blocksLength / 2;
6216 int offset = BLOCK_LENGTH / 2;
6217 BlockPtr *blockPtr = this->d_blocks_p + blockOffset;
6219 *blockPtr = *finishBlock;
6221 this->d_start = this->d_finish = IteratorImp(blockPtr,
6222 (*blockPtr)->d_data + offset);
6226template <
class VALUE_TYPE,
class ALLOCATOR>
6228typename deque<VALUE_TYPE, ALLOCATOR>::allocator_type
6231 return this->allocatorRef();
6234template <
class VALUE_TYPE,
class ALLOCATOR>
6236typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6239 return AllocatorTraits::max_size(this->get_allocator());
6243template <
class VALUE_TYPE,
class ALLOCATOR>
6244bool operator==(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6245 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6247 if (lhs.size() != rhs.size()) {
6252 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
6255 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
6256 BLOCK_LENGTH> Iterator;
6258 Iterator lhsBegin = lhs.begin().imp();
6259 Iterator lhsEnd = lhs.end().imp();
6260 Iterator rhsBegin = rhs.begin().imp();
6262 for (; !(lhsBegin == lhsEnd); ++lhsBegin, ++rhsBegin) {
6263 if (!(*lhsBegin == *rhsBegin)) {
6270#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6272template <
class VALUE_TYPE,
class ALLOCATOR>
6274bool operator!=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6275 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6277 return !(lhs == rhs);
6282#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
6284template <
class VALUE_TYPE,
class ALLOCATOR>
6286BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
6287 const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6288 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6290 return bsl::lexicographical_compare_three_way(
6295 BloombergLP::bslalg::SynthThreeWayUtil::compare);
6300template <
class VALUE_TYPE,
class ALLOCATOR>
6302bool operator<(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6303 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6305 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
6313template <
class VALUE_TYPE,
class ALLOCATOR>
6315bool operator>(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6316 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6321template <
class VALUE_TYPE,
class ALLOCATOR>
6323bool operator<=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6324 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6326 return !(rhs < lhs);
6329template <
class VALUE_TYPE,
class ALLOCATOR>
6331bool operator>=(
const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6332 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6334 return !(lhs < rhs);
6340template <
class VALUE_TYPE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
6341inline typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6342erase(deque<VALUE_TYPE, ALLOCATOR>& deq,
const BDE_OTHER_TYPE& value)
6344 typename deque<VALUE_TYPE, ALLOCATOR>::size_type oldSize = deq.
size();
6345 deq.erase(bsl::remove(deq.begin(), deq.end(), value), deq.end());
6346 return oldSize - deq.size();
6349template <
class VALUE_TYPE,
class ALLOCATOR,
class PREDICATE>
6350inline typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6351erase_if(deque<VALUE_TYPE, ALLOCATOR>& deq, PREDICATE predicate)
6353 typename deque<VALUE_TYPE, ALLOCATOR>::size_type oldSize = deq.
size();
6354 deq.erase(bsl::remove_if(deq.begin(), deq.end(), predicate), deq.end());
6355 return oldSize - deq.size();
6358template <
class VALUE_TYPE,
class ALLOCATOR>
6360void swap(deque<VALUE_TYPE, ALLOCATOR>& a, deque<VALUE_TYPE, ALLOCATOR>& b)
6372template <
class VALUE_TYPE,
class ALLOCATOR>
6374Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::Deque_BlockCreator(
6375 deque<VALUE_TYPE, ALLOCATOR> *deque)
6381template <
class VALUE_TYPE,
class ALLOCATOR>
6382Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::~Deque_BlockCreator()
6384 if (0 != d_boundary_p) {
6385 BlockPtr *delFirst, *delLast;
6386 if (d_boundary_p <= d_deque_p->d_start.blockPtr()) {
6387 delFirst = d_boundary_p;
6388 delLast = d_deque_p->d_start.blockPtr();
6391 delFirst = d_deque_p->d_finish.blockPtr() + 1;
6392 delLast = d_boundary_p;
6395 for (; delFirst != delLast; ++delFirst) {
6397 d_deque_p->deallocateBlock(*delFirst);
6403template <
class VALUE_TYPE,
class ALLOCATOR>
6404void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::insertAtFront(size_type n)
6406 d_boundary_p = reserveBlockSlots(n,
true);
6407 for ( ; n > 0; --n) {
6408 d_boundary_p[-1] = d_deque_p->allocateBlock();
6414template <
class VALUE_TYPE,
class ALLOCATOR>
6415void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::insertAtBack(size_type n)
6417 d_boundary_p = reserveBlockSlots(n,
false);
6418 for ( ; n > 0; --n) {
6419 *d_boundary_p = d_deque_p->allocateBlock();
6424template <
class VALUE_TYPE,
class ALLOCATOR>
6425typename Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::BlockPtr *
6426Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::reserveBlockSlots(
6427 size_type numNewBlocks,
6430 BlockPtr *blocks = d_deque_p->d_blocks_p;
6431 size_type blocksLength = d_deque_p->d_blocksLength;
6433 BlockPtr *firstSlot = d_deque_p->d_start.blockPtr();
6434 BlockPtr *lastSlot = d_deque_p->d_finish.blockPtr() + 1;
6438 firstSlot = d_boundary_p;
6440 if (size_type(firstSlot - blocks) >= numNewBlocks) {
6448 lastSlot = d_boundary_p;
6450 if (size_type(blocks + blocksLength - lastSlot) >= numNewBlocks) {
6457 BlockPtr *newBlocks = blocks;
6458 size_type newBlocksLength = blocksLength;
6459 size_type numUsedBlocks = lastSlot - firstSlot;
6460 size_type blockOffsetStart = d_deque_p->d_start.blockPtr() - firstSlot;
6461 size_type numCommittedBlocks = (d_deque_p->d_finish.blockPtr() -
6462 d_deque_p->d_start.blockPtr() + 1);
6463 size_type newNumUsedBlocks = numUsedBlocks + numNewBlocks;
6465 if (newNumUsedBlocks > blocksLength) {
6466 const size_type newThreshold = newNumUsedBlocks +
6467 2 * Imp::BLOCK_ARRAY_PADDING;
6468 while (newThreshold > newBlocksLength) {
6474 newBlocksLength *= 2;
6476 newBlocks = d_deque_p->allocateBlockPtrs(newBlocksLength);
6481 BlockPtr *newFirstSlot = newBlocks +
6482 (newBlocksLength - newNumUsedBlocks) / 2;
6485 newFirstSlot += numNewBlocks;
6491 const size_type offsetStart = d_deque_p->d_start.offsetInBlock();
6492 const size_type offsetFinish = d_deque_p->d_finish.offsetInBlock();
6496 std::memmove(newFirstSlot, firstSlot, numUsedBlocks *
sizeof(BlockPtr));
6498 if (newBlocks != blocks) {
6502 d_deque_p->deallocateBlockPtrs(blocks, d_deque_p->d_blocksLength);
6504 d_deque_p->d_blocks_p = newBlocks;
6505 d_deque_p->d_blocksLength = newBlocksLength;
6510 d_deque_p->d_start.setBlock(newFirstSlot + blockOffsetStart);
6511 d_deque_p->d_start += offsetStart;
6512 d_deque_p->d_finish.setBlock(newFirstSlot + blockOffsetStart +
6513 numCommittedBlocks - 1);
6514 d_deque_p->d_finish += offsetFinish;
6516 BlockPtr *ret = newFirstSlot;
6518 ret += numUsedBlocks;
6524template <
class VALUE_TYPE,
class ALLOCATOR>
6526void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::release()
6536template <
class VALUE_TYPE,
class ALLOCATOR>
6537Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::Deque_BlockProctor(
6538 deque<VALUE_TYPE, ALLOCATOR> *deque,
6541, d_boundary_p(atFront
6542 ? d_deque_p->d_start.blockPtr()
6543 : d_deque_p->d_finish.blockPtr())
6548template <
class VALUE_TYPE,
class ALLOCATOR>
6549Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::~Deque_BlockProctor()
6551 if (0 != d_deque_p) {
6552 BlockPtr *delFirst, *delLast;
6554 if (d_atFront && d_boundary_p < d_deque_p->d_start.blockPtr()) {
6558 delFirst = d_boundary_p;
6559 delLast = d_deque_p->d_start.blockPtr();
6561 else if (!d_atFront && d_boundary_p > d_deque_p->d_finish.blockPtr()) {
6565 delFirst = d_deque_p->d_finish.blockPtr() + 1;
6566 delLast = d_boundary_p + 1;
6572 for (; delFirst != delLast; ++delFirst) {
6575 d_deque_p->deallocateBlock(*delFirst);
6581template <
class VALUE_TYPE,
class ALLOCATOR>
6583void Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::release()
6593template <
class VALUE_TYPE,
class ALLOCATOR>
6595Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::Deque_ClearGuard(
6596 deque<VALUE_TYPE, ALLOCATOR> *deque)
6601template <
class VALUE_TYPE,
class ALLOCATOR>
6603Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::~Deque_ClearGuard()
6611template <
class VALUE_TYPE,
class ALLOCATOR>
6613void Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::release()
6623template <
class VALUE_TYPE,
class ALLOCATOR>
6625Deque_Guard<VALUE_TYPE, ALLOCATOR>::Deque_Guard(
6626 deque<VALUE_TYPE, ALLOCATOR> *deque,
6634template <
class VALUE_TYPE,
class ALLOCATOR>
6635Deque_Guard<VALUE_TYPE, ALLOCATOR>::~Deque_Guard()
6644 begin = d_deque_p->d_finish;
6648 end = d_deque_p->d_start;
6652 DequePrimitives::destruct(begin, end, d_deque_p->get_allocator());
6656template <
class VALUE_TYPE,
class ALLOCATOR>
6658std::size_t Deque_Guard<VALUE_TYPE, ALLOCATOR>::operator++()
6663template <
class VALUE_TYPE,
class ALLOCATOR>
6665std::size_t Deque_Guard<VALUE_TYPE, ALLOCATOR>::operator--()
6670template <
class VALUE_TYPE,
class ALLOCATOR>
6672void Deque_Guard<VALUE_TYPE, ALLOCATOR>::release()
6678template <
class VALUE_TYPE,
class ALLOCATOR>
6686template <
class VALUE_TYPE,
class ALLOCATOR>
6688typename Deque_Guard<VALUE_TYPE, ALLOCATOR>::IteratorImp
6691 return d_deque_p->d_start - d_count;
6694template <
class VALUE_TYPE,
class ALLOCATOR>
6696typename Deque_Guard<VALUE_TYPE, ALLOCATOR>::IteratorImp
6699 return d_deque_p->d_finish + d_count;
6719template <
class VALUE_TYPE,
class ALLOCATOR>
6728template <
class VALUE_TYPE,
class ALLOCATOR>
6729struct IsBitwiseMoveable<
bsl::deque<VALUE_TYPE, ALLOCATOR> >
6730 : IsBitwiseMoveable<ALLOCATOR>
6738template <
class VALUE_TYPE,
class ALLOCATOR>
6739struct UsesBslmaAllocator<
bsl::deque<VALUE_TYPE, ALLOCATOR> >
6749# error Not valid except when included from bslstl_deque.h
IteratorImp d_finish
Definition bslstl_deque.h:625
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2066
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:1940
reference back()
Definition bslstl_deque.h:1997
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:1948
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements contained by this deque.
Definition bslstl_deque.h:2074
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2018
bsl::reverse_iterator< Iterator > reverse_iterator
Definition bslstl_deque.h:617
std::size_t d_blocksLength
Definition bslstl_deque.h:623
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:1956
bsl::reverse_iterator< ConstIterator > const_reverse_iterator
Definition bslstl_deque.h:618
reference front()
Definition bslstl_deque.h:1987
BlockPtr * d_blocks_p
Definition bslstl_deque.h:622
Iterator iterator
Definition bslstl_deque.h:604
ConstIterator const_iterator
Definition bslstl_deque.h:605
VALUE_TYPE value_type
Definition bslstl_deque.h:608
iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:1932
const VALUE_TYPE & const_reference
Definition bslstl_deque.h:603
size_type capacity() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2081
std::size_t size_type
Definition bslstl_deque.h:606
reference at(size_type position)
Definition bslstl_deque.h:1973
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2034
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2120
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2050
VALUE_TYPE & reference
Definition bslstl_deque.h:602
IteratorImp d_start
Definition bslstl_deque.h:624
std::ptrdiff_t difference_type
Definition bslstl_deque.h:607
Definition bslma_bslallocator.h:580
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
static const t_TYPE value
Definition bslmf_integralconstant.h:258
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:635
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:289
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
bool operator<(const MetricId &lhs, const MetricId &rhs)
void resize(TYPE *array, int newSize)
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
TransformIterator< FUNCTOR, ITERATOR > operator--(TransformIterator< FUNCTOR, ITERATOR > &iterator, int)
bool operator>=(const Guid &lhs, const Guid &rhs)
FunctionOutputIterator< FUNCTION > & operator++(FunctionOutputIterator< FUNCTION > &iterator)
Do nothing and return specified iterator.
Definition bdlb_functionoutputiterator.h:405
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
Definition bdlb_printmethods.h:283
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1611
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4126
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1553
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4135
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1279
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
@ DEFAULT_BLOCK_SIZE
Definition bslstl_deque.h:534
@ BLOCK_LENGTH
Definition bslstl_deque.h:536
static void swap(void *a, void *b)
static void move(void *dst, void *src)
Definition bslma_allocatortraits.h:1061
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1165
Definition bslmf_isconvertible.h:867
t_TYPE type
Definition bslmf_typeidentity.h:216