BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_deque_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_deque_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_deque_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_DEQUE_CPP03
12#define INCLUDED_BSLSTL_DEQUE_CPP03
13
14/// @defgroup bslstl_deque_cpp03 bslstl_deque_cpp03
15/// @brief Provide C++03 implementation for bslstl_deque.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_deque_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_deque_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_deque_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_deque_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_deque_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_deque.h
30///
31/// # Classes {#bslstl_deque_cpp03-classes}
32/// See bslstl_deque.h for list of classes
33///
34/// @see bslstl_deque
35///
36/// # Description {#bslstl_deque_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Thu Mar 12 11:34:18 2026
48/// Command line: sim_cpp11_features.pl bslstl_deque.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_deque_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_DEQUE_H
64
65namespace bsl {
66
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>
74class Deque_Guard;
75
76 // ================================
77 // struct Deque_BlockLengthCalcUtil
78 // ================================
79
80/// This `struct` provides a namespace for the calculation of block length
81/// (the number of elements per block within a `deque`). This ensures that
82/// each block in the deque can hold at least 16 elements.
83///
84/// See @ref bslstl_deque_cpp03
85template <class VALUE_TYPE>
86struct Deque_BlockLengthCalcUtil {
87
88 // TYPES
89 enum {
90 DEFAULT_BLOCK_SIZE = 200, // number of bytes per block
91
92 BLOCK_LENGTH = (16 * sizeof(VALUE_TYPE) >= DEFAULT_BLOCK_SIZE)
93 ? 16
94 : (DEFAULT_BLOCK_SIZE / sizeof(VALUE_TYPE))
95 // number of elements per block
96 };
97};
98
99 // =================
100 // struct Deque_Util
101 // =================
102
103/// This `struct` provides a namespace to implement the `swap` member
104/// function of `deque<VALUE_TYPE, ALLOCATOR>`. This function can be
105/// implemented irrespective of the `VALUE_TYPE` or `ALLOCATOR` template
106/// parameters, which is why we implement it in this non-parameterized,
107/// non-inlined utility.
108///
109/// See @ref bslstl_deque_cpp03
110struct Deque_Util {
111
112 // CLASS METHODS
113
114 /// Assign the value of the specified `dst` deque to that of the
115 /// specified `src` deque, and reset the `src` deque to a raw state.
116 static void move(void *dst, void *src);
117
118 /// Exchange the value of the specified `a` deque with that of the
119 /// specified `b` deque.
120 static void swap(void *a, void *b);
121};
122
123 // ================
124 // class Deque_Base
125 // ================
126
127/// This class describes the basic layout for a deque class. It is
128/// important that this class has the same layout as the deque class
129/// implementation. It is parameterized by `VALUE_TYPE` only and implements
130/// the portion of `bsl::deque` that does not need to know about its
131/// (template parameter) type `ALLOCATOR` (in order to generate shorter debug strings).
132///
133/// \note Note that this class must have the same layout as
134/// `Deque_Imp` (see implementation file).
135///
136/// See @ref bslstl_deque_cpp03
137template <class VALUE_TYPE>
138class Deque_Base {
139
140 // PRIVATE TYPES
141 enum {
143 };
144
145 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
146 BLOCK_LENGTH> Imp;
147 typedef typename Imp::Block Block;
148 typedef typename Imp::BlockPtr BlockPtr;
149 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
150 BLOCK_LENGTH> IteratorImp;
151 typedef BloombergLP::
152 bslstl::RandomAccessIterator<VALUE_TYPE, IteratorImp>
153 Iterator;
154
155 typedef BloombergLP::
156 bslstl::RandomAccessIterator<const VALUE_TYPE, IteratorImp>
157 ConstIterator;
158
159 public:
160 // PUBLIC TYPES
161 typedef VALUE_TYPE& reference;
162 typedef const VALUE_TYPE& const_reference;
163 typedef Iterator iterator;
164 typedef ConstIterator const_iterator;
165 typedef std::size_t size_type;
166 typedef std::ptrdiff_t difference_type;
167 typedef VALUE_TYPE value_type;
168
169 // For consistent behavior on all compilers, we must 'bsl::'-qualify
170 // @ref reverse_iterator . (For most compilers, @ref reverse_iterator is in
171 // namespace 'std', and NOT in namespace 'bsl'. Hence, we need to
172 // actively look into a different namespace to find the iterator. However,
173 // on Solaris we explicitly provide a @ref reverse_iterator implementation, IN
174 // namespace 'bsl', to replace their broken one. See 'bslstl_iterator.h'.)
175
176 typedef bsl::reverse_iterator<Iterator> reverse_iterator;
177 typedef bsl::reverse_iterator<ConstIterator> const_reverse_iterator;
178
179 protected:
180 // PROTECTED DATA
181 BlockPtr *d_blocks_p; // array of pointer to blocks (owned)
182 std::size_t d_blocksLength; // length of 'd_blocks_p' array
183 IteratorImp d_start; // iterator to first element
184 IteratorImp d_finish; // iterator to one past last element
185
186 public:
187 // MANIPULATORS
188
189 // *** iterators ***
190
191 /// Return an iterator providing modifiable access to the first element
192 /// in this deque, and the past-the-end iterator if this deque is empty.
194
195 /// Return the past-the-end (forward) iterator providing modifiable
196 /// access to this deque.
198
199 /// Return a reverse iterator providing modifiable access to the last
200 /// element in this deque, and the past-the-end reverse iterator if this
201 /// deque is empty.
203
204 /// Return the past-the-end reverse iterator providing modifiable access
205 /// to this deque.
207
208 // *** element access ***
209
210 /// Return a reference providing modifiable access to the element at the
211 /// specified `position` in this deque.
212 ///
213 /// \pre The behavior is undefined unless `position < size()`.
214 reference operator[](size_type position);
215
216 /// Return a reference providing modifiable access to the element at the
217 /// specified `position` in this deque. Throw a `std::out_of_range`
218 /// exception if `position >= size()`.
219 reference at(size_type position);
220
221 /// Return a reference providing modifiable access to the first element in this deque.
222 ///
223 /// \pre The behavior is undefined unless this deque is not
224 /// empty.
226
227 /// Return a reference providing modifiable access to the last element in this deque.
228 ///
229 /// \pre The behavior is undefined unless this deque is not
230 /// empty.
231 reference back();
232
233 // ACCESSORS
234
235 // *** iterators ***
236
238
239 /// Return an iterator providing non-modifiable access to the first
240 /// element in this deque, and the past-the-end iterator if this deque
241 /// is empty.
243
245
246 /// Return the past-the-end (forward) iterator providing non-modifiable
247 /// access to this deque.
249
251
252 /// Return a reverse iterator providing non-modifiable access to the
253 /// last element in this deque, and the past-the-end reverse iterator if
254 /// this deque is empty.
256
258
259 /// Return the past-the-end reverse iterator providing non-modifiable
260 /// access to this deque.
262
263 // *** capacity ***
264
265 /// Return the number of elements contained by this deque.
267
268 /// Return the sum of the current size of this deque plus the minimum
269 /// number of `push_front` or `push_back` operations needed to invalidate iterators in this deque.
270 ///
271 /// \note Note that this method is not
272 /// part of the C++ standard.
274
275 /// Return `true` if this deque contains no elements, and `false`
276 /// otherwise.
277 bool empty() const BSLS_KEYWORD_NOEXCEPT;
278
279 // *** element access ***
280
281 /// Return a reference providing non-modifiable access to the element at
282 /// the specified `position` in this deque.
283 ///
284 /// \pre The behavior is undefined unless `position < size()`.
285 const_reference operator[](size_type position) const;
286
287 /// Return a reference providing non-modifiable access to the element at
288 /// the specified `position` in this deque. Throw a `std::out_of_range`
289 /// exception if `position >= size()`.
290 const_reference at(size_type position) const;
291
292 /// Return a reference providing non-modifiable access to the first element in this deque.
293 ///
294 /// \pre The behavior is undefined unless this deque
295 /// is not empty.
296 const_reference front() const;
297
298 /// Return a reference providing non-modifiable access to the last element in this deque.
299 ///
300 /// \pre The behavior is undefined unless this deque
301 /// is not empty.
302 const_reference back() const;
303};
304
305 // ===========
306 // class deque
307 // ===========
308
309/// This class template provides an STL-compliant `deque` that conforms to
310/// the `bslma::Allocator` model. For the requirements of a deque class,
311/// consult the C++11 standard. In particular, this implementation offers
312/// the general rules that:
313/// 1. A call to any method that would result in a deque having a size
314/// greater than the value returned by @ref max_size triggers a call to
315/// `bslstl::StdExceptUtil::throwLengthError`.
316/// 2. A call to an `at` method that attempts to access a position
317/// outside of the valid range of a deque triggers a call to
318/// `bslstl::StdExceptUtil::throwOutOfRange`.
319///
320///
321/// \note Note that portions of the standard methods are implemented in
322/// `Deque_Base`, which is parameterized on only `VALUE_TYPE` in order to
323/// generate smaller debug strings.
324///
325/// This class:
326/// * supports a complete set of *value-semantic* operations
327/// - except for `BDEX` serialization
328/// * is *exception-neutral*
329/// * is *alias-safe*
330/// * is `const` *thread-safe*
331/// For terminology see @ref bsldoc_glossary .
332///
333/// In addition, the following members offer a full guarantee of rollback:
334/// if an exception is thrown during the invocation of `insert`,
335/// `push_front`, or `push_back` on a pre-existing object, the object is
336/// left in a valid state and its value is unchanged.
337template <class VALUE_TYPE, class ALLOCATOR = allocator<VALUE_TYPE> >
338class deque : public Deque_Base<VALUE_TYPE>
339 , private BloombergLP::bslalg::ContainerBase<ALLOCATOR> {
340
341 // PRIVATE TYPES
342 enum {
344 };
345
346 typedef Deque_Base<VALUE_TYPE> Base;
347
348 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
349
350 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
351 BLOCK_LENGTH> Imp;
352 typedef typename Imp::Block Block;
353 typedef typename Imp::BlockPtr BlockPtr;
354
355 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
356 BLOCK_LENGTH> IteratorImp;
357
358 typedef BloombergLP::
359 bslstl::RandomAccessIterator<VALUE_TYPE,
360 IteratorImp> Iterator;
361
362 typedef BloombergLP::
363 bslstl::RandomAccessIterator<const VALUE_TYPE,
364 IteratorImp> ConstIterator;
365
366 typedef Deque_BlockCreator<VALUE_TYPE, ALLOCATOR> BlockCreator;
367 typedef Deque_BlockProctor<VALUE_TYPE, ALLOCATOR> BlockProctor;
368 typedef Deque_ClearGuard<VALUE_TYPE, ALLOCATOR> ClearGuard;
369 typedef Deque_Guard<VALUE_TYPE, ALLOCATOR> Guard;
370
371 typedef BloombergLP::bslalg::DequePrimitives<VALUE_TYPE,
372 BLOCK_LENGTH> DequePrimitives;
373
374 typedef BloombergLP::bslma::AllocatorUtil AllocatorUtil;
375 typedef bsl::allocator_traits<ALLOCATOR> AllocatorTraits;
376
377 /// This typedef is a convenient alias for the utility associated with
378 /// movable references.
379 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
380
381 /// Special type (and value) used to create a "raw" deque, which has a
382 /// block length of 0, and null start and finish pointers.
383 enum RawInit { k_RAW_INIT = 0 };
384
385 public:
386 // PUBLIC TYPES
387 typedef VALUE_TYPE& reference;
388 typedef const VALUE_TYPE& const_reference;
389 typedef Iterator iterator;
390 typedef ConstIterator const_iterator;
391 typedef std::size_t size_type;
392 typedef std::ptrdiff_t difference_type;
393 typedef VALUE_TYPE value_type;
394
395 typedef ALLOCATOR allocator_type;
396 typedef typename AllocatorTraits::pointer pointer;
397 typedef typename AllocatorTraits::const_pointer const_pointer;
398
399 // As above, we must 'bsl::'-qualify @ref reverse_iterator .
400
401 typedef bsl::reverse_iterator<Iterator> reverse_iterator;
402 typedef bsl::reverse_iterator<ConstIterator> const_reverse_iterator;
403
404 private:
405 // STATIC ASSERTIONS
406
409 typename Base::const_reference>::value));
410 // These need not necessarily be true as per the C++ standard, but are
411 // safe assumptions for this implementation and allow us to implement
412 // the element access within the 'Base' type (that is parameterized by
413 // 'VALUE_TYPE' only).
414
415 // PRIVATE CREATORS
416
417 /// Create a "raw" deque (i.e., a deque that obeys the raw deque
418 /// invariants and is destructible) that uses the specified `allocator`
419 /// to supply memory. The following holds for a raw deque:
420 /// `0 == d_blocks_p`, `0 == d_blocksLength`, and `d_start` and
421 /// `d_finish` are singular iterators (i.e., have null internal pointers).
422 ///
423 /// \note Note that the constructed deque contains no allocated
424 /// storage. Also note that the purpose of a raw deque is to provide an
425 /// exception-safe repository for intermediate calculations.
426 deque(RawInit, const allocator_type& allocator);
427
428 // PRIVATE MANIPULATORS
429
430 /// Return one block allocated from this object's allocator.
431 ///
432 /// \note Note that the block is not initialized.
433 Block *allocateBlock();
434
435 /// Allocate an array having the specified `n` elements of type `BlockPtr` from this object's allocator.
436 ///
437 /// \note Note that the array
438 /// elements are not initialized.
439 BlockPtr *allocateBlockPtrs(std::size_t n);
440
441 /// Deallocate from this object's allocator the block at the specified `p` address.
442 ///
443 /// \note Note that this function does not call any destructors
444 /// on `p` or `*p`.
445 void deallocateBlock(Block *p);
446
447 /// Deallocate from this object's allocator an array at the specified
448 /// `p` address having the specified `n` elements of type `BlockPtr`.
449 ///
450 /// \note Note that if any of the array elements point to an allocated block,
451 /// then that block is not deallocated (and might be leaked).
452 void deallocateBlockPtrs(BlockPtr *p, std::size_t n);
453
454 /// Append the elements in the range specified by `[first .. last)` to
455 /// this deque, and return the number of elements appended.
456 ///
457 /// \pre The behavior is undefined unless `first` and `last` refer to a sequence of valid
458 /// values where `first` is at a position at or before `last`.
459 template <class INPUT_ITERATOR, class SENTINEL>
460 size_type privateAppend(INPUT_ITERATOR first, SENTINEL last);
461
462 /// Append the elements in the range specified by `[first .. last)` to
463 /// this deque, and return the number of elements appended. The third
464 /// argument is used for overload resolution.
465 ///
466 /// \pre The behavior is undefined unless `first` and `last` refer to a sequence of valid values where
467 /// `first` is at a position at or before `last`.
468 template <class INPUT_ITERATOR, class SENTINEL>
469 size_type privateAppend(INPUT_ITERATOR first,
470 SENTINEL last,
471 std::input_iterator_tag);
472 template <class INPUT_ITERATOR, class SENTINEL>
473 size_type privateAppend(INPUT_ITERATOR first,
474 SENTINEL last,
475 std::random_access_iterator_tag);
476
477 /// Append the specified `numElements` value-inititalized objects to
478 /// this deque.
479 void privateAppendDefaultInsertable(size_type numElements);
480
481 /// Append the specified `numElements` copies of the specified `value`
482 /// to this deque.
483 void privateAppendRaw(size_type numElements, const VALUE_TYPE& value);
484
485 /// Assign the elements in the range specified by `[first .. last)` to this
486 /// deque.
487 template <class t_ITERATOR, class t_SENTINEL>
488 void privateAssign(t_ITERATOR first, t_SENTINEL last);
489
490 /// Initialize `d_start` and `d_finish` for eventual insertion of the
491 /// specified `numElements` elements. After this method returns, this
492 /// object is fully constructed with memory allocated for `numElements`,
493 /// with all member variables obeying the class invariants, and with size 0.
494 ///
495 /// \pre The behavior is undefined unless this object is in a "raw" state.
496 ///
497 /// \note Note that this method must not be called while constructing
498 /// this object (although a constructor may call it for a temporary
499 /// object).
500 void privateInit(size_type numElements);
501
502 /// Insert the specified `numElements` copies of the specified `value`
503 /// into this deque at the specified `position`. This overload matches
504 /// `privateInsert` when the second and third arguments are of the same
505 /// type which happens to be an integral type. The fourth and fifth
506 /// arguments are used for overload resolution only.
507 template <class INTEGER_TYPE>
508 void privateInsertDispatch(
509 const_iterator position,
510 INTEGER_TYPE numElements,
511 INTEGER_TYPE value,
512 BloombergLP::bslmf::MatchArithmeticType,
513 BloombergLP::bslmf::Nil);
514
515 /// Insert the elements in the range specified by `[first .. last)` into
516 /// this deque at the specified `position`. The third and fourth
517 /// arguments are used for overload resolution only, so that this
518 /// function is not called if `first` and `last` are of integral type.
519 ///
520 /// \pre The behavior is undefined unless `first` and `last` refer to a
521 /// sequence of valid values where `first` is at a position at or before
522 /// `last`.
523 template <class INPUT_ITERATOR>
524 void privateInsertDispatch(const_iterator position,
525 INPUT_ITERATOR first,
526 INPUT_ITERATOR last,
527 BloombergLP::bslmf::MatchAnyType,
528 BloombergLP::bslmf::MatchAnyType);
529
530 /// Insert the elements in the range specified by `[first .. last)` into
531 /// this deque at the specified `position`.
532 template <class INPUT_ITERATOR, class SENTINEL>
533 void privateInsert(const_iterator position,
534 INPUT_ITERATOR first,
535 SENTINEL last);
536
537 /// Specialized insertion for input iterators.
538 template <class INPUT_ITERATOR, class SENTINEL>
539 void privateInsert(const_iterator position,
540 INPUT_ITERATOR first,
541 SENTINEL last,
542 std::input_iterator_tag);
543
544 /// Specialized insertion for forward, bidirectional, and random-access
545 /// iterators.
546 template <class INPUT_ITERATOR, class SENTINEL>
547 void privateInsert(const_iterator position,
548 INPUT_ITERATOR first,
549 SENTINEL last,
550 std::random_access_iterator_tag);
551
552 /// Join `*this` and the specified `other` deque into one. After the
553 /// join, `*this` contains the concatenated sequence, in order, of
554 /// `*other` and `*this` elements, and 'other is made a raw deque.
555 void privateJoinPrepend(deque *other);
556
557 /// Join `*this` and the specified `other` deque into one. After the
558 /// join, `*this` contains the concatenated sequence, in order, of
559 /// `*this` and `*other` elements, and 'other is made a raw deque.
560 void privateJoinAppend(deque *other);
561
562 /// Prepend the elements in the range specified by `[first .. last)` to
563 /// this deque, and return the number of elements prepended.
564 ///
565 /// \pre The behavior is undefined unless `first` and `last` refer to a sequence of valid
566 /// values where `first` is at a position at or before `last`.
567 template <class INPUT_ITERATOR, class SENTINEL>
568 size_type privatePrepend(INPUT_ITERATOR first, SENTINEL last);
569
570 /// Prepend the elements in the range specified by `[first .. last)` to
571 /// this deque, and return the number of elements prepended. The third
572 /// argument is used for overload resolution only.
573 ///
574 /// \pre The behavior is undefined unless `first` and `last` refer to a sequence of valid
575 /// values where `first` is at a position at or before `last`.
576 template <class INPUT_ITERATOR, class SENTINEL>
577 size_type privatePrepend(INPUT_ITERATOR first,
578 SENTINEL last,
579 std::input_iterator_tag);
580 template <class INPUT_ITERATOR, class SENTINEL>
581 size_type privatePrepend(INPUT_ITERATOR first,
582 SENTINEL last,
583 std::bidirectional_iterator_tag);
584 template <class INPUT_ITERATOR, class SENTINEL>
585 size_type privatePrepend(INPUT_ITERATOR first,
586 SENTINEL last,
587 std::random_access_iterator_tag);
588
589 /// Prepend the specified `numElements` copies of the specified `value`
590 /// to this deque.
591 void privatePrependRaw(size_type numElements, const VALUE_TYPE& value);
592
593 /// Split this deque in two such that after the split, `*this` contains
594 /// elements formerly in the range specified by `[d_start .. pos)` and
595 /// the specified `other` deque contains elements formerly in the range `[pos .. d_finish)`.
596 ///
597 /// \pre The behavior is undefined unless `other` is a
598 /// raw deque, i.e., the `RawInit` constructor was used to create
599 /// `other`.
600 void privateSplit(deque *other, IteratorImp pos);
601
602 // FRIENDS
603 template <class VALUE_TYPE2, class ALLOCATOR2>
604 friend class Deque_BlockCreator;
605
606 template <class VALUE_TYPE2, class ALLOCATOR2>
607 friend class Deque_BlockProctor;
608
609 template <class VALUE_TYPE2, class ALLOCATOR2>
610 friend class Deque_Guard;
611
612 public:
613 // CREATORS
614
615 // *** construct/copy/destroy ***
616
617 /// Create an empty deque. Optionally specify a `basicAllocator` used
618 /// to supply memory. If `basicAllocator` is not supplied, a
619 /// default-constructed object of the (template parameter) type
620 /// `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator`
621 /// (the default), then `basicAllocator`, if supplied, shall be
622 /// convertible to `bslma::Allocator *`. If the type `ALLOCATOR` is
623 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
624 /// installed default allocator is used.
625 deque();
626 explicit deque(const ALLOCATOR& basicAllocator);
627
628 /// Create a deque of the specified `numElements` size whose every
629 /// element is value-initialized. Optionally specify a `basicAllocator`
630 /// used to supply memory. If `basicAllocator` is not supplied, a
631 /// default-constructed object of the (template parameter) type
632 /// `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator`
633 /// (the default), then `basicAllocator`, if supplied, shall be
634 /// convertible to `bslma::Allocator *`. If the type `ALLOCATOR` is
635 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
636 /// installed default allocator is used. Throw `bsl::length_error` if
637 /// `numElements > max_size()`. This method requires that the (template
638 /// parameter) `VALUE_TYPE` be `default-insertable` into this deque (see
639 /// {Requirements on `VALUE_TYPE`}).
640 explicit
641 deque(size_type numElements,
642 const ALLOCATOR& basicAllocator = ALLOCATOR());
643
644 /// Create a deque of the specified `numElements` size whose every
645 /// element has the specified `value`. Optionally specify a
646 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
647 /// supplied, a default-constructed object of the (template parameter)
648 /// type `ALLOCATOR` is used. If the type `ALLOCATOR` is
649 /// `bsl::allocator` (the default), then `basicAllocator`, if supplied,
650 /// shall be convertible to `bslma::Allocator *`. If the type
651 /// `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not
652 /// supplied, the currently installed default allocator is used. Throw
653 /// `bsl::length_error` if `numElements > max_size()`. This method
654 /// requires that the (template parameter) `VALUE_TYPE` be
655 /// `copy-insertable` into this deque (see {Requirements on
656 /// `VALUE_TYPE`}).
657 deque(size_type numElements,
658 const VALUE_TYPE& value,
659 const ALLOCATOR& basicAllocator = ALLOCATOR());
660
661 /// Create a deque initially containing copies of the values in the
662 /// range starting at the specified `first` and ending immediately
663 /// before the specified `last` iterators of the (template parameter)
664 /// type `INPUT_ITERATOR`. Optionally specify a `basicAllocator` used
665 /// to supply memory. If `basicAllocator` is not supplied, a
666 /// default-constructed object of the (template parameter) type
667 /// `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator`
668 /// (the default), then `basicAllocator`, if supplied, shall be
669 /// convertible to `bslma::Allocator *`. If the type `ALLOCATOR` is
670 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
671 /// installed default allocator is used. Throw `bsl::length_error` if
672 /// the number of elements in `[first .. last)` exceeds the size
673 /// returned by @ref max_size . The (template parameter) type
674 /// `INPUT_ITERATOR` shall meet the requirements of an input iterator
675 /// defined in the C++11 standard [input.iterators] providing access to
676 /// values of a type convertible to `value_type`, and `value_type` must
677 /// be `emplace-constructible` from `*i` into this deque, where `i` is a
678 /// dereferenceable iterator in the range `[first .. last)` (see {Requirements on `VALUE_TYPE`}).
679 ///
680 /// \pre The behavior is undefined unless
681 /// `first` and `last` refer to a sequence of valid values where `first`
682 /// is at a position at or before `last`.
683 template <class INPUT_ITERATOR>
684 deque(INPUT_ITERATOR first,
685 INPUT_ITERATOR last,
686 const ALLOCATOR& basicAllocator = ALLOCATOR());
687
688 /// Create a deque from the elements of the specifed `range`. Optionally
689 /// specify an `basicAllocator` used to supply memory. If `basicAllocator`
690 /// is not specified, a default-constructed object of the (template parameter) type `ALLOCATOR` is used.
691 ///
692 /// \note Note that `range` must meet the
693 /// requirements of an input range and the values from `range` must have a
694 /// type matching or convertible to (template parameter) `VALUE_TYPE`.
695 template <class t_RANGE>
697 deque(from_range_t ,
699 const ALLOCATOR& basicAllocator =
700 ALLOCATOR());
701
702 /// Create a deque that has the same value as the specified `original`
703 /// object. Use the allocator returned by
704 /// 'bsl::allocator_traits<ALLOCATOR>::
705 /// select_on_container_copy_construction(original.get_allocator())' to
706 /// supply memory. If the (template parameter) type `ALLOCATOR` is
707 /// `bsl::allocator` (the default), the currently installed default
708 /// allocator is used. This method requires that the (template
709 /// parameter) `VALUE_TYPE` be `copy-insertable` into this deque (see
710 /// {Requirements on `VALUE_TYPE`}).
711 deque(const deque& original);
712
713 /// Create a deque that has the same value as the specified `original`
714 /// object and that uses the specified `basicAllocator` to supply
715 /// memory. This method requires that the (template parameter)
716 /// `VALUE_TYPE` be `copy-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
717 ///
718 /// \note Note that a `bslma::Allocator *`
719 /// can be supplied for `basicAllocator` if the (template parameter)
720 /// type `ALLOCATOR` is `bsl::allocator` (the default).
721 deque(const deque& original,
722 const typename type_identity<ALLOCATOR>::type& basicAllocator);
723
724 /// Create a deque having the same value as the specified `original`
725 /// object by moving (in constant time) the contents of `original` to
726 /// the new deque. The allocator associated with `original` is
727 /// propagated for use in the newly-created deque. `original` is left
728 /// in a valid but unspecified state.
729 deque(BloombergLP::bslmf::MovableRef<deque> original); // IMPLICIT
730
731 /// Create a deque having the same value as the specified `original`
732 /// object that uses the specified `basicAllocator` to supply memory.
733 /// The contents of `original` are moved (in constant time) to the new
734 /// deque if `basicAllocator == original.get_allocator()`, and are move-
735 /// inserted (in linear time) using `basicAllocator` otherwise.
736 /// `original` is left in a valid but unspecified state. This method
737 /// requires that the (template parameter) `VALUE_TYPE` be
738 /// `move-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
739 ///
740 /// \note Note that a `bslma::Allocator *` can be supplied
741 /// for `basicAllocator` if the (template parameter) `ALLOCATOR` is
742 /// `bsl::allocator` (the default).
743 deque(BloombergLP::bslmf::MovableRef<deque> original,
744 const typename type_identity<ALLOCATOR>::type& basicAllocator);
745
746#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
747 /// Create a deque and append each `value_type` object in the specified
748 /// `values` initializer list. Optionally specify a `basicAllocator`
749 /// used to supply memory. If `basicAllocator` is not supplied, a
750 /// default-constructed object of the (template parameter) type
751 /// `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator`
752 /// (the default), then `basicAllocator`, if supplied, shall be
753 /// convertible to `bslma::Allocator *`. If the type `ALLOCATOR` is
754 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
755 /// installed default allocator is used. This method requires that the
756 /// (template parameter) `VALUE_TYPE` be `copy-insertable` into this
757 /// deque (see {Requirements on `VALUE_TYPE`}).
758 deque(std::initializer_list<value_type> values,
759 const ALLOCATOR& basicAllocator = ALLOCATOR());
760#endif
761
762 /// Destroy this object.
763 ~deque();
764
765 // MANIPULATORS
766
767 /// Assign to this object the value of the specified `rhs` object,
768 /// propagate to this object the allocator of `rhs` if the `ALLOCATOR`
769 /// type has trait @ref propagate_on_container_copy_assignment , and return
770 /// a reference providing modifiable access to this object. If an
771 /// exception is thrown, `*this` is left in a valid but unspecified
772 /// state. This method requires that the (template parameter)
773 /// `VALUE_TYPE` be `copy-assignable` and `copy-insertable` into this
774 /// deque (see {Requirements on `VALUE_TYPE`}).
775 deque& operator=(const deque& rhs);
776
777 /// Assign to this object the value of the specified `rhs` object,
778 /// propagate to this object the allocator of `rhs` if the `ALLOCATOR`
779 /// type has trait @ref propagate_on_container_move_assignment , and return
780 /// a reference providing modifiable access to this object. The
781 /// contents of `rhs` are moved (in constant time) to this deque if
782 /// `get_allocator() == rhs.get_allocator()` (after accounting for the
783 /// aforementioned trait); otherwise, all elements in this deque are
784 /// either destroyed or move-assigned to and each additional element in
785 /// `rhs` is move-inserted into this deque. `rhs` is left in a valid
786 /// but unspecified state, and if an exception is thrown, `*this` is
787 /// left in a valid but unspecified state. This method requires that
788 /// the (template parameter) `VALUE_TYPE` be `move-assignable` and
789 /// `move-insertable` into this deque (see {Requirements on
790 /// `VALUE_TYPE`}).
791 deque& operator=(BloombergLP::bslmf::MovableRef<deque> rhs)
793 AllocatorTraits::is_always_equal::value);
794
795#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
796 /// Assign to this object the value resulting from first clearing this
797 /// deque and then appending each `value_type` object in the specified
798 /// `values` initializer list; return a reference providing modifiable
799 /// access to this object. This method requires that the (template
800 /// parameter) `VALUE_TYPE` be `copy-insertable` into this deque (see
801 /// {Requirements on `VALUE_TYPE`}).
802 deque& operator=(std::initializer_list<value_type> values);
803#endif
804
805 /// Assign to this deque the values in the range starting at the
806 /// specified `first` and ending immediately before the specified `last`
807 /// iterators of the (template parameter) type `INPUT_ITERATOR`. The
808 /// (template parameter) type `INPUT_ITERATOR` shall meet the
809 /// requirements of an input iterator defined in the C++11 standard
810 /// [input.iterators] providing access to values of a type convertible
811 /// to `value_type`, and `value_type` must be `copy-assignable` and
812 /// `emplace-constructible` from `*i` into this deque, where `i` is a
813 /// dereferenceable iterator in the range `[first .. last)` (see {Requirements on `VALUE_TYPE`}).
814 ///
815 /// \pre The behavior is undefined unless
816 /// `first` and `last` refer to a sequence of valid values where `first`
817 /// is at a position at or before `last`.
818 template <class INPUT_ITERATOR>
819 void assign(INPUT_ITERATOR first, INPUT_ITERATOR last);
820
821 /// Assign to this object the value resulting from first clearing this
822 /// deque and then appending the specified `numElements` having the
823 /// specified `value`. This method requires that the (template
824 /// parameter) `VALUE_TYPE` be `copy-assignable` and `copy-insertable`
825 /// into this deque (see {Requirements on `VALUE_TYPE`}).
826 void assign(size_type numElements, const VALUE_TYPE& value);
827
828#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
829 /// Assign to this object the value resulting from first clearing this
830 /// deque and then appending each `value_type` object in the specified
831 /// `values` initializer list. This method requires that the (template
832 /// parameter) `VALUE_TYPE` be `copy-assignable` and `copy-insertable`
833 /// into this deque (see {Requirements on `VALUE_TYPE`}).
834 void assign(std::initializer_list<value_type> values);
835#endif
836
837 /// Assign to this object the elements of the specified `range`.
838 ///
839 /// \note Note that `range` must meet the requirements of an input range and the values
840 /// from `range` must have a type matching or convertible to (template
841 /// parameter) `VALUE_TYPE`.
842 template <class t_RANGE>
844 void assign_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range);
845
846 // *** capacity ***
847
848 /// Change the capacity of this deque such that, after this method
849 /// returns, iterators remain valid provided that no more than the
850 /// specified `numElements` objects are pushed to the front or back of
851 /// the deque after this call. If it is already possible to push
852 /// `numElements` objects to either end of this deque without
853 /// invalidating iterators, this method has no effect.
854 ///
855 /// \note Note that inserting elements into the deque may still incur memory allocation.
856 /// Also note that this method, if it has any effect, will invalidate
857 /// iterators initialized prior to the call. Also note that this method
858 /// is not part of the C++ standard.
859 void reserve(size_type numElements);
860
861 /// Change the size of this deque to the specified `newSize`. Erase
862 /// `size() - newSize` elements at the back if `newSize < size()`.
863 /// Append `newSize - size()` elements at the back having the optionally
864 /// specified `value` if `newSize > size()`; if `value` is not
865 /// specified, value-initialized objects of the (template parameter)
866 /// `VALUE_TYPE` are emplaced. This method has no effect if
867 /// `newSize == size()`. Throw `bsl::length_error` if
868 /// `newSize > max_size()`.
869 void resize(size_type newSize);
870 void resize(size_type newSize, const VALUE_TYPE& value);
871
872 /// Minimize the memory used by this deque to the extent possible
873 /// without moving any contained elements. If an exception is thrown, the value of this object is unchanged.
874 ///
875 /// \note Note that this method has no
876 /// effect on the memory used by individual elements of the (template
877 /// parameter) `VALUE_TYPE`.
878 void shrink_to_fit();
879
880 // *** modifiers ***
881
882 /// Append to the end of this object the elements of the specified `range`.
883 ///
884 /// \note Note that `range` must meet the requirements of an input range and the
885 /// values from `range` must have a type matching or convertible to
886 /// (template parameter) `VALUE_TYPE`.
887 template <class t_RANGE>
889 void append_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range);
890
891 /// Prepend to the front of this object the elements of the specified `range`.
892 ///
893 /// \note Note that `range` must meet the requirements of an input
894 /// range and the values from `range` must have a type matching or
895 /// convertible to (template parameter) `VALUE_TYPE`.
896 template <class t_RANGE>
898 void prepend_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range);
899
900 /// Prepend to the front of this deque a copy of the specified `value`.
901 /// This method offers full guarantee of rollback in case an exception
902 /// is thrown. This method requires that the (template parameter)
903 /// `VALUE_TYPE` be `copy-constructible` (see {Requirements on
904 /// `VALUE_TYPE`}).
905 void push_front(const VALUE_TYPE& value);
906
907 /// Prepend to the front of this deque the specified move-insertable
908 /// `value`. `value` is left in a valid but unspecified state. If an
909 /// exception is thrown (other than by the move constructor of a
910 /// non-copy-insertable `value_type`), this method has no effect. This
911 /// method requires that the (template parameter) `VALUE_TYPE` be
912 /// `move-insertable` into this deque (see {Requirements on
913 /// `VALUE_TYPE`}).
914 void push_front(BloombergLP::bslmf::MovableRef<value_type> value);
915
916 /// Append to the back of this deque a copy of the specified `value`.
917 /// This method offers full guarantee of rollback in case an exception
918 /// is thrown. This method requires that the (template parameter)
919 /// `VALUE_TYPE` be `copy-constructible` (see {Requirements on
920 /// `VALUE_TYPE`}).
921 void push_back(const VALUE_TYPE& value);
922
923 /// Append to the back of this deque the specified move-insertable
924 /// `value`. `value` is left in a valid but unspecified state. If an
925 /// exception is thrown (other than by the move constructor of a
926 /// non-copy-insertable `value_type`), this method has no effect. This
927 /// method requires that the (template parameter) `VALUE_TYPE` be
928 /// `move-insertable` into this deque (see {Requirements on
929 /// `VALUE_TYPE`}).
930 void push_back(BloombergLP::bslmf::MovableRef<value_type> value);
931
932#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
933// {{{ BEGIN GENERATED CODE
934// Command line: sim_cpp11_features.pl bslstl_deque.h
935#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
936#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
937#endif
938#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_A
939#define BSLSTL_DEQUE_VARIADIC_LIMIT_A BSLSTL_DEQUE_VARIADIC_LIMIT
940#endif
941#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
942 reference emplace_front(
943 );
944#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
945
946#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
947 template <class Args_01>
948 reference emplace_front(
949 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
950#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
951
952#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
953 template <class Args_01,
954 class Args_02>
955 reference emplace_front(
956 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
957 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
958#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
959
960#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
961 template <class Args_01,
962 class Args_02,
963 class Args_03>
964 reference emplace_front(
965 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
966 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
967 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
968#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
969
970#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
971 template <class Args_01,
972 class Args_02,
973 class Args_03,
974 class Args_04>
975 reference emplace_front(
976 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
977 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
978 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
979 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
980#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
981
982#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
983 template <class Args_01,
984 class Args_02,
985 class Args_03,
986 class Args_04,
987 class Args_05>
988 reference emplace_front(
989 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
990 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
991 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
992 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
993 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
994#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
995
996#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
997 template <class Args_01,
998 class Args_02,
999 class Args_03,
1000 class Args_04,
1001 class Args_05,
1002 class Args_06>
1003 reference emplace_front(
1004 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1005 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1006 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1007 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1008 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1009 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
1010#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
1011
1012#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
1013 template <class Args_01,
1014 class Args_02,
1015 class Args_03,
1016 class Args_04,
1017 class Args_05,
1018 class Args_06,
1019 class Args_07>
1020 reference emplace_front(
1021 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1022 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1023 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1024 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1027 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
1028#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
1029
1030#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
1031 template <class Args_01,
1032 class Args_02,
1033 class Args_03,
1034 class Args_04,
1035 class Args_05,
1036 class Args_06,
1037 class Args_07,
1038 class Args_08>
1039 reference emplace_front(
1040 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1041 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1042 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1043 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1044 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1045 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1046 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1047 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
1048#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
1049
1050#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
1051 template <class Args_01,
1052 class Args_02,
1053 class Args_03,
1054 class Args_04,
1055 class Args_05,
1056 class Args_06,
1057 class Args_07,
1058 class Args_08,
1059 class Args_09>
1060 reference emplace_front(
1061 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1062 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1063 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1064 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1065 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1066 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1067 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1068 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1069 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
1070#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
1071
1072#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
1073 template <class Args_01,
1074 class Args_02,
1075 class Args_03,
1076 class Args_04,
1077 class Args_05,
1078 class Args_06,
1079 class Args_07,
1080 class Args_08,
1081 class Args_09,
1082 class Args_10>
1083 reference emplace_front(
1084 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1085 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1086 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1087 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1088 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1089 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1090 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1091 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1092 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1093 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
1094#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
1095
1096
1097#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
1098 reference emplace_back(
1099 );
1100#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 0
1101
1102#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
1103 template <class Args_01>
1104 reference emplace_back(
1105 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
1106#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 1
1107
1108#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
1109 template <class Args_01,
1110 class Args_02>
1111 reference emplace_back(
1112 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1113 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
1114#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 2
1115
1116#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
1117 template <class Args_01,
1118 class Args_02,
1119 class Args_03>
1120 reference emplace_back(
1121 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1122 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1123 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
1124#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 3
1125
1126#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
1127 template <class Args_01,
1128 class Args_02,
1129 class Args_03,
1130 class Args_04>
1131 reference emplace_back(
1132 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1133 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1134 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1135 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
1136#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 4
1137
1138#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
1139 template <class Args_01,
1140 class Args_02,
1141 class Args_03,
1142 class Args_04,
1143 class Args_05>
1144 reference emplace_back(
1145 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1146 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1147 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1148 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1149 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
1150#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 5
1151
1152#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
1153 template <class Args_01,
1154 class Args_02,
1155 class Args_03,
1156 class Args_04,
1157 class Args_05,
1158 class Args_06>
1159 reference emplace_back(
1160 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1161 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1162 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1163 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1164 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1165 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
1166#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 6
1167
1168#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
1169 template <class Args_01,
1170 class Args_02,
1171 class Args_03,
1172 class Args_04,
1173 class Args_05,
1174 class Args_06,
1175 class Args_07>
1176 reference emplace_back(
1177 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1178 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1179 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1180 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1181 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1182 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1183 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
1184#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 7
1185
1186#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
1187 template <class Args_01,
1188 class Args_02,
1189 class Args_03,
1190 class Args_04,
1191 class Args_05,
1192 class Args_06,
1193 class Args_07,
1194 class Args_08>
1195 reference emplace_back(
1196 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1197 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1198 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1199 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1200 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1201 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1202 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1203 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
1204#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 8
1205
1206#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
1207 template <class Args_01,
1208 class Args_02,
1209 class Args_03,
1210 class Args_04,
1211 class Args_05,
1212 class Args_06,
1213 class Args_07,
1214 class Args_08,
1215 class Args_09>
1216 reference emplace_back(
1217 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1218 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1219 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1220 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1221 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1222 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1223 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1224 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1225 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
1226#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 9
1227
1228#if BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
1229 template <class Args_01,
1230 class Args_02,
1231 class Args_03,
1232 class Args_04,
1233 class Args_05,
1234 class Args_06,
1235 class Args_07,
1236 class Args_08,
1237 class Args_09,
1238 class Args_10>
1239 reference emplace_back(
1240 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1241 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1242 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1243 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1244 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1245 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1246 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1247 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1248 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1249 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
1250#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_A >= 10
1251
1252#else
1253// The generated code below is a workaround for the absence of perfect
1254// forwarding in some compilers.
1255 template <class... Args>
1256 reference emplace_front(
1257 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
1258
1259 template <class... Args>
1260 reference emplace_back(
1261 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
1262// }}} END GENERATED CODE
1263#endif
1264
1265#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1266// {{{ BEGIN GENERATED CODE
1267// Command line: sim_cpp11_features.pl bslstl_deque.h
1268#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
1269#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
1270#endif
1271#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_B
1272#define BSLSTL_DEQUE_VARIADIC_LIMIT_B BSLSTL_DEQUE_VARIADIC_LIMIT
1273#endif
1274#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 0
1275 iterator emplace(const_iterator position);
1276#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 0
1277
1278#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 1
1279 template <class Args_01>
1280 iterator emplace(const_iterator position,
1281 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
1282#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 1
1283
1284#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 2
1285 template <class Args_01,
1286 class Args_02>
1287 iterator emplace(const_iterator position,
1288 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1289 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
1290#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 2
1291
1292#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 3
1293 template <class Args_01,
1294 class Args_02,
1295 class Args_03>
1296 iterator emplace(const_iterator position,
1297 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1298 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1299 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
1300#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 3
1301
1302#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 4
1303 template <class Args_01,
1304 class Args_02,
1305 class Args_03,
1306 class Args_04>
1307 iterator emplace(const_iterator position,
1308 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1309 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1310 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1311 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
1312#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 4
1313
1314#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 5
1315 template <class Args_01,
1316 class Args_02,
1317 class Args_03,
1318 class Args_04,
1319 class Args_05>
1320 iterator emplace(const_iterator position,
1321 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1322 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1324 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1325 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
1326#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 5
1327
1328#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 6
1329 template <class Args_01,
1330 class Args_02,
1331 class Args_03,
1332 class Args_04,
1333 class Args_05,
1334 class Args_06>
1335 iterator emplace(const_iterator position,
1336 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1337 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1338 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1339 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1340 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1341 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
1342#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 6
1343
1344#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 7
1345 template <class Args_01,
1346 class Args_02,
1347 class Args_03,
1348 class Args_04,
1349 class Args_05,
1350 class Args_06,
1351 class Args_07>
1352 iterator emplace(const_iterator position,
1353 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1354 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1355 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1356 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1357 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1358 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1359 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
1360#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 7
1361
1362#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 8
1363 template <class Args_01,
1364 class Args_02,
1365 class Args_03,
1366 class Args_04,
1367 class Args_05,
1368 class Args_06,
1369 class Args_07,
1370 class Args_08>
1371 iterator emplace(const_iterator position,
1372 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1373 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1374 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1375 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1376 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1377 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1378 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1379 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
1380#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 8
1381
1382#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 9
1383 template <class Args_01,
1384 class Args_02,
1385 class Args_03,
1386 class Args_04,
1387 class Args_05,
1388 class Args_06,
1389 class Args_07,
1390 class Args_08,
1391 class Args_09>
1392 iterator emplace(const_iterator position,
1393 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1394 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1395 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1396 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1397 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1398 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1399 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1400 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1401 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
1402#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 9
1403
1404#if BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 10
1405 template <class Args_01,
1406 class Args_02,
1407 class Args_03,
1408 class Args_04,
1409 class Args_05,
1410 class Args_06,
1411 class Args_07,
1412 class Args_08,
1413 class Args_09,
1414 class Args_10>
1415 iterator emplace(const_iterator position,
1416 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1417 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1418 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1419 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1420 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1421 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1422 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1423 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1424 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1425 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
1426#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_B >= 10
1427
1428#else
1429// The generated code below is a workaround for the absence of perfect
1430// forwarding in some compilers.
1431 template <class... Args>
1432 iterator emplace(const_iterator position,
1433 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
1434// }}} END GENERATED CODE
1435#endif
1436
1437 /// Erase the first element from this deque.
1438 ///
1439 /// \pre The behavior is undefined if this deque is empty.
1440 void pop_front();
1441
1442 /// Erase the last element from this deque.
1443 ///
1444 /// \pre The behavior is undefined if this deque is empty.
1445 void pop_back();
1446
1447 /// Insert at the specified `position` in this deque a copy of the
1448 /// specified `value`, and return an iterator providing modifiable
1449 /// access to the newly inserted element. This method offers full
1450 /// guarantee of rollback in case an exception is thrown other than by
1451 /// the `VALUE_TYPE` copy constructor or assignment operator. This
1452 /// method requires that the (template parameter) `VALUE_TYPE` be
1453 /// `copy-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
1454 ///
1455 /// \pre The behavior is undefined unless `position` is an
1456 /// iterator in the range `[cbegin() .. cend()]` (both endpoints
1457 /// included).
1458 iterator insert(const_iterator position, const VALUE_TYPE& value);
1459
1460 /// Insert at the specified `position` in this deque the specified
1461 /// move-insertable `value`, and return an iterator providing modifiable
1462 /// access to the newly inserted element. `value` is left in a valid
1463 /// but unspecified state. If an exception is thrown (other than by the
1464 /// copy constructor, move constructor, assignment operator, or move
1465 /// assignment operator of `value_type`), this method has no effect.
1466 /// This method requires that the (template parameter) `VALUE_TYPE` be
1467 /// `move-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
1468 ///
1469 /// \pre The behavior is undefined unless `position` is an
1470 /// iterator in the range `[cbegin() .. cend()]` (both endpoints
1471 /// included).
1472 iterator insert(const_iterator position,
1473 BloombergLP::bslmf::MovableRef<value_type> value);
1474
1475 /// Insert at the specified `position` in this deque the specified
1476 /// `numElements` copies of the specified `value`, and return an
1477 /// iterator providing modifiable access to the first element in the
1478 /// newly inserted sequence of elements. This method offers full
1479 /// guarantee of rollback in case an exception is thrown other than by
1480 /// the `VALUE_TYPE` copy constructor or assignment operator. This
1481 /// method requires that the (template parameter) `VALUE_TYPE` be
1482 /// `copy-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
1483 ///
1484 /// \pre The behavior is undefined unless `position` is an
1485 /// iterator in the range `[cbegin() .. cend()]` (both endpoints
1486 /// included).
1487 iterator insert(const_iterator position,
1488 size_type numElements,
1489 const VALUE_TYPE& value);
1490
1491 /// Insert at the specified `position` in this deque the values in the
1492 /// range starting at the specified `first` and ending immediately
1493 /// before the specified `last` iterators of the (template parameter)
1494 /// type `INPUT_ITERATOR`, and return an iterator providing modifiable
1495 /// access to the first element in the newly inserted sequence of
1496 /// elements. This method offers full guarantee of rollback in case an
1497 /// exception is thrown other than by the `VALUE_TYPE` copy constructor
1498 /// or assignment operator. The (template parameter) type
1499 /// `INPUT_ITERATOR` shall meet the requirements of an input iterator
1500 /// defined in the C++11 standard [input.iterators] providing access to
1501 /// values of a type convertible to `value_type`, and `value_type` must
1502 /// be `emplace-constructible` from `*i` into this deque, where `i` is a
1503 /// dereferenceable iterator in the range `[first .. last)` (see {Requirements on `VALUE_TYPE`}).
1504 ///
1505 /// \pre The behavior is undefined unless
1506 /// `position` is an iterator in the range `[cbegin() .. cend()]` (both
1507 /// endpoints included), and `first` and `last` refer to a sequence of
1508 /// valid values where `first` is at a position at or before `last`.
1509 template <class INPUT_ITERATOR>
1510 iterator insert(const_iterator position,
1511 INPUT_ITERATOR first,
1512 INPUT_ITERATOR last);
1513
1514#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1515 /// Insert at the specified `position` in this deque the value of each
1516 /// `value_type` object in the specified `values` initializer list, and
1517 /// return an iterator providing modifiable access to the first element
1518 /// in the newly inserted sequence of elements. This method offers full
1519 /// guarantee of rollback in case an exception is thrown other than by
1520 /// the `VALUE_TYPE` copy constructor or assignment operator. This
1521 /// method requires that the (template parameter) `VALUE_TYPE` be
1522 /// `copy-insertable` into this deque (see {Requirements on `VALUE_TYPE`}).
1523 ///
1524 /// \pre The behavior is undefined unless `position` is an
1525 /// iterator in the range `[cbegin() .. cend()]` (both endpoints
1526 /// included).
1527 iterator insert(const_iterator position,
1528 std::initializer_list<value_type> values);
1529#endif
1530
1531 /// Insert at the specified `position` in this object the elements of the specified `range`.
1532 ///
1533 /// \note Note that `range` must meet the requirements of an
1534 /// input range and the values from `range` must have a type matching or
1535 /// convertible to (template parameter) `VALUE_TYPE`.
1536 template <class t_RANGE>
1538 iterator insert_range(const_iterator position,
1539 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range);
1540
1541 /// Remove from this deque the element at the specified `position`, and
1542 /// return an iterator providing modifiable access to the element
1543 /// immediately following the removed element, or the position returned
1544 /// by the method `end` if the removed element was the last in the sequence.
1545 ///
1546 /// \pre The behavior is undefined unless `position` is an
1547 /// iterator in the range `[cbegin() .. cend())`.
1548 iterator erase(const_iterator position);
1549
1550 /// Remove from this deque the sequence of elements starting at the
1551 /// specified `first` position and ending before the specified `last`
1552 /// position, and return an iterator providing modifiable access to the
1553 /// element immediately following the last removed element, or the
1554 /// position returned by the method `end` if the removed elements were last in the sequence.
1555 ///
1556 /// \pre The behavior is undefined unless `first` is
1557 /// an iterator in the range `[cbegin() .. cend()]` (both endpoints
1558 /// included) and `last` is an iterator in the range
1559 /// `[first .. cend()]` (both endpoints included).
1561
1562 /// Exchange the value of this object with that of the specified `other`
1563 /// object; also exchange the allocator of this object with that of
1564 /// `other` if the (template parameter) type `ALLOCATOR` has the
1565 /// @ref propagate_on_container_swap trait, and do not modify either
1566 /// allocator otherwise. This method provides the no-throw
1567 /// exception-safety guarantee. This operation has `O[1]` complexity if
1568 /// either this object was created with the same allocator as `other` or
1569 /// `ALLOCATOR` has the @ref propagate_on_container_swap trait; otherwise,
1570 /// it has `O[n + m]` complexity, where `n` and `m` are the number of elements in this object and `other`, respectively.
1571 ///
1572 /// \note Note that this
1573 /// method`s support for swapping objects created with different
1574 /// allocators when `ALLOCATOR` does not have the
1575 /// @ref propagate_on_container_swap trait is a departure from the
1576 /// C++ Standard.
1577 void swap(deque<VALUE_TYPE, ALLOCATOR>& other)
1579 AllocatorTraits::is_always_equal::value);
1580
1581 /// Remove all elements from this deque making its size 0.
1582 ///
1583 /// \note Note that although this deque is empty after this method returns, it preserves
1584 /// the same capacity it had before the method was called.
1585 void clear() BSLS_KEYWORD_NOEXCEPT;
1586
1587 // ACCESSORS
1588
1589 // *** construct/copy/destroy ***
1590
1591 /// Return the allocator used by this deque to supply memory.
1592 allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT;
1593
1594 /// Return the maximum possible size of this deque.
1595 /// \note Note that this is a
1596 /// theoretical maximum (such as the maximum value that can be held by
1597 /// `size_type`). Also note that any request to create or enlarge a
1598 /// deque to a size greater than `max_size()` is guaranteed to raise a
1599 /// `bsl::length_error` exception.
1600 size_type max_size() const BSLS_KEYWORD_NOEXCEPT;
1601};
1602
1603#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1604// CLASS TEMPLATE DEDUCTION GUIDES
1605
1606/// Deduce the template parameter `VALUE` from the corresponding parameter
1607/// supplied to the constructor of `deque`. This deduction guide does not
1608/// participate unless the supplied allocator is convertible to
1609/// `bsl::allocator<VALUE>`.
1610template <
1611 class SIZE_TYPE,
1612 class VALUE,
1613 class ALLOC,
1614 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
1615 class = bsl::enable_if_t<
1616 bsl::is_convertible_v<
1617 SIZE_TYPE,
1619 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1620 >
1621deque(SIZE_TYPE, VALUE, ALLOC *) -> deque<VALUE>;
1622
1623/// Deduce the template parameter `VALUE` from the `value_type` of the
1624/// iterators supplied to the constructor of `deque`.
1625template <
1626 class INPUT_ITERATOR,
1627 class VALUE =
1628 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
1629 >
1630deque(INPUT_ITERATOR, INPUT_ITERATOR) -> deque<VALUE>;
1631
1632/// Deduce the template parameter `VALUE` from the `value_type` of the
1633/// iterators supplied to the constructor of `deque`. This deduction guide
1634/// does not participate unless the supplied allocator meets the
1635/// requirements of a standard allocator.
1636template<
1637 class INPUT_ITERATOR,
1638 class ALLOCATOR,
1639 class VALUE =
1640 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1641 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>>
1642deque(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR) -> deque<VALUE, ALLOCATOR>;
1643
1644/// Deduce the template parameter `VALUE` from the `value_type` of the
1645/// iterators supplied to the constructor of `deque`. This deduction guide
1646/// does not participate unless the supplied allocator is convertible to
1647/// `bsl::allocator<VALUE>`.
1648template<
1649 class INPUT_ITERATOR,
1650 class ALLOC,
1651 class VALUE =
1652 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
1653 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
1654 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1655 >
1656deque(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
1657-> deque<VALUE>;
1658
1659/// Deduce the template parameter `VALUE` from the `value_type` of the
1660/// initializer_list supplied to the constructor of `deque`. This deduction
1661/// guide does not participate unless the supplied allocator is convertible
1662/// to `bsl::allocator<VALUE>`.
1663template<
1664 class VALUE,
1665 class ALLOC,
1666 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
1667 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
1668 >
1669deque(std::initializer_list<VALUE>, ALLOC *)
1670-> deque<VALUE>;
1671
1672#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
1673 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
1674/// Deduce the template parameters `VALUE_TYPE` and `ALLOCATOR` from the
1675/// parameters supplied to the constructor of `deque`.
1676template <ranges::input_range t_RANGE,
1677 class t_ALLOCATOR =
1678 allocator<ranges::range_value_t<t_RANGE>>>
1679deque(from_range_t, t_RANGE&&, t_ALLOCATOR = t_ALLOCATOR())
1680-> deque<ranges::range_value_t<t_RANGE>, t_ALLOCATOR>;
1681#endif
1682#endif
1683
1684// FREE OPERATORS
1685
1686/// Return `true` if the specified `lhs` and `rhs` objects have the same
1687/// value, and `false` otherwise. Two `deque` objects `lhs` and `rhs` have
1688/// the same value if they have the same number of elements, and each
1689/// element in the ordered sequence of elements of `lhs` has the same value
1690/// as the corresponding element in the ordered sequence of elements of
1691/// `rhs`. This method requires that the (template parameter) type
1692/// `VALUE_TYPE` be `equality-comparable` (see {Requirements on
1693/// `VALUE_TYPE`}).
1694template <class VALUE_TYPE, class ALLOCATOR>
1695bool operator==(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1696 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1697
1698#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
1699/// Return `true` if the specified `lhs` and `rhs` objects do not have the
1700/// same value, and `false` otherwise. Two `deque` objects `lhs` and `rhs`
1701/// do not have the same value if they do not have the same number of
1702/// elements, or some element in the ordered sequence of elements of `lhs`
1703/// does not have the same value as the corresponding element in the ordered
1704/// sequence of elements of `rhs`. This method requires that the (template
1705/// parameter) type `VALUE_TYPE` be `equality-comparable` (see {Requirements
1706/// on `VALUE_TYPE`}).
1707template <class VALUE_TYPE, class ALLOCATOR>
1708bool operator!=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1709 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1710#endif
1711
1712#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1713
1714/// Perform a lexicographic three-way comparison of the specified `lhs` and
1715/// the specified `rhs` containers by using the comparison operators of
1716/// `VALUE_TYPE` on each element; return the result of that comparison.
1717template <class VALUE_TYPE, class ALLOCATOR>
1718BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
1719 const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1720 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1721
1722#else
1723
1724/// Return `true` if the value of the specified `lhs` deque is
1725/// lexicographically less than that of the specified `rhs` deque, and
1726/// `false` otherwise. Given iterators `i` and `j` over the respective
1727/// sequences `[lhs.begin() .. lhs.end())` and `[rhs.begin() .. rhs.end())`,
1728/// the value of deque `lhs` is lexicographically less than that of deque
1729/// `rhs` if `true == *i < *j` for the first pair of corresponding iterator
1730/// positions where `*i < *j` and `*j < *i` are not both `false`. If no
1731/// such corresponding iterator position exists, the value of `lhs` is
1732/// lexicographically less than that of `rhs` if `lhs.size() < rhs.size()`.
1733/// This method requires that `operator<`, inducing a total order, be
1734/// defined for `value_type`.
1735template <class VALUE_TYPE, class ALLOCATOR>
1736bool operator<(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1737 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1738
1739/// Return `true` if the value of the specified `lhs` deque is
1740/// lexicographically greater than that of the specified `rhs` deque, and
1741/// `false` otherwise. The value of deque `lhs` is lexicographically
1742/// greater than that of deque `rhs` if `rhs` is lexicographically less than
1743/// `lhs` (see `operator<`). This method requires that `operator<`, inducing a total order, be defined for `value_type`.
1744///
1745/// \note Note that this
1746/// operator returns `rhs < lhs`.
1747template <class VALUE_TYPE, class ALLOCATOR>
1748bool operator>(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1749 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1750
1751/// Return `true` if the value of the specified `lhs` deque is
1752/// lexicographically less than or equal to that of the specified `rhs`
1753/// deque, and `false` otherwise. The value of deque `lhs` is
1754/// lexicographically less than or equal to that of deque `rhs` if `rhs` is
1755/// not lexicographically less than `lhs` (see `operator<`). This method
1756/// requires that `operator<`, inducing a total order, be defined for `value_type`.
1757///
1758/// \note Note that this operator returns `!(rhs < lhs)`.
1759template <class VALUE_TYPE, class ALLOCATOR>
1760bool operator<=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1761 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1762
1763/// Return `true` if the value of the specified `lhs` deque is
1764/// lexicographically greater than or equal to that of the specified `rhs`
1765/// deque, and `false` otherwise. The value of deque `lhs` is
1766/// lexicographically greater than or equal to that of deque `rhs` if `lhs`
1767/// is not lexicographically less than `rhs` (see `operator<`). This method
1768/// requires that `operator<`, inducing a total order, be defined for `value_type`.
1769///
1770/// \note Note that this operator returns `!(lhs < rhs)`.
1771template <class VALUE_TYPE, class ALLOCATOR>
1772bool operator>=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
1773 const deque<VALUE_TYPE, ALLOCATOR>& rhs);
1774
1775#endif // BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
1776
1777// FREE FUNCTIONS
1778
1779/// Erase all the elements in the specified deque `deq` that compare equal
1780/// to the specified `value`. Return the number of elements erased.
1781template <class VALUE_TYPE, class ALLOCATOR, class BDE_OTHER_TYPE>
1782typename deque<VALUE_TYPE, ALLOCATOR>::size_type
1783erase(deque<VALUE_TYPE, ALLOCATOR>& deq, const BDE_OTHER_TYPE& value);
1784
1785/// Erase all the elements in the specified deque `deq` that satisfy the
1786/// specified predicate `predicate`. Return the number of elements erased.
1787template <class VALUE_TYPE, class ALLOCATOR, class PREDICATE>
1788typename deque<VALUE_TYPE, ALLOCATOR>::size_type
1789erase_if(deque<VALUE_TYPE, ALLOCATOR>& deq, PREDICATE predicate);
1790
1791/// Exchange the value of the specified `a` object with that of the
1792/// specified `b` object; also exchange the allocator of `a` with that of
1793/// `b` if the (template parameter) type `ALLOCATOR` has the
1794/// @ref propagate_on_container_swap trait, and do not modify either allocator
1795/// otherwise. This function provides the no-throw exception-safety
1796/// guarantee. This operation has `O[1]` complexity if either `a` was
1797/// created with the same allocator as `b` or `ALLOCATOR` has the
1798/// @ref propagate_on_container_swap trait; otherwise, it has `O[n + m]`
1799/// complexity, where `n` and `m` are the number of elements in `a` and `b`, respectively.
1800///
1801/// \note Note that this function`s support for swapping objects
1802/// created with different allocators when `ALLOCATOR` does not have the
1803/// @ref propagate_on_container_swap trait is a departure from the C++
1804/// Standard.
1805template <class VALUE_TYPE, class ALLOCATOR>
1806void swap(deque<VALUE_TYPE, ALLOCATOR>& a, deque<VALUE_TYPE, ALLOCATOR>& b)
1808 a.swap(b)));
1809
1810 // ========================
1811 // class Deque_BlockCreator
1812 // ========================
1813
1814/// This class allocates blocks at the front or back of a deque and
1815/// tentatively adds them to the deque. It also keeps track of how many of
1816/// the newly allocated blocks have actually been used by the deque. The
1817/// destructor automatically frees any unused blocks (e.g., in case an
1818/// exception is thrown).
1819///
1820/// See @ref bslstl_deque_cpp03
1821template <class VALUE_TYPE, class ALLOCATOR>
1822class Deque_BlockCreator {
1823
1824 // PRIVATE TYPES
1825 enum {
1826 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
1827 };
1828
1829 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
1830 BLOCK_LENGTH> Imp;
1831 typedef typename Imp::Block Block;
1832 typedef typename Imp::BlockPtr BlockPtr;
1833 typedef std::size_t size_type;
1834
1835 // DATA
1836 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
1837 BlockPtr *d_boundary_p;
1838
1839 private:
1840 // NOT IMPLEMENTED
1841 Deque_BlockCreator(const Deque_BlockCreator&);
1842 Deque_BlockCreator& operator=(const Deque_BlockCreator&);
1843
1844 public:
1845 // CREATORS
1846
1847 /// Construct a block allocator for the specified `deque`.
1848 explicit
1849 Deque_BlockCreator(deque<VALUE_TYPE, ALLOCATOR> *deque);
1850
1851 /// Free any blocks that have been allocated by this allocator but have
1852 /// not yet been used by the deque.
1853 ~Deque_BlockCreator();
1854
1855 // MANIPULATORS
1856
1857 /// Allocate the specified `n` blocks at the front of the block array.
1858 /// This method invalidates all iterators except `d_deque_p->d_start`
1859 /// and `d_deque_p->d_finish`.
1860 void insertAtFront(size_type n);
1861
1862 /// Allocate the specified `n` blocks at the back of the block array.
1863 /// This method invalidates all iterators except `d_deque_p->d_start`
1864 /// and `d_deque_p->d_finish`.
1865 void insertAtBack(size_type n);
1866
1867 /// Make room for the specified `numNewBlocks` pointers in the blocks
1868 /// array. If the specified `atFront` is `true`, then make room at the
1869 /// front of the array, else make room at the back of the array. Return
1870 /// a pointer to the insertion point, i.e., the point where new blocks
1871 /// can be stored into the array, working backwards if `atFront` is
1872 /// `true`, or working forwards if `atFront` is `false`. This method
1873 /// invalidates all iterators and updates `d_deque_p->d_start` and
1874 /// `d_deque_p->d_finish`.
1875 BlockPtr *reserveBlockSlots(size_type numNewBlocks, bool atFront);
1876
1877 /// Relinquish control over any allocated blocks. The destructor will
1878 /// do nothing following a call to this method.
1879 void release();
1880};
1881
1882 // ========================
1883 // class Deque_BlockProctor
1884 // ========================
1885
1886/// This class implements a proctor that, upon destruction and unless its
1887/// `release` method has previously been invoked, deallocates empty blocks
1888/// at one end (i.e., front or back) of a proctored deque. The end at which
1889/// empty blocks are to be proctored is indicated by a flag supplied at
1890/// construction. See `emplace` for a use case.
1891///
1892/// See @ref bslstl_deque_cpp03
1893template <class VALUE_TYPE, class ALLOCATOR>
1894class Deque_BlockProctor {
1895
1896 // PRIVATE TYPES
1897 enum {
1898 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
1899 };
1900
1901 typedef BloombergLP::bslalg::DequeImpUtil<VALUE_TYPE,
1902 BLOCK_LENGTH> Imp;
1903
1904 typedef typename Imp::BlockPtr BlockPtr;
1905
1906 // DATA
1907 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p; // proctored deque
1908
1909 BlockPtr *d_boundary_p; // boundary of proctored
1910 // blocks
1911
1912 bool d_atFront; // if 'true', proctor blocks
1913 // at the front of the deque;
1914 // otherwise, proctor blocks
1915 // at the block
1916
1917 private:
1918 // NOT IMPLEMENTED
1919 Deque_BlockProctor(const Deque_BlockProctor&);
1920 Deque_BlockProctor& operator=(const Deque_BlockProctor&);
1921
1922 public:
1923 // CREATORS
1924
1925 /// Create a block proctor object to proctor blocks at one end (i.e.,
1926 /// front or back) of the specified `deque` as indicated by the
1927 /// specified `atFront` flag. If `atFront` is `true`, blocks at the
1928 /// front of `deque` are proctored; otherwise, blocks at the back of
1929 /// `deque` are proctored.
1930 Deque_BlockProctor(deque<VALUE_TYPE, ALLOCATOR> *deque, bool atFront);
1931
1932 /// Destroy this block proctor, and deallocate empty blocks at the back
1933 /// of the proctored deque as indicated by the `atFront` flag supplied
1934 /// at construction. If no deque is currently being managed, this
1935 /// method has no effect.
1936 ~Deque_BlockProctor();
1937
1938 // MANIPULATORS
1939
1940 /// Release from management the deque currently managed by this proctor.
1941 /// If no deque is currently being managed, this method has no effect.
1942 void release();
1943};
1944
1945 // ======================
1946 // class Deque_ClearGuard
1947 // ======================
1948
1949/// This class provides a proctor which, at destruction, calls `clear` on
1950/// the deque supplied at construction, unless the guard has been released
1951/// prior.
1952///
1953/// See @ref bslstl_deque_cpp03
1954template <class VALUE_TYPE, class ALLOCATOR>
1955class Deque_ClearGuard {
1956
1957 // PRIVATE TYPES
1958 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
1959
1960 // DATA
1961 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p; // proctored object
1962
1963 private:
1964 // NOT IMPLEMENTED
1965 Deque_ClearGuard(const Deque_ClearGuard&);
1966 Deque_ClearGuard& operator=(const Deque_ClearGuard&);
1967
1968 public:
1969 // CREATORS
1970
1971 /// Create a clear guard object to proctor the specified `deque`.
1972 explicit
1973 Deque_ClearGuard(deque<VALUE_TYPE, ALLOCATOR> *deque);
1974
1975 /// Destroy this guard, and call `clear` on the deque supplied at
1976 /// construction, unless `release` has been called on this object.
1977 ~Deque_ClearGuard();
1978
1979 // MANIPULATORS
1980
1981 /// Release from management the deque proctored by this object.
1982 void release();
1983};
1984
1985 // =================
1986 // class Deque_Guard
1987 // =================
1988
1989/// This class provides a proctor that maintains a count of the number of
1990/// elements constructed at the front or back of a deque, but not yet
1991/// committed to the deque's range of valid elements; if the count is
1992/// non-zero at destruction, the destructor destroys the elements in the
1993/// range `[d_deque_p->end() .. d_deque_p->end() + d_count)`, or the range
1994/// `[d_deque_p->begin() - d_count .. d_deque_p->begin())`, depending on
1995/// whether this proctor guards the back or front. This guard is used to
1996/// undo element constructors in the event of an exception. It is up to the
1997/// client code to increment the count whenever a new element is constructed
1998/// and to decrement the count whenever `d_start` or `d_finish` of the
1999/// guarded deque is moved to incorporate more elements.
2000///
2001/// See @ref bslstl_deque_cpp03
2002template <class VALUE_TYPE, class ALLOCATOR>
2003class Deque_Guard {
2004
2005 // PRIVATE TYPES
2006 enum {
2007 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
2008 };
2009
2010 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
2011 BLOCK_LENGTH> IteratorImp;
2012 typedef BloombergLP::bslalg::DequePrimitives<VALUE_TYPE,
2013 BLOCK_LENGTH> DequePrimitives;
2014
2015 // DATA
2016 deque<VALUE_TYPE, ALLOCATOR> *d_deque_p;
2017 std::size_t d_count;
2018 bool d_isTail;
2019
2020 private:
2021 // NOT IMPLEMENTED
2022 Deque_Guard(const Deque_Guard&);
2023 Deque_Guard& operator=(const Deque_Guard&);
2024
2025 public:
2026 // CREATORS
2027
2028 /// Initializes object to guard 0 items from the specified `deque`.
2029 /// This guards either the tail or the head, as determined by the
2030 /// specified `isTail` boolean.
2031 Deque_Guard(deque<VALUE_TYPE, ALLOCATOR> *deque, bool isTail);
2032
2033 /// Call the (template parameter) `VALUE_TYPE` destructor on objects in
2034 /// the range `[d.end() .. d.end() + count())` if `isTail` was specified
2035 /// as `true` during construction, or
2036 /// `[d.start() - count() .. d.start()]` if `isTail` was specified as
2037 /// `false` during construction, where `d` is the deque used to
2038 /// construct this guard.
2039 ~Deque_Guard();
2040
2041 // MANIPULATORS
2042
2043 /// Increment the count of this guard, and return the new count.
2044 std::size_t operator++();
2045
2046 /// Decrement the count of this guard, and return the new count.
2047 std::size_t operator--();
2048
2049 /// Set the count of this guard to 0.
2050 /// \note Note that this guard's destructor
2051 /// will do nothing if count is not incremented again after this call.
2052 void release();
2053
2054 // ACCESSORS
2055
2056 /// Return the current count maintained by this guard.
2057 std::size_t count() const BSLS_KEYWORD_NOEXCEPT;
2058
2059 /// Return a pointer after the first item in the guarded range.
2060 IteratorImp begin() const BSLS_KEYWORD_NOEXCEPT;
2061
2062 /// Return a pointer after the last item in the guarded range.
2063 IteratorImp end() const BSLS_KEYWORD_NOEXCEPT;
2064};
2065
2066// ============================================================================
2067// TEMPLATE AND INLINE FUNCTION DEFINITIONS
2068// ============================================================================
2069
2070// See IMPLEMENTATION NOTES in the .cpp before modifying anything below.
2071
2072 // ----------------
2073 // class Deque_Base
2074 // ----------------
2075
2076// MANIPULATORS
2077template <class VALUE_TYPE>
2078inline
2079typename Deque_Base<VALUE_TYPE>::iterator
2080Deque_Base<VALUE_TYPE>::begin() BSLS_KEYWORD_NOEXCEPT
2081{
2082 return d_start;
2083}
2084
2085template <class VALUE_TYPE>
2086inline
2087typename Deque_Base<VALUE_TYPE>::iterator
2088Deque_Base<VALUE_TYPE>::end() BSLS_KEYWORD_NOEXCEPT
2089{
2090 return d_finish;
2091}
2092
2093template <class VALUE_TYPE>
2094inline
2095typename Deque_Base<VALUE_TYPE>::reverse_iterator
2096Deque_Base<VALUE_TYPE>::rbegin() BSLS_KEYWORD_NOEXCEPT
2097{
2098 return reverse_iterator(end());
2099}
2100
2101template <class VALUE_TYPE>
2102inline
2103typename Deque_Base<VALUE_TYPE>::reverse_iterator
2104Deque_Base<VALUE_TYPE>::rend() BSLS_KEYWORD_NOEXCEPT
2105{
2106 return reverse_iterator(begin());
2107}
2108
2109template <class VALUE_TYPE>
2110inline
2111typename Deque_Base<VALUE_TYPE>::reference
2112Deque_Base<VALUE_TYPE>::operator[](size_type position)
2113{
2114 BSLS_ASSERT_SAFE(position < size());
2115
2116 return *(begin() + position);
2117}
2118
2119template <class VALUE_TYPE>
2120typename Deque_Base<VALUE_TYPE>::reference
2121Deque_Base<VALUE_TYPE>::at(size_type position)
2122{
2123 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(position >= size())) {
2125
2126 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
2127 "deque<...>::at(n): invalid position");
2128 }
2129 return *(begin() + position);
2130}
2131
2132template <class VALUE_TYPE>
2133inline
2134typename Deque_Base<VALUE_TYPE>::reference
2135Deque_Base<VALUE_TYPE>::front()
2136{
2138
2139 return *d_start;
2140}
2141
2142template <class VALUE_TYPE>
2143inline
2144typename Deque_Base<VALUE_TYPE>::reference
2145Deque_Base<VALUE_TYPE>::back()
2146{
2148
2149 IteratorImp backIterator = d_finish;
2150 --backIterator;
2151 return *backIterator;
2152}
2153
2154// ACCESSORS
2155template <class VALUE_TYPE>
2156inline
2157typename Deque_Base<VALUE_TYPE>::const_iterator
2158Deque_Base<VALUE_TYPE>::begin() const BSLS_KEYWORD_NOEXCEPT
2159{
2160 return d_start;
2161}
2162
2163template <class VALUE_TYPE>
2164inline
2165typename Deque_Base<VALUE_TYPE>::const_iterator
2166Deque_Base<VALUE_TYPE>::cbegin() const BSLS_KEYWORD_NOEXCEPT
2167{
2168 return d_start;
2169}
2170
2171template <class VALUE_TYPE>
2172inline
2173typename Deque_Base<VALUE_TYPE>::const_iterator
2174Deque_Base<VALUE_TYPE>::end() const BSLS_KEYWORD_NOEXCEPT
2175{
2176 return d_finish;
2177}
2178
2179template <class VALUE_TYPE>
2180inline
2181typename Deque_Base<VALUE_TYPE>::const_iterator
2182Deque_Base<VALUE_TYPE>::cend() const BSLS_KEYWORD_NOEXCEPT
2183{
2184 return d_finish;
2185}
2186
2187template <class VALUE_TYPE>
2188inline
2189typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2190Deque_Base<VALUE_TYPE>::rbegin() const BSLS_KEYWORD_NOEXCEPT
2191{
2192 return const_reverse_iterator(end());
2193}
2194
2195template <class VALUE_TYPE>
2196inline
2197typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2198Deque_Base<VALUE_TYPE>::crbegin() const BSLS_KEYWORD_NOEXCEPT
2199{
2200 return const_reverse_iterator(end());
2201}
2202
2203template <class VALUE_TYPE>
2204inline
2205typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2206Deque_Base<VALUE_TYPE>::rend() const BSLS_KEYWORD_NOEXCEPT
2207{
2208 return const_reverse_iterator(begin());
2209}
2210
2211template <class VALUE_TYPE>
2212inline
2213typename Deque_Base<VALUE_TYPE>::const_reverse_iterator
2214Deque_Base<VALUE_TYPE>::crend() const BSLS_KEYWORD_NOEXCEPT
2215{
2216 return const_reverse_iterator(begin());
2217}
2218
2219template <class VALUE_TYPE>
2220inline
2221typename Deque_Base<VALUE_TYPE>::size_type
2222Deque_Base<VALUE_TYPE>::size() const BSLS_KEYWORD_NOEXCEPT
2223{
2224 return d_finish - d_start;
2225}
2226
2227template <class VALUE_TYPE>
2228typename Deque_Base<VALUE_TYPE>::size_type
2229Deque_Base<VALUE_TYPE>::capacity() const BSLS_KEYWORD_NOEXCEPT
2230{
2231 // 'allocateBlockPtrs', which creates the 'd_blocks_p' array,
2232 // does not, in its contract, guarantee to initialize the array to 0.
2233 // Since we read these values, we have to make sure they're initialized to
2234 // avoid purify 'read before write' errors. Note that we initialize them
2235 // to null in which case they are not valid pointers, but we never
2236 // dereference them, and the pointer arithmetic we do on them will still
2237 // work.
2238
2239 if (d_start.blockPtr() > d_blocks_p) {
2240 d_blocks_p[0] = 0;
2241 }
2242 if (d_finish.blockPtr() < d_blocks_p + d_blocksLength - 1) {
2243 d_blocks_p[d_blocksLength - 1] = 0;
2244 }
2245
2246 const IteratorImp first(d_blocks_p);
2247
2248 // 'last' points to the empty slot at the end of the last block in
2249 // 'd_blocks_p', which might not actually be there.
2250
2251 IteratorImp last(d_blocks_p + d_blocksLength - 1);
2252 last += BLOCK_LENGTH - 1;
2253
2254 BSLS_ASSERT_SAFE(!(d_start < first)); // 'IteratorImp' has no '>='
2255 BSLS_ASSERT_SAFE(!(last < d_finish));
2256
2257 const size_type frontCapacity = d_finish - first;
2258 const size_type backCapacity = last - d_start;
2259
2260 // Return the min (we are below 'bsl_algorithm.h', so we have to do it by
2261 // hand).
2262
2263 return frontCapacity < backCapacity ? frontCapacity : backCapacity;
2264}
2265
2266template <class VALUE_TYPE>
2267inline
2268bool Deque_Base<VALUE_TYPE>::empty() const BSLS_KEYWORD_NOEXCEPT
2269{
2270 return d_start == d_finish;
2271}
2272
2273template <class VALUE_TYPE>
2274inline
2275typename Deque_Base<VALUE_TYPE>::const_reference
2276Deque_Base<VALUE_TYPE>::operator[](size_type position) const
2277{
2278 BSLS_ASSERT_SAFE(position < size());
2279
2280 return *(begin() + position);
2281}
2282
2283template <class VALUE_TYPE>
2284typename Deque_Base<VALUE_TYPE>::const_reference
2285Deque_Base<VALUE_TYPE>::at(size_type position) const
2286{
2287 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(position >= size())) {
2289
2290 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
2291 "const deque<...>::at(n): invalid position");
2292 }
2293 return *(begin() + position);
2294}
2295
2296template <class VALUE_TYPE>
2297inline
2298typename Deque_Base<VALUE_TYPE>::const_reference
2299Deque_Base<VALUE_TYPE>::front() const
2300{
2302
2303 return *d_start;
2304}
2305
2306template <class VALUE_TYPE>
2307inline
2308typename Deque_Base<VALUE_TYPE>::const_reference
2309Deque_Base<VALUE_TYPE>::back() const
2310{
2312
2313 IteratorImp backIterator = d_finish;
2314 --backIterator;
2315 return *backIterator;
2316}
2317
2318 // -----------
2319 // class deque
2320 // -----------
2321
2322// PRIVATE CREATORS
2323template <class VALUE_TYPE, class ALLOCATOR>
2324inline
2325deque<VALUE_TYPE, ALLOCATOR>::deque(RawInit, const ALLOCATOR& allocator)
2326: Deque_Base<VALUE_TYPE>()
2327, ContainerBase(allocator)
2328{
2329 this->d_blocks_p = 0;
2330}
2331
2332// PRIVATE MANIPULATORS
2333template <class VALUE_TYPE, class ALLOCATOR>
2334inline
2335typename deque<VALUE_TYPE, ALLOCATOR>::Block *
2336deque<VALUE_TYPE, ALLOCATOR>::allocateBlock()
2337{
2338 return AllocatorUtil::allocateObject<Block>(this->allocatorRef());
2339}
2340
2341template <class VALUE_TYPE, class ALLOCATOR>
2342inline
2343typename deque<VALUE_TYPE, ALLOCATOR>::BlockPtr *
2344deque<VALUE_TYPE, ALLOCATOR>::allocateBlockPtrs(std::size_t n)
2345{
2346 return AllocatorUtil::allocateObject<BlockPtr>(this->allocatorRef(), n);
2347}
2348
2349template <class VALUE_TYPE, class ALLOCATOR>
2350inline
2351void deque<VALUE_TYPE, ALLOCATOR>::deallocateBlock(Block *p)
2352{
2353 AllocatorUtil::deallocateObject(this->allocatorRef(), p);
2354}
2355
2356template <class VALUE_TYPE, class ALLOCATOR>
2357inline
2358void
2359deque<VALUE_TYPE, ALLOCATOR>::deallocateBlockPtrs(BlockPtr *p, std::size_t n)
2360{
2361 AllocatorUtil::deallocateObject(this->allocatorRef(), p, n);
2362}
2363
2364template <class VALUE_TYPE, class ALLOCATOR>
2365template <class INPUT_ITERATOR, class SENTINEL>
2366inline
2367typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2368deque<VALUE_TYPE, ALLOCATOR>::privateAppend(INPUT_ITERATOR first,
2369 SENTINEL last)
2370{
2371 if (first == last) {
2372 return 0; // RETURN
2373 }
2374 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
2375 return privateAppend(first, last, Tag());
2376}
2377
2378template <class VALUE_TYPE, class ALLOCATOR>
2379template <class INPUT_ITERATOR, class SENTINEL>
2380typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2381deque<VALUE_TYPE, ALLOCATOR>::privateAppend(
2382 INPUT_ITERATOR first,
2383 SENTINEL last,
2384 std::random_access_iterator_tag)
2385{
2386 BlockCreator newBlocks(this);
2387 Guard guard(this, true);
2388
2389 const size_type numElements =
2390 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2392 numElements > max_size() - this->size())) {
2394
2395 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2396 "deque<...>::insert(pos,n,v): deque too big");
2397 }
2398
2399 for ( ; first != last; ++first) {
2400 IteratorImp insertPoint = guard.end();
2401
2402 // There must be room for the iterator to be incremented. Allocate new
2403 // block now if necessary. We cannot wait until after the new element
2404 // is constructed or else we won't be able to increment the guard right
2405 // away and there will be a window where an exception will cause a
2406 // resource leak.
2407
2408 if (1 == insertPoint.remainingInBlock()) {
2409 newBlocks.insertAtBack(1);
2410 insertPoint = guard.end(); // 'insertAtBack(1)' invalidated
2411 // iterator
2412 }
2413 AllocatorTraits::construct(this->allocatorRef(),
2414 BSLS_UTIL_ADDRESSOF(*insertPoint),
2415 *first);
2416 ++guard;
2417 }
2418
2419 this->d_finish += guard.count();
2420
2421 guard.release();
2422 return numElements;
2423}
2424
2425template <class VALUE_TYPE, class ALLOCATOR>
2426template <class INPUT_ITERATOR, class SENTINEL>
2427typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2428deque<VALUE_TYPE, ALLOCATOR>::privateAppend(INPUT_ITERATOR first,
2429 SENTINEL last,
2430 std::input_iterator_tag)
2431{
2432 BlockCreator newBlocks(this);
2433 Guard guard(this, true);
2434
2435 size_type numElements = 0;
2436 size_type maxNumElements = max_size() - this->size();
2437 for ( ; first != last; ++first) {
2438 ++numElements;
2440 numElements > maxNumElements)) {
2442
2443 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2444 "deque<...>::insert(pos,n,v): deque too big");
2445 }
2446 IteratorImp insertPoint = guard.end();
2447
2448 // There must be room for the iterator to be incremented. Allocate new
2449 // block now if necessary. We cannot wait until after the new element
2450 // is constructed or else we won't be able to increment the guard right
2451 // away and there will be a window where an exception will cause a
2452 // resource leak.
2453
2454 if (1 == insertPoint.remainingInBlock()) {
2455 newBlocks.insertAtBack(1);
2456 insertPoint = guard.end(); // 'insertAtBack(1)' invalidated
2457 // iterator
2458 }
2459
2460 AllocatorTraits::construct(this->allocatorRef(),
2461 BSLS_UTIL_ADDRESSOF(*insertPoint),
2462 *first);
2463 ++guard;
2464 }
2465
2466 this->d_finish += guard.count();
2467
2468 guard.release();
2469 return numElements;
2470}
2471
2472template <class VALUE_TYPE, class ALLOCATOR>
2473void deque<VALUE_TYPE, ALLOCATOR>::privateAppendDefaultInsertable(
2474 size_type numElements)
2475{
2476 // Create new blocks at the back. In case an exception is thrown, any
2477 // unused blocks are returned to the allocator.
2478
2479 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements) /
2480 BLOCK_LENGTH;
2481 BlockCreator newBlocks(this);
2482 newBlocks.insertAtBack(numNewBlocks);
2483 DequePrimitives::valueInititalizeN(&this->d_finish,
2484 this->d_finish,
2485 numElements,
2486 this->allocatorRef());
2487}
2488
2489template <class VALUE_TYPE, class ALLOCATOR>
2490void deque<VALUE_TYPE, ALLOCATOR>::privateAppendRaw(
2491 size_type numElements,
2492 const VALUE_TYPE& value)
2493{
2494 // Create new blocks at the back. In case an exception is thrown, any
2495 // unused blocks are returned to the allocator.
2496
2497 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements) /
2498 BLOCK_LENGTH;
2499 BlockCreator newBlocks(this);
2500 newBlocks.insertAtBack(numNewBlocks);
2501
2502 DequePrimitives::uninitializedFillNBack(&this->d_finish,
2503 this->d_finish,
2504 numElements,
2505 value,
2506 this->allocatorRef());
2507}
2508
2509template <class VALUE_TYPE, class ALLOCATOR>
2510template <class t_ITERATOR, class t_SENTINEL>
2511void deque<VALUE_TYPE, ALLOCATOR>::privateAssign(t_ITERATOR first,
2512 t_SENTINEL last)
2513{
2514 typedef typename iterator_traits<t_ITERATOR>::iterator_category Tag;
2515
2516 // If an exception is thrown, clear the deque to provide standard behavior,
2517 // which is:
2518 // ```
2519 // erase(begin(), end());
2520 // insert(begin(), first, last);
2521 // ```
2522
2523 ClearGuard guard(this);
2524
2525 // Copy over existing elements.
2526
2527 IteratorImp i;
2528 for (i = this->d_start; !(i == this->d_finish) && first != last;
2529 ++i, ++first) {
2530 *i = *first;
2531 }
2532
2533 if (!(i == this->d_finish)) {
2534 // Erase elements past the last one copied.
2535
2536 erase(i, this->end());
2537 }
2538 else {
2539 // Still more elements to copy. Append them.
2540
2541 privateAppend(first, last, Tag());
2542 }
2543
2544 guard.release();
2545}
2546
2547template <class VALUE_TYPE, class ALLOCATOR>
2548void deque<VALUE_TYPE, ALLOCATOR>::privateInit(size_type numElements)
2549{
2550 size_type blocksLength = numElements / BLOCK_LENGTH + 1 +
2551 2 * Imp::BLOCK_ARRAY_PADDING;
2552
2553 // Allocate block pointer array.
2554
2555 this->d_blocks_p = this->allocateBlockPtrs(blocksLength);
2556
2557 this->d_blocksLength = blocksLength;
2558
2559 // Allocate the first block and store its pointer into the array. Leave a
2560 // little room at the front and back of the array for growth.
2561
2562 BlockPtr *firstBlockPtr = &this->d_blocks_p[Imp::BLOCK_ARRAY_PADDING];
2563 *firstBlockPtr = this->allocateBlock();
2564
2565 // Calculate the offset into the first block such that 'n' elements will
2566 // leave equal space at the front of the first block and at the end of the
2567 // last block, remembering that the last element of the last block cannot
2568 // be used. Centering the elements reduces the chance that either
2569 // 'push_back' or 'push_front' will need to allocate a new block. In case
2570 // of an odd number of unused elements, slight preference is given to
2571 // 'push_back' over 'push_front'.
2572
2573 const int offset = static_cast<int>(
2574 (BLOCK_LENGTH - 1 - numElements % BLOCK_LENGTH) / 2);
2575
2576 // Initialize the begin and end iterators.
2577
2578 this->d_start = this->d_finish = IteratorImp(
2579 firstBlockPtr,
2580 (*firstBlockPtr)->d_data + offset);
2581}
2582
2583template <class VALUE_TYPE, class ALLOCATOR>
2584template <class INTEGRAL_TYPE>
2585inline
2586void deque<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
2587 const_iterator position,
2588 INTEGRAL_TYPE numElements,
2589 INTEGRAL_TYPE value,
2590 BloombergLP::bslmf::MatchArithmeticType,
2591 BloombergLP::bslmf::Nil)
2592{
2593 insert(position,
2594 static_cast<size_type>(numElements),
2595 static_cast<VALUE_TYPE>(value));
2596}
2597
2598template <class VALUE_TYPE, class ALLOCATOR>
2599template <class INPUT_ITERATOR>
2600void deque<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
2601 const_iterator position,
2602 INPUT_ITERATOR first,
2603 INPUT_ITERATOR last,
2604 BloombergLP::bslmf::MatchAnyType,
2605 BloombergLP::bslmf::MatchAnyType)
2606{
2607 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
2608
2609 if (first == last) {
2610 return; // RETURN
2611 }
2612
2613 if (position == this->cbegin()) {
2614 privatePrepend(first, last, Tag());
2615 return; // RETURN
2616 }
2617
2618 if (position == this->cend()) {
2619 privateAppend(first, last, Tag());
2620 return; // RETURN
2621 }
2622
2623 privateInsert(position, first, last, Tag());
2624}
2625
2626template <class VALUE_TYPE, class ALLOCATOR>
2627template <class INPUT_ITERATOR, class SENTINEL>
2628inline
2629void deque<VALUE_TYPE, ALLOCATOR>::privateInsert(const_iterator position,
2630 INPUT_ITERATOR first,
2631 SENTINEL last)
2632{
2633 if (first == last) {
2634 return; // RETURN
2635 }
2636
2637 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
2638 if (position == this->cbegin()) {
2639 privatePrepend(first, last, Tag());
2640 }
2641 else if (position == this->cend()) {
2642 privateAppend(first, last, Tag());
2643 }
2644 else {
2645 privateInsert(position, first, last, Tag());
2646 }
2647}
2648
2649template <class VALUE_TYPE, class ALLOCATOR>
2650template <class INPUT_ITERATOR, class SENTINEL>
2651void deque<VALUE_TYPE, ALLOCATOR>::privateInsert(
2652 const_iterator position,
2653 INPUT_ITERATOR first,
2654 SENTINEL last,
2655 std::input_iterator_tag tag)
2656{
2657 BSLS_ASSERT(first != last);
2658
2659 iterator pos(position.imp());
2660 const size_type currentSize = this->size();
2661 const size_type posIdx = pos - this->begin();
2662
2663 deque temp(k_RAW_INIT, this->get_allocator());
2664 privateSplit(&temp, position.imp());
2665
2666 if (posIdx <= currentSize / 2) {
2667 Deque_Util::swap(
2668 static_cast<Base *>(this), static_cast<Base *>(&temp));
2669 privatePrepend(first, last, tag);
2670 privateJoinPrepend(&temp);
2671 }
2672 else {
2673 privateAppend(first, last, tag);
2674 privateJoinAppend(&temp);
2675 }
2676}
2677
2678template <class VALUE_TYPE, class ALLOCATOR>
2679void deque<VALUE_TYPE, ALLOCATOR>::privateSplit(
2680 deque<VALUE_TYPE, ALLOCATOR> *other,
2681 IteratorImp pos)
2682{
2683 // BEFORE:
2684 //..
2685 // this->d_start.valuePtr() -----------+
2686 // V
2687 // this->d_start.blockPtr() --> H -> __AAA
2688 // I -> AAAAA
2689 // pos.blockPtr() -> J -> BBBxx <- pos.valuePtr() (at 1st x)
2690 // K -> yyyyy
2691 // this->d_finish.blockPtr() -> L -> y____
2692 // ^
2693 // +- this->d_finish.valuePtr()
2694 //
2695 // AFTER:
2696 // this->d_start.valuePtr() -----------+
2697 // V
2698 // this->d_start.blockPtr() --> H -> __AAA
2699 // I -> AAAAA
2700 // this->d_finish.blockPtr() -> J -> BBB__
2701 // ^
2702 // +- this->d_finish.valuePtr()
2703 //
2704 // other->d_start.valuePtr() ------------+
2705 // V
2706 // other->d_start.blockPtr() --> M -> ___xx
2707 // K -> yyyyy
2708 // other->d_finish.blockPtr() -> L -> y____
2709 // ^
2710 // +- other->d_finish.valuePtr()
2711 //
2712 // assert(! other.d_blocks_p);
2713 //..
2714
2715 if (pos.blockPtr() == this->d_finish.blockPtr()) {
2716 // Split point is in last block. Just copy portion after the split to
2717 // new block in 'other'.
2718
2719 difference_type numAfter = this->d_finish.valuePtr() - pos.valuePtr();
2720 other->privateInit(numAfter);
2721 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2722 other->d_start.valuePtr(),
2723 pos.valuePtr(),
2724 this->d_finish.valuePtr(),
2725 this->allocatorRef());
2726 other->d_finish += numAfter;
2727 this->d_finish = pos;
2728 return; // RETURN
2729 }
2730
2731 if (pos.blockPtr() == this->d_start.blockPtr()) {
2732 // Split point is in first block. Copy portion before the split to new
2733 // block in 'other' and swap.
2734
2735 difference_type numBefore = pos.valuePtr() - this->d_start.valuePtr();
2736 other->privateInit(numBefore);
2737 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2738 other->d_start.valuePtr(),
2739 this->d_start.valuePtr(),
2740 pos.valuePtr(),
2741 this->allocatorRef());
2742 other->d_finish += numBefore;
2743 this->d_start = pos;
2744 Deque_Util::swap(
2745 static_cast<Base *>(this), static_cast<Base *>(other));
2746 return; // RETURN
2747 }
2748
2749 // Compute number of unsplit blocks to move.
2750
2751 difference_type numMoveBlocks = this->d_finish.blockPtr() - pos.blockPtr();
2752
2753 size_type otherBlocksLength = numMoveBlocks + 1 +
2754 2 * Imp::BLOCK_ARRAY_PADDING;
2755
2756 other->d_blocks_p = this->allocateBlockPtrs(otherBlocksLength);
2757 other->d_blocksLength = otherBlocksLength;
2758
2759 // Good time to allocate block for exception safety.
2760
2761 Block *newBlock = this->allocateBlock();
2762
2763 // The following chunk of code will never throw an exception. Move unsplit
2764 // blocks from 'this' to 'other', then adjust the iterators.
2765
2766 std::memcpy(other->d_blocks_p + 1 + Imp::BLOCK_ARRAY_PADDING,
2767 pos.blockPtr() + 1,
2768 sizeof(BlockPtr) * numMoveBlocks);
2769
2770 other->d_start = IteratorImp(&other->d_blocks_p[
2771 1 + Imp::BLOCK_ARRAY_PADDING]);
2772 other->d_finish = IteratorImp(other->d_start.blockPtr() +
2773 numMoveBlocks - 1,
2774 this->d_finish.valuePtr());
2775
2776 BlockPtr *newBlockPtr = pos.blockPtr() + 1;
2777 *newBlockPtr = newBlock;
2778 this->d_finish = IteratorImp(newBlockPtr);
2779
2780 // Current situation:
2781 //..
2782 // this->d_start.valuePtr() -----------+
2783 // V
2784 // this->d_start.blockPtr() --> H -> __AAA
2785 // I -> AAAAA
2786 // pos.blockPtr() -> J -> BBBxx <- pos.valuePtr() (1st x)
2787 // this->d_finish.blockPtr() -> M -> _____
2788 // / ^
2789 // newBlockPtr -+ +- this->d_finish.valuePtr()
2790 //
2791 // other->d_start.valuePtr() ---------+
2792 // V
2793 // other->d_start.blockPtr() --> K -> yyyyy
2794 // other->d_finish.blockPtr() -> L -> y____
2795 // ^
2796 // +- other->d_finish.valuePtr()
2797 //..
2798 // Now we split the block containing "BBBxx" into two blocks, with the "xx"
2799 // part going into '*newBlockPtr'. An exception can safely occur here
2800 // because the 'bslalg::ArrayPrimitives' functions are exception-neutral
2801 // and because all class invariants for both '*this' and 'other' hold going
2802 // in to this section.
2803
2804 size_type splitOffset = pos.offsetInBlock();
2805 if (splitOffset >= pos.remainingInBlock()) {
2806 // Move the tail part of the block into the new block.
2807
2808 value_type *splitValuePtr = newBlock->d_data + splitOffset;
2809 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2810 splitValuePtr,
2811 pos.valuePtr(),
2812 pos.blockEnd(),
2813 this->allocatorRef());
2814 }
2815 else {
2816 // Move the head part of the block into the new block, then swap the
2817 // blocks within the 'd_blocks_p' array.
2818
2819 BloombergLP::bslalg::ArrayPrimitives::destructiveMove(
2820 newBlock->d_data,
2821 pos.blockBegin(),
2822 pos.valuePtr(),
2823 this->allocatorRef());
2824 *newBlockPtr = *pos.blockPtr();
2825 *pos.blockPtr() = newBlock;
2826 }
2827
2828 // Move block to 'other' and adjust the iterators. This will not throw.
2829
2830 this->d_finish = IteratorImp(&newBlockPtr[-1],
2831 newBlockPtr[-1]->d_data + splitOffset);
2832 other->d_start.previousBlock();
2833 *(other->d_start.blockPtr()) = *newBlockPtr;
2834 other->d_start = IteratorImp(other->d_start.blockPtr(),
2835 other->d_start.blockBegin() + splitOffset);
2836}
2837
2838template <class VALUE_TYPE, class ALLOCATOR>
2839inline
2840void deque<VALUE_TYPE, ALLOCATOR>::privateJoinPrepend(
2841 deque<VALUE_TYPE, ALLOCATOR> *other)
2842{
2843 privatePrepend(other->begin(),
2844 other->end(),
2845 std::random_access_iterator_tag());
2846
2847 // Make 'other' raw again, and free its resources.
2848
2849 deque<VALUE_TYPE, ALLOCATOR> temp(k_RAW_INIT, other->allocatorRef());
2850 Deque_Util::move(static_cast<Base *>(&temp), static_cast<Base *>(other));
2851}
2852
2853template <class VALUE_TYPE, class ALLOCATOR>
2854inline
2855void deque<VALUE_TYPE, ALLOCATOR>::privateJoinAppend(
2856 deque<VALUE_TYPE, ALLOCATOR> *other)
2857{
2858 privateAppend(other->begin(),
2859 other->end(),
2860 std::random_access_iterator_tag());
2861
2862 // Make 'other' raw again, and free its resources.
2863
2864 deque<VALUE_TYPE, ALLOCATOR> temp(k_RAW_INIT, other->allocatorRef());
2865 Deque_Util::move(static_cast<Base *>(&temp), static_cast<Base *>(other));
2866}
2867
2868template <class VALUE_TYPE, class ALLOCATOR>
2869template <class INPUT_ITERATOR, class SENTINEL>
2870void deque<VALUE_TYPE, ALLOCATOR>::privateInsert(
2871 const_iterator position,
2872 INPUT_ITERATOR first,
2873 SENTINEL last,
2874 std::random_access_iterator_tag tag)
2875{
2876 BSLS_ASSERT(first != last);
2877
2878 if (position == this->cbegin()) {
2879 privatePrepend(first, last, tag);
2880 return; // RETURN
2881 }
2882
2883 if (position == this->cend()) {
2884 privateAppend(first, last, tag);
2885 return; // RETURN
2886 }
2887
2888 const size_type currentSize = this->size();
2889 const size_type numElements =
2890 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
2892 numElements > max_size() - currentSize)) {
2894
2895 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
2896 "deque<...>::insert(pos,n,v): deque too big");
2897 }
2898
2899 iterator pos(position.imp());
2900 const size_type posIdx = position - this->cbegin();
2901 if (posIdx <= currentSize / 2) {
2902 // Create new blocks at the front. In case an exception is thrown, any
2903 // unused blocks are returned to the allocator.
2904
2905 size_type numNewBlocks = (this->d_start.remainingInBlock()
2906 + numElements - 1) / BLOCK_LENGTH;
2907 BlockCreator newBlocks(this);
2908 newBlocks.insertAtFront(numNewBlocks);
2909
2910 DequePrimitives::insertAndMoveToFront(&this->d_start,
2911 this->d_start,
2912 this->d_start + posIdx,
2913 first,
2914 last,
2915 numElements,
2916 this->allocatorRef());
2917 } else {
2918 // Create new blocks at front. In case an exception is thrown, any
2919 // unused blocks are returned to the allocator.
2920
2921 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements)
2922 / BLOCK_LENGTH;
2923 BlockCreator newBlocks(this);
2924 newBlocks.insertAtBack(numNewBlocks);
2925
2926 DequePrimitives::insertAndMoveToBack(&this->d_finish,
2927 this->d_finish,
2928 this->d_start + posIdx,
2929 first,
2930 last,
2931 numElements,
2932 this->allocatorRef());
2933 }
2934}
2935
2936template <class VALUE_TYPE, class ALLOCATOR>
2937void deque<VALUE_TYPE, ALLOCATOR>::privatePrependRaw(
2938 size_type numElements,
2939 const VALUE_TYPE& value)
2940{
2941 // Create new blocks at front. In case an exception is thrown, any unused
2942 // blocks are returned to the allocator.
2943
2944 size_type numNewBlocks = (this->d_start.remainingInBlock() +
2945 numElements - 1) / BLOCK_LENGTH;
2946 BlockCreator newBlocks(this);
2947 newBlocks.insertAtFront(numNewBlocks);
2948
2949 DequePrimitives::uninitializedFillNFront(&this->d_start,
2950 this->d_start,
2951 numElements,
2952 value,
2953 this->allocatorRef());
2954}
2955
2956template <class VALUE_TYPE, class ALLOCATOR>
2957template <class INPUT_ITERATOR, class SENTINEL>
2958inline
2959typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2960deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(INPUT_ITERATOR first,
2961 SENTINEL last)
2962{
2963 if (first == last) {
2964 return 0; // RETURN
2965 }
2966 typedef typename iterator_traits<INPUT_ITERATOR>::iterator_category Tag;
2967 return privatePrepend(first, last, Tag());
2968}
2969
2970template <class VALUE_TYPE, class ALLOCATOR>
2971template <class INPUT_ITERATOR, class SENTINEL>
2972typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2973deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(INPUT_ITERATOR first,
2974 SENTINEL last,
2975 std::input_iterator_tag tag)
2976{
2977 deque temp(k_RAW_INIT, this->get_allocator());
2978 temp.privateInit(this->size() + 1);
2979 size_type numElements = temp.privateAppend(first, last, tag);
2980
2981 // Check whether appending or prepending is more economical.
2982
2983 if (numElements > this->size()) {
2984 Deque_Util::swap((Base *)this, (Base *)&temp);
2985 privateJoinAppend(&temp);
2986 }
2987 else {
2988 privateJoinPrepend(&temp);
2989 }
2990
2991 return numElements;
2992}
2993
2994template <class VALUE_TYPE, class ALLOCATOR>
2995template <class INPUT_ITERATOR, class SENTINEL>
2996typename deque<VALUE_TYPE, ALLOCATOR>::size_type
2997deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(
2998 INPUT_ITERATOR first,
2999 SENTINEL last,
3000 std::bidirectional_iterator_tag)
3001{
3002
3003 BlockCreator newBlocks(this);
3004 Guard guard(this, false);
3005
3006 size_type numElements = 0;
3007 size_type maxNumElements = max_size() - this->size();
3008 do {
3009 ++numElements;
3011 numElements > maxNumElements)) {
3013
3014 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3015 "deque<...>::insert(pos,n,v): deque too big");
3016 }
3017
3018 IteratorImp insertPoint = guard.begin();
3019
3020 // There must be room for the iterator to be decremented. Allocate new
3021 // block now if necessary, with same caveat as above.
3022
3023 if (insertPoint.valuePtr() == insertPoint.blockBegin()) {
3024 newBlocks.insertAtFront(1);
3025 insertPoint = guard.begin(); // 'insertAtFront' invalidates
3026 // 'insertPoint'
3027 }
3028 --insertPoint;
3029 AllocatorTraits::construct(this->allocatorRef(),
3030 BSLS_UTIL_ADDRESSOF(*insertPoint),
3031 *--last);
3032 ++guard;
3033 } while (first != last);
3034
3035 this->d_start -= guard.count();
3036 guard.release();
3037 return numElements;
3038}
3039
3040template <class VALUE_TYPE, class ALLOCATOR>
3041template <class INPUT_ITERATOR, class SENTINEL>
3042typename deque<VALUE_TYPE, ALLOCATOR>::size_type
3043deque<VALUE_TYPE, ALLOCATOR>::privatePrepend(
3044 INPUT_ITERATOR first,
3045 SENTINEL last,
3046 std::random_access_iterator_tag)
3047{
3048 BSLS_ASSERT_OPT((BloombergLP::bslstl::IteratorUtil
3049 ::canCalculateInsertDistance<INPUT_ITERATOR, SENTINEL>()));
3050 const size_type numElements =
3051 BloombergLP::bslstl::IteratorUtil::insertDistance(first, last);
3053 numElements > max_size() - this->size())) {
3055
3056 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3057 "deque<...>::insert(pos,n,v): deque too big");
3058 }
3059
3060 BlockCreator newBlocks(this);
3061 Guard guard(this, false);
3062
3063#ifdef BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES
3064 INPUT_ITERATOR end;
3065 if constexpr (std::is_same_v<INPUT_ITERATOR, SENTINEL>) {
3066 end = last;
3067 }
3068 else {
3069 end = first + numElements;
3070 BSLS_ASSERT_SAFE(end == last);
3071 }
3072#else
3073 INPUT_ITERATOR end = last;
3074#endif
3075 do {
3076 IteratorImp insertPoint = guard.begin();
3077
3078 // There must be room for the iterator to be decremented. Allocate new
3079 // block now if necessary, with same caveat as above.
3080
3081 if (insertPoint.valuePtr() == insertPoint.blockBegin()) {
3082 newBlocks.insertAtFront(1);
3083 insertPoint = guard.begin(); // 'insertAtFront' invalidates
3084 // 'insertPoint'
3085 }
3086 --insertPoint;
3087 AllocatorTraits::construct(this->allocatorRef(),
3088 BSLS_UTIL_ADDRESSOF(*insertPoint),
3089 *--end);
3090 ++guard;
3091 } while (first != end);
3092
3093 this->d_start -= guard.count();
3094 guard.release();
3095 return numElements;
3096}
3097
3098// CREATORS
3099template <class VALUE_TYPE, class ALLOCATOR>
3100deque<VALUE_TYPE, ALLOCATOR>::deque()
3101: Deque_Base<VALUE_TYPE>()
3102, ContainerBase(ALLOCATOR())
3103{
3104 deque temp(k_RAW_INIT, this->get_allocator());
3105 temp.privateInit(0);
3106 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3107}
3108
3109template <class VALUE_TYPE, class ALLOCATOR>
3110deque<VALUE_TYPE, ALLOCATOR>::deque(const ALLOCATOR& basicAllocator)
3111: Deque_Base<VALUE_TYPE>()
3112, ContainerBase(basicAllocator)
3113{
3114 deque temp(k_RAW_INIT, this->get_allocator());
3115 temp.privateInit(0);
3116 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3117}
3118
3119template <class VALUE_TYPE, class ALLOCATOR>
3120deque<VALUE_TYPE, ALLOCATOR>::deque(size_type numElements,
3121 const ALLOCATOR& basicAllocator)
3122: Deque_Base<VALUE_TYPE>()
3123, ContainerBase(basicAllocator)
3124{
3125 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(numElements > max_size())) {
3127
3128 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3129 "deque<...>::deque(n): deque too big");
3130 }
3131 deque temp(k_RAW_INIT, this->get_allocator());
3132 temp.privateInit(numElements);
3133 temp.privateAppendDefaultInsertable(numElements);
3134 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3135}
3136
3137template <class VALUE_TYPE, class ALLOCATOR>
3138deque<VALUE_TYPE, ALLOCATOR>::deque(size_type numElements,
3139 const VALUE_TYPE& value,
3140 const ALLOCATOR& basicAllocator)
3141: Deque_Base<VALUE_TYPE>()
3142, ContainerBase(basicAllocator)
3143{
3144 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(numElements > max_size())) {
3146
3147 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3148 "deque<...>::deque(n,v): deque too big");
3149 }
3150 deque temp(k_RAW_INIT, this->get_allocator());
3151 temp.privateInit(numElements);
3152 temp.privateAppendRaw(numElements, value);
3153 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3154}
3155
3156template <class VALUE_TYPE, class ALLOCATOR>
3157template <class INPUT_ITERATOR>
3158deque<VALUE_TYPE, ALLOCATOR>::deque(INPUT_ITERATOR first,
3159 INPUT_ITERATOR last,
3160 const ALLOCATOR& basicAllocator)
3161: Deque_Base<VALUE_TYPE>()
3162, ContainerBase(basicAllocator)
3163{
3164 deque temp(k_RAW_INIT, this->get_allocator());
3165 temp.privateInit(0);
3166 temp.insert(temp.begin(), first, last);
3167 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3168}
3169
3170template <class VALUE_TYPE, class ALLOCATOR>
3171template <class t_RANGE>
3173deque<VALUE_TYPE, ALLOCATOR>::deque(
3174 from_range_t ,
3175 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range,
3176 const ALLOCATOR& basicAllocator)
3177: Deque_Base<VALUE_TYPE>()
3178, ContainerBase(basicAllocator)
3179{
3180 deque temp(k_RAW_INIT, this->get_allocator());
3181 temp.privateInit(0);
3182 temp.append_range(BSLS_COMPILERFEATURES_FORWARD(t_RANGE, range));
3183 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3184}
3185
3186template <class VALUE_TYPE, class ALLOCATOR>
3187deque<VALUE_TYPE, ALLOCATOR>::deque(const deque& original)
3188: Deque_Base<VALUE_TYPE>()
3189, ContainerBase(AllocatorTraits::select_on_container_copy_construction(
3190 original.get_allocator()))
3191{
3192 deque temp(k_RAW_INIT, this->get_allocator());
3193 temp.privateInit(original.size());
3194 temp.privateAppend(original.begin(),
3195 original.end(),
3196 std::random_access_iterator_tag());
3197 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3198}
3199
3200template <class VALUE_TYPE, class ALLOCATOR>
3201deque<VALUE_TYPE, ALLOCATOR>::deque(
3202 const deque& original,
3203 const typename type_identity<ALLOCATOR>::type& basicAllocator)
3204: Deque_Base<VALUE_TYPE>()
3205, ContainerBase(basicAllocator)
3206{
3207 deque temp(k_RAW_INIT, this->get_allocator());
3208 temp.privateInit(original.size());
3209 temp.privateAppend(original.begin(),
3210 original.end(),
3211 std::random_access_iterator_tag());
3212 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3213}
3214
3215template <class VALUE_TYPE, class ALLOCATOR>
3216deque<VALUE_TYPE, ALLOCATOR>::deque(
3217 BloombergLP::bslmf::MovableRef<deque> original)
3218: Deque_Base<VALUE_TYPE>()
3219, ContainerBase(MoveUtil::access(original).get_allocator())
3220{
3221 deque temp(k_RAW_INIT, this->get_allocator());
3222 temp.privateInit(0);
3223 Deque_Util::move(static_cast<Base *>(this), static_cast<Base *>(&temp));
3224
3225 deque& lvalue = original;
3226 Deque_Util::swap(static_cast<Base *>(this), static_cast<Base *>(&lvalue));
3227}
3228
3229template <class VALUE_TYPE, class ALLOCATOR>
3230deque<VALUE_TYPE, ALLOCATOR>::deque(
3231 BloombergLP::bslmf::MovableRef<deque> original,
3232 const typename type_identity<ALLOCATOR>::type& basicAllocator)
3233: Deque_Base<VALUE_TYPE>()
3234, ContainerBase(basicAllocator)
3235{
3236 deque temp(k_RAW_INIT, this->get_allocator());
3237 temp.privateInit(0);
3238
3239 deque& lvalue = original;
3240
3242 get_allocator() == lvalue.get_allocator())) {
3243 Deque_Util::move(static_cast<Base *>(this),
3244 static_cast<Base *>(&temp));
3245 Deque_Util::swap(static_cast<Base *>(this),
3246 static_cast<Base *>(&lvalue));
3247 }
3248 else {
3249 const size_type size = lvalue.size();
3250 temp.reserve(size);
3251 for (size_type pos = 0; pos < size; ++pos) {
3252 temp.push_back(MoveUtil::move(lvalue[pos]));
3253 }
3254 Deque_Util::move(static_cast<Base *>(this),
3255 static_cast<Base *>(&temp));
3256 }
3257}
3258
3259#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3260template <class VALUE_TYPE, class ALLOCATOR>
3261inline
3262deque<VALUE_TYPE, ALLOCATOR>::deque(
3263 std::initializer_list<value_type> values,
3264 const ALLOCATOR& basicAllocator)
3265: deque(values.begin(), values.end(), basicAllocator)
3266{
3267}
3268#endif
3269
3270template <class VALUE_TYPE, class ALLOCATOR>
3271deque<VALUE_TYPE, ALLOCATOR>::~deque()
3272{
3273 if (0 == this->d_blocks_p) {
3274 // Nothing to do when destroying raw deques.
3275
3276 return; // RETURN
3277 }
3278
3279 if (0 != this->d_start.blockPtr()) {
3280 // Destroy all elements and deallocate all but one block.
3281 clear();
3282
3283 // Deallocate the remaining (empty) block.
3284 this->deallocateBlock(*this->d_start.blockPtr());
3285 }
3286
3287 // Deallocate the array of block pointers.
3288 this->deallocateBlockPtrs(this->d_blocks_p, this->d_blocksLength);
3289}
3290
3291// MANIPULATORS
3292template <class VALUE_TYPE, class ALLOCATOR>
3293deque<VALUE_TYPE, ALLOCATOR>&
3294deque<VALUE_TYPE, ALLOCATOR>::operator=(const deque<VALUE_TYPE,ALLOCATOR>& rhs)
3295{
3296 typedef typename
3297 AllocatorTraits::propagate_on_container_copy_assignment Propagate;
3298
3299 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this != &rhs)) {
3300 if (Propagate::value && get_allocator() != rhs.get_allocator()) {
3301 deque other(rhs, rhs.get_allocator());
3302
3303 Deque_Util::swap(static_cast<Base *>(this),
3304 static_cast<Base *>(&other));
3305 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
3306 Propagate());
3307 }
3308 else {
3309 size_type origSize = this->size();
3310 size_type rhsSize = rhs.size();
3311 size_type minSize;
3312
3313 if (origSize > rhsSize) {
3314 // Make shorter by deleting excess elements.
3315
3316 minSize = rhsSize;
3317 erase(this->begin() + minSize, this->end());
3318 }
3319 else {
3320 // Make longer by appending new elements.
3321
3322 minSize = origSize;
3323 privateAppend(rhs.begin() + minSize,
3324 rhs.end(),
3325 std::random_access_iterator_tag());
3326 }
3327
3328 // Copy the smaller of the number of elements in 'rhs' and '*this'.
3329
3330 IteratorImp from = rhs.d_start;
3331 IteratorImp to = this->d_start;
3332 for (size_type i = 0; i < minSize; ++i) {
3333 *to = *from;
3334 ++to;
3335 ++from;
3336 }
3337 }
3338 }
3339
3340 return *this;
3341}
3342
3343template <class VALUE_TYPE, class ALLOCATOR>
3344deque<VALUE_TYPE, ALLOCATOR>&
3345deque<VALUE_TYPE, ALLOCATOR>::operator=(
3346 BloombergLP::bslmf::MovableRef<deque> rhs)
3348 AllocatorTraits::is_always_equal::value)
3349{
3350 deque& lvalue = rhs;
3351
3352 typedef typename
3353 AllocatorTraits::propagate_on_container_move_assignment Propagate;
3354 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this != &lvalue)) {
3355 if (get_allocator() == lvalue.get_allocator()) {
3356 Deque_Util::swap(static_cast<Base *>(this),
3357 static_cast<Base *>(&lvalue));
3358 }
3359 else if (Propagate::value) {
3360 deque other(MoveUtil::move(lvalue));
3361 Deque_Util::swap(static_cast<Base *>(this),
3362 static_cast<Base *>(&other));
3363 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
3364 Propagate());
3365 }
3366 else {
3367 deque other(MoveUtil::move(lvalue), get_allocator());
3368 Deque_Util::swap(static_cast<Base *>(this),
3369 static_cast<Base *>(&other));
3370 }
3371 }
3372 return *this;
3373}
3374
3375#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3376template <class VALUE_TYPE, class ALLOCATOR>
3377inline
3378deque<VALUE_TYPE, ALLOCATOR>&
3379deque<VALUE_TYPE, ALLOCATOR>::operator=(
3380 std::initializer_list<value_type> values)
3381{
3382 assign(values.begin(), values.end());
3383 return *this;
3384}
3385#endif
3386
3387template <class VALUE_TYPE, class ALLOCATOR>
3388template <class INPUT_ITERATOR>
3389void deque<VALUE_TYPE, ALLOCATOR>::assign(INPUT_ITERATOR first,
3390 INPUT_ITERATOR last)
3391{
3392 privateAssign(first, last);
3393}
3394
3395template <class VALUE_TYPE, class ALLOCATOR>
3396void deque<VALUE_TYPE, ALLOCATOR>::assign(size_type numElements,
3397 const VALUE_TYPE& value)
3398{
3399 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(numElements > max_size())) {
3401
3402 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3403 "deque<...>::assign(n,v): deque too big");
3404 }
3405
3406 // If an exception is thrown, clear the deque to provide standard behavior,
3407 // which is:
3408 //..
3409 // erase(begin(), end());
3410 // insert(begin(), first, last);
3411 //..
3412
3413 ClearGuard guard(this);
3414
3415 size_type origSize = this->size();
3416 size_type minSize;
3417
3418 if (numElements < origSize) {
3419 minSize = numElements;
3420 erase(this->begin() + numElements, this->end());
3421 }
3422 else {
3423 minSize = origSize;
3424 privateAppendRaw(numElements - origSize, value);
3425 }
3426
3427 IteratorImp to = this->d_start;
3428 for (size_type i = 0; i < minSize; ++i) {
3429 *to = value;
3430 ++to;
3431 }
3432
3433 guard.release();
3434}
3435
3436#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3437template <class VALUE_TYPE, class ALLOCATOR>
3438inline
3439void deque<VALUE_TYPE, ALLOCATOR>::assign(
3440 std::initializer_list<value_type> values)
3441{
3442 assign(values.begin(), values.end());
3443}
3444#endif
3445
3446template <class VALUE_TYPE, class ALLOCATOR>
3447template <class t_RANGE>
3449void deque<VALUE_TYPE, ALLOCATOR>::assign_range(
3450 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
3451{
3452 privateAssign(ranges::begin(range), ranges::end(range));
3453}
3454
3455template <class VALUE_TYPE, class ALLOCATOR>
3456void deque<VALUE_TYPE, ALLOCATOR>::reserve(size_type numElements)
3457{
3458 // Make sure 'numElements' isn't high enough to make the calculations of
3459 // 'num(Front|Back)Blocks' overflow.
3460
3462 max_size() - (BLOCK_LENGTH - 1))) {
3464
3465 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3466 "deque<...>::reserve(n): deque too big");
3467 }
3468
3469 // 'allocateBlockPtrs', which creates the 'd_blocks_p' array, does
3470 // not, in its contract, guarantee to initialize the array to 0. Since we
3471 // read these values, we have to make sure they're initialized to avoid
3472 // purify 'read before write' errors. Note that we initialize them to 0,
3473 // making them invalid pointers, but we never dereference them, and the
3474 // pointer arithmetic we do on them will still work.
3475
3476 if (this->d_start.blockPtr() > this->d_blocks_p) {
3477 this->d_blocks_p[0] = 0;
3478 }
3479 if (this->d_finish.blockPtr() < this->d_blocks_p + this->d_blocksLength-1){
3480 this->d_blocks_p[this->d_blocksLength - 1] = 0;
3481 }
3482
3483 const IteratorImp first(this->d_blocks_p);
3484 IteratorImp last( this->d_blocks_p + this->d_blocksLength - 1);
3485 last += BLOCK_LENGTH - 1;
3486
3487 const size_type frontRoom = this->d_start - first;
3488 const size_type backRoom = last - this->d_finish;
3489
3490 size_type numFrontBlocks = numElements > frontRoom
3491 ? (numElements - frontRoom + BLOCK_LENGTH - 1) /
3492 BLOCK_LENGTH
3493 : 0;
3494 size_type numBackBlocks = numElements > backRoom
3495 ? (numElements - backRoom + BLOCK_LENGTH - 1) /
3496 BLOCK_LENGTH
3497 : 0;
3498
3499 if (0 == numFrontBlocks && 0 == numBackBlocks) {
3500 return; // RETURN
3501 }
3502
3503 // Make sure that if we throw, it's before we modify the deque.
3504
3505 size_type existingSpace = last - first;
3506 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(numFrontBlocks >
3507 (max_size() - existingSpace) / BLOCK_LENGTH
3508 || (existingSpace += numFrontBlocks * BLOCK_LENGTH,
3509 numBackBlocks >
3510 (max_size() - existingSpace) / BLOCK_LENGTH))) {
3512
3513 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3514 "deque<...>::reserve(n): deque too big");
3515 }
3516
3517 // When 'numFrontBlocks' or 'numBackBlocks' are 0, the respective calls
3518 // will be no-ops.
3519
3520 BlockCreator newBlocks(this);
3521 newBlocks.reserveBlockSlots(numFrontBlocks, true);
3522 newBlocks.reserveBlockSlots(numBackBlocks, false);
3523}
3524
3525template <class VALUE_TYPE, class ALLOCATOR>
3526void deque<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize)
3527{
3528 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(newSize > max_size())) {
3530
3531 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3532 "deque<...>::resize(n): deque too big");
3533 }
3534
3535 size_type origSize = this->size();
3536
3537 if (newSize <= origSize) {
3538 // Note that we do not use 'erase' here as 'erase' requires elements be
3539 // copy-insertable, while the standard does not require elements be
3540 // copy-insertable for this 'resize' overload.
3541
3542 IteratorImp oldEnd = this->d_finish;
3543 IteratorImp newEnd = this->d_start + newSize;
3544 DequePrimitives::destruct(newEnd, oldEnd, this->allocatorRef());
3545 // Deallocate blocks no longer used
3546 for (; oldEnd.blockPtr() != newEnd.blockPtr();
3547 oldEnd.previousBlock()) {
3548 this->deallocateBlock(*oldEnd.blockPtr());
3549 }
3550 this->d_finish = newEnd;
3551 }
3552 else {
3553 privateAppendDefaultInsertable(newSize - origSize);
3554 }
3555}
3556
3557template <class VALUE_TYPE, class ALLOCATOR>
3558void deque<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize,
3559 const VALUE_TYPE& value)
3560{
3561 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(newSize > max_size())) {
3563
3564 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3565 "deque<...>::resize(n,v): deque too big");
3566 }
3567
3568 size_type origSize = this->size();
3569
3570 if (newSize <= origSize) {
3571 erase(this->begin() + newSize, this->end());
3572 }
3573 else {
3574 privateAppendRaw(newSize - origSize, value);
3575 }
3576}
3577
3578template <class VALUE_TYPE, class ALLOCATOR>
3579void deque<VALUE_TYPE, ALLOCATOR>::shrink_to_fit()
3580{
3581 // Minimize the length of 'd_blocks_p' without moving any elements. A more
3582 // complex algorithm is not justified. At most 'BLOCK_LENGTH' bytes are
3583 // wasted.
3584
3585 const size_type newBlocksLength =
3586 this->d_finish.blockPtr() - this->d_start.blockPtr() + 1;
3587
3588 if (newBlocksLength == this->d_blocksLength) {
3589 return; // RETURN
3590 }
3591
3592 const size_type offsetStart = this->d_start.offsetInBlock();
3593 const size_type offsetFinish = this->d_finish.offsetInBlock();
3594
3595 BlockPtr *newBlocks = this->allocateBlockPtrs(newBlocksLength);
3596
3597 std::memmove(newBlocks,
3598 this->d_start.blockPtr(),
3599 newBlocksLength * sizeof(BlockPtr));
3600
3601 this->deallocateBlockPtrs(this->d_blocks_p, this->d_blocksLength);
3602
3603 this->d_blocks_p = newBlocks;
3604 this->d_blocksLength = newBlocksLength;
3605
3606 this->d_start.setBlock(newBlocks);
3607 this->d_start += offsetStart;
3608
3609 this->d_finish.setBlock(newBlocks + newBlocksLength - 1);
3610 this->d_finish += offsetFinish;
3611}
3612
3613template <class VALUE_TYPE, class ALLOCATOR>
3614template <class t_RANGE>
3616void deque<VALUE_TYPE, ALLOCATOR>::append_range(
3617 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
3618{
3619 privateAppend(ranges::begin(range), ranges::end(range));
3620}
3621
3622template <class VALUE_TYPE, class ALLOCATOR>
3623template <class t_RANGE>
3625void deque<VALUE_TYPE, ALLOCATOR>::prepend_range(
3626 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
3627{
3628 privatePrepend(ranges::begin(range), ranges::end(range));
3629}
3630
3631template <class VALUE_TYPE, class ALLOCATOR>
3632void deque<VALUE_TYPE, ALLOCATOR>::push_front(const VALUE_TYPE& value)
3633{
3634 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3636
3637 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3638 "deque<...>::push_front(v): deque too big");
3639 }
3640
3642 0 == this->d_start.offsetInBlock())) {
3644
3645 BlockCreator newBlocks(this);
3646 newBlocks.insertAtFront(1); // The deque's value is not modified.
3647
3648 AllocatorTraits::construct(
3649 this->allocatorRef(), (this->d_start - 1).valuePtr(), value);
3650
3651 --this->d_start;
3652 }
3653 else {
3654 // Since the offset is non-zero, it is safe to directly decrement the
3655 // pointer. This is much quicker than calling 'operator--'.
3656
3657 AllocatorTraits::construct(
3658 this->allocatorRef(), this->d_start.valuePtr() - 1, value);
3659 this->d_start.valuePtrDecrement();
3660 }
3661}
3662
3663template <class VALUE_TYPE, class ALLOCATOR>
3664void deque<VALUE_TYPE, ALLOCATOR>::push_front(
3665 BloombergLP::bslmf::MovableRef<value_type> value)
3666{
3667 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3669
3670 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3671 "deque<...>::push_front(v): deque too big");
3672 }
3673
3674 VALUE_TYPE& lvalue = value;
3675
3677 0 == this->d_start.offsetInBlock())) {
3679
3680 BlockCreator newBlocks(this);
3681 newBlocks.insertAtFront(1); // The deque's value is not modified.
3682
3683 AllocatorTraits::construct(this->allocatorRef(),
3684 (this->d_start - 1).valuePtr(),
3685 MoveUtil::move(lvalue));
3686 --this->d_start;
3687 }
3688 else {
3689 // Since the offset is non-zero, it is safe to directly decrement the
3690 // pointer. This is much quicker than calling 'operator--'.
3691
3692 AllocatorTraits::construct(this->allocatorRef(),
3693 this->d_start.valuePtr() - 1,
3694 MoveUtil::move(lvalue));
3695 this->d_start.valuePtrDecrement();
3696 }
3697}
3698
3699template <class VALUE_TYPE, class ALLOCATOR>
3700void deque<VALUE_TYPE, ALLOCATOR>::push_back(const VALUE_TYPE& value)
3701{
3702 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3704
3705 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3706 "deque<...>::push_back(v): deque too big");
3707 }
3708
3710 1 < this->d_finish.remainingInBlock())) {
3711 AllocatorTraits::construct(
3712 this->allocatorRef(), this->d_finish.valuePtr(), value);
3713 this->d_finish.valuePtrIncrement();
3714 }
3715 else {
3717
3718 BlockCreator newBlocks(this);
3719 newBlocks.insertAtBack(1); // The deque's value is not modified.
3720
3721 AllocatorTraits::construct(
3722 this->allocatorRef(), this->d_finish.valuePtr(), value);
3723 this->d_finish.nextBlock();
3724 }
3725}
3726
3727template <class VALUE_TYPE, class ALLOCATOR>
3728void deque<VALUE_TYPE, ALLOCATOR>::push_back(
3729 BloombergLP::bslmf::MovableRef<value_type> value)
3730{
3731 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3733
3734 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3735 "deque<...>::push_back(v): deque too big");
3736 }
3737
3738 VALUE_TYPE& lvalue = value;
3739
3741 1 < this->d_finish.remainingInBlock())) {
3742 AllocatorTraits::construct(this->allocatorRef(),
3743 this->d_finish.valuePtr(),
3744 MoveUtil::move(lvalue));
3745 this->d_finish.valuePtrIncrement();
3746 }
3747 else {
3749
3750 BlockCreator newBlocks(this);
3751 newBlocks.insertAtBack(1); // The deque's value is not modified.
3752
3753 AllocatorTraits::construct(this->allocatorRef(),
3754 this->d_finish.valuePtr(),
3755 MoveUtil::move(lvalue));
3756 this->d_finish.nextBlock();
3757 }
3758}
3759
3760#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3761// {{{ BEGIN GENERATED CODE
3762// Command line: sim_cpp11_features.pl bslstl_deque.h
3763#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
3764#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
3765#endif
3766#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_C
3767#define BSLSTL_DEQUE_VARIADIC_LIMIT_C BSLSTL_DEQUE_VARIADIC_LIMIT
3768#endif
3769#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
3770template <class VALUE_TYPE, class ALLOCATOR>
3771typename deque<VALUE_TYPE, ALLOCATOR>::reference
3772deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3773 )
3774{
3775 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3777
3778 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3779 "deque<...>::emplace_front(args): deque too big");
3780 }
3781
3783 0 == this->d_start.offsetInBlock())) {
3785
3786 BlockCreator newBlocks(this);
3787 newBlocks.insertAtFront(1);
3788
3789 AllocatorTraits::construct(
3790 this->allocatorRef(),
3791 (this->d_start - 1).valuePtr());
3792 --this->d_start;
3793 }
3794 else {
3795
3796 AllocatorTraits::construct(
3797 this->allocatorRef(),
3798 this->d_start.valuePtr() - 1);
3799 this->d_start.valuePtrDecrement();
3800 }
3801 return *(this->d_start);
3802}
3803#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
3804
3805#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
3806template <class VALUE_TYPE, class ALLOCATOR>
3807template <class Args_01>
3808typename deque<VALUE_TYPE, ALLOCATOR>::reference
3809deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3810 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
3811{
3812 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3814
3815 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3816 "deque<...>::emplace_front(args): deque too big");
3817 }
3818
3820 0 == this->d_start.offsetInBlock())) {
3822
3823 BlockCreator newBlocks(this);
3824 newBlocks.insertAtFront(1);
3825
3826 AllocatorTraits::construct(
3827 this->allocatorRef(),
3828 (this->d_start - 1).valuePtr(),
3829 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
3830 --this->d_start;
3831 }
3832 else {
3833
3834 AllocatorTraits::construct(
3835 this->allocatorRef(),
3836 this->d_start.valuePtr() - 1,
3837 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
3838 this->d_start.valuePtrDecrement();
3839 }
3840 return *(this->d_start);
3841}
3842#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
3843
3844#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
3845template <class VALUE_TYPE, class ALLOCATOR>
3846template <class Args_01,
3847 class Args_02>
3848typename deque<VALUE_TYPE, ALLOCATOR>::reference
3849deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3850 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3851 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
3852{
3853 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3855
3856 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3857 "deque<...>::emplace_front(args): deque too big");
3858 }
3859
3861 0 == this->d_start.offsetInBlock())) {
3863
3864 BlockCreator newBlocks(this);
3865 newBlocks.insertAtFront(1);
3866
3867 AllocatorTraits::construct(
3868 this->allocatorRef(),
3869 (this->d_start - 1).valuePtr(),
3870 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3871 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
3872 --this->d_start;
3873 }
3874 else {
3875
3876 AllocatorTraits::construct(
3877 this->allocatorRef(),
3878 this->d_start.valuePtr() - 1,
3879 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3880 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
3881 this->d_start.valuePtrDecrement();
3882 }
3883 return *(this->d_start);
3884}
3885#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
3886
3887#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
3888template <class VALUE_TYPE, class ALLOCATOR>
3889template <class Args_01,
3890 class Args_02,
3891 class Args_03>
3892typename deque<VALUE_TYPE, ALLOCATOR>::reference
3893deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3894 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3895 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3896 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
3897{
3898 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3900
3901 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3902 "deque<...>::emplace_front(args): deque too big");
3903 }
3904
3906 0 == this->d_start.offsetInBlock())) {
3908
3909 BlockCreator newBlocks(this);
3910 newBlocks.insertAtFront(1);
3911
3912 AllocatorTraits::construct(
3913 this->allocatorRef(),
3914 (this->d_start - 1).valuePtr(),
3915 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3916 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3917 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
3918 --this->d_start;
3919 }
3920 else {
3921
3922 AllocatorTraits::construct(
3923 this->allocatorRef(),
3924 this->d_start.valuePtr() - 1,
3925 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3926 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3927 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
3928 this->d_start.valuePtrDecrement();
3929 }
3930 return *(this->d_start);
3931}
3932#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
3933
3934#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
3935template <class VALUE_TYPE, class ALLOCATOR>
3936template <class Args_01,
3937 class Args_02,
3938 class Args_03,
3939 class Args_04>
3940typename deque<VALUE_TYPE, ALLOCATOR>::reference
3941deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3942 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3943 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3944 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3945 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
3946{
3947 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
3949
3950 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3951 "deque<...>::emplace_front(args): deque too big");
3952 }
3953
3955 0 == this->d_start.offsetInBlock())) {
3957
3958 BlockCreator newBlocks(this);
3959 newBlocks.insertAtFront(1);
3960
3961 AllocatorTraits::construct(
3962 this->allocatorRef(),
3963 (this->d_start - 1).valuePtr(),
3964 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3965 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3966 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3967 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
3968 --this->d_start;
3969 }
3970 else {
3971
3972 AllocatorTraits::construct(
3973 this->allocatorRef(),
3974 this->d_start.valuePtr() - 1,
3975 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3976 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3977 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3978 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
3979 this->d_start.valuePtrDecrement();
3980 }
3981 return *(this->d_start);
3982}
3983#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
3984
3985#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
3986template <class VALUE_TYPE, class ALLOCATOR>
3987template <class Args_01,
3988 class Args_02,
3989 class Args_03,
3990 class Args_04,
3991 class Args_05>
3992typename deque<VALUE_TYPE, ALLOCATOR>::reference
3993deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
3994 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3995 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3996 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3997 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
3998 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
3999{
4000 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4002
4003 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4004 "deque<...>::emplace_front(args): deque too big");
4005 }
4006
4008 0 == this->d_start.offsetInBlock())) {
4010
4011 BlockCreator newBlocks(this);
4012 newBlocks.insertAtFront(1);
4013
4014 AllocatorTraits::construct(
4015 this->allocatorRef(),
4016 (this->d_start - 1).valuePtr(),
4017 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4018 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4019 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4020 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4021 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4022 --this->d_start;
4023 }
4024 else {
4025
4026 AllocatorTraits::construct(
4027 this->allocatorRef(),
4028 this->d_start.valuePtr() - 1,
4029 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4030 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4031 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4032 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4033 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4034 this->d_start.valuePtrDecrement();
4035 }
4036 return *(this->d_start);
4037}
4038#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
4039
4040#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
4041template <class VALUE_TYPE, class ALLOCATOR>
4042template <class Args_01,
4043 class Args_02,
4044 class Args_03,
4045 class Args_04,
4046 class Args_05,
4047 class Args_06>
4048typename deque<VALUE_TYPE, ALLOCATOR>::reference
4049deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4050 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4051 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4052 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4053 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4054 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4055 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
4056{
4057 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4059
4060 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4061 "deque<...>::emplace_front(args): deque too big");
4062 }
4063
4065 0 == this->d_start.offsetInBlock())) {
4067
4068 BlockCreator newBlocks(this);
4069 newBlocks.insertAtFront(1);
4070
4071 AllocatorTraits::construct(
4072 this->allocatorRef(),
4073 (this->d_start - 1).valuePtr(),
4074 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4075 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4076 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4077 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4078 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4079 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4080 --this->d_start;
4081 }
4082 else {
4083
4084 AllocatorTraits::construct(
4085 this->allocatorRef(),
4086 this->d_start.valuePtr() - 1,
4087 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4088 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4089 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4090 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4091 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4092 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4093 this->d_start.valuePtrDecrement();
4094 }
4095 return *(this->d_start);
4096}
4097#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
4098
4099#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
4100template <class VALUE_TYPE, class ALLOCATOR>
4101template <class Args_01,
4102 class Args_02,
4103 class Args_03,
4104 class Args_04,
4105 class Args_05,
4106 class Args_06,
4107 class Args_07>
4108typename deque<VALUE_TYPE, ALLOCATOR>::reference
4109deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4110 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4111 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4112 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4113 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4114 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4115 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4116 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
4117{
4118 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4120
4121 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4122 "deque<...>::emplace_front(args): deque too big");
4123 }
4124
4126 0 == this->d_start.offsetInBlock())) {
4128
4129 BlockCreator newBlocks(this);
4130 newBlocks.insertAtFront(1);
4131
4132 AllocatorTraits::construct(
4133 this->allocatorRef(),
4134 (this->d_start - 1).valuePtr(),
4135 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4136 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4137 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4138 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4139 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4140 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4141 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
4142 --this->d_start;
4143 }
4144 else {
4145
4146 AllocatorTraits::construct(
4147 this->allocatorRef(),
4148 this->d_start.valuePtr() - 1,
4149 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4150 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4151 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4152 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4153 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4154 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4155 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
4156 this->d_start.valuePtrDecrement();
4157 }
4158 return *(this->d_start);
4159}
4160#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
4161
4162#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
4163template <class VALUE_TYPE, class ALLOCATOR>
4164template <class Args_01,
4165 class Args_02,
4166 class Args_03,
4167 class Args_04,
4168 class Args_05,
4169 class Args_06,
4170 class Args_07,
4171 class Args_08>
4172typename deque<VALUE_TYPE, ALLOCATOR>::reference
4173deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4174 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4175 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4176 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4177 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4178 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4179 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4180 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4181 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
4182{
4183 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4185
4186 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4187 "deque<...>::emplace_front(args): deque too big");
4188 }
4189
4191 0 == this->d_start.offsetInBlock())) {
4193
4194 BlockCreator newBlocks(this);
4195 newBlocks.insertAtFront(1);
4196
4197 AllocatorTraits::construct(
4198 this->allocatorRef(),
4199 (this->d_start - 1).valuePtr(),
4200 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4201 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4202 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4203 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4204 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4205 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4206 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4207 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
4208 --this->d_start;
4209 }
4210 else {
4211
4212 AllocatorTraits::construct(
4213 this->allocatorRef(),
4214 this->d_start.valuePtr() - 1,
4215 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4216 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4217 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4218 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4219 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4220 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4221 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4222 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
4223 this->d_start.valuePtrDecrement();
4224 }
4225 return *(this->d_start);
4226}
4227#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
4228
4229#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
4230template <class VALUE_TYPE, class ALLOCATOR>
4231template <class Args_01,
4232 class Args_02,
4233 class Args_03,
4234 class Args_04,
4235 class Args_05,
4236 class Args_06,
4237 class Args_07,
4238 class Args_08,
4239 class Args_09>
4240typename deque<VALUE_TYPE, ALLOCATOR>::reference
4241deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4242 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4243 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4244 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4245 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4246 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4247 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4248 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4249 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4250 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
4251{
4252 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4254
4255 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4256 "deque<...>::emplace_front(args): deque too big");
4257 }
4258
4260 0 == this->d_start.offsetInBlock())) {
4262
4263 BlockCreator newBlocks(this);
4264 newBlocks.insertAtFront(1);
4265
4266 AllocatorTraits::construct(
4267 this->allocatorRef(),
4268 (this->d_start - 1).valuePtr(),
4269 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4270 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4271 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4272 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4273 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4274 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4275 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4276 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4277 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
4278 --this->d_start;
4279 }
4280 else {
4281
4282 AllocatorTraits::construct(
4283 this->allocatorRef(),
4284 this->d_start.valuePtr() - 1,
4285 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4286 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4287 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4288 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4289 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4290 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4291 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4292 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4293 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
4294 this->d_start.valuePtrDecrement();
4295 }
4296 return *(this->d_start);
4297}
4298#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
4299
4300#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4301template <class VALUE_TYPE, class ALLOCATOR>
4302template <class Args_01,
4303 class Args_02,
4304 class Args_03,
4305 class Args_04,
4306 class Args_05,
4307 class Args_06,
4308 class Args_07,
4309 class Args_08,
4310 class Args_09,
4311 class Args_10>
4312typename deque<VALUE_TYPE, ALLOCATOR>::reference
4313deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4314 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4315 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4316 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4317 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4318 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4319 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4320 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4321 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4322 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
4323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
4324{
4325 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4327
4328 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4329 "deque<...>::emplace_front(args): deque too big");
4330 }
4331
4333 0 == this->d_start.offsetInBlock())) {
4335
4336 BlockCreator newBlocks(this);
4337 newBlocks.insertAtFront(1);
4338
4339 AllocatorTraits::construct(
4340 this->allocatorRef(),
4341 (this->d_start - 1).valuePtr(),
4342 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4343 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4344 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4345 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4346 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4347 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4348 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4349 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4350 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
4351 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
4352 --this->d_start;
4353 }
4354 else {
4355
4356 AllocatorTraits::construct(
4357 this->allocatorRef(),
4358 this->d_start.valuePtr() - 1,
4359 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4360 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4361 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4362 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4363 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4364 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4365 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4366 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4367 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
4368 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
4369 this->d_start.valuePtrDecrement();
4370 }
4371 return *(this->d_start);
4372}
4373#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4374
4375
4376#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
4377template <class VALUE_TYPE, class ALLOCATOR>
4378typename deque<VALUE_TYPE, ALLOCATOR>::reference
4379deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4380 )
4381{
4382 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4384
4385 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4386 "deque<...>::emplace_back(args): deque too big");
4387 }
4388
4390 1 < this->d_finish.remainingInBlock())) {
4391 AllocatorTraits::construct(
4392 this->allocatorRef(),
4393 this->d_finish.valuePtr());
4394 this->d_finish.valuePtrIncrement();
4395 }
4396 else {
4398
4399 BlockCreator newBlocks(this);
4400 newBlocks.insertAtBack(1);
4401
4402 AllocatorTraits::construct(
4403 this->allocatorRef(),
4404 this->d_finish.valuePtr());
4405 this->d_finish.nextBlock();
4406 }
4407 return *(this->d_finish - 1);
4408}
4409#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 0
4410
4411#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
4412template <class VALUE_TYPE, class ALLOCATOR>
4413template <class Args_01>
4414typename deque<VALUE_TYPE, ALLOCATOR>::reference
4415deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4416 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
4417{
4418 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4420
4421 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4422 "deque<...>::emplace_back(args): deque too big");
4423 }
4424
4426 1 < this->d_finish.remainingInBlock())) {
4427 AllocatorTraits::construct(
4428 this->allocatorRef(),
4429 this->d_finish.valuePtr(),
4430 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
4431 this->d_finish.valuePtrIncrement();
4432 }
4433 else {
4435
4436 BlockCreator newBlocks(this);
4437 newBlocks.insertAtBack(1);
4438
4439 AllocatorTraits::construct(
4440 this->allocatorRef(),
4441 this->d_finish.valuePtr(),
4442 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
4443 this->d_finish.nextBlock();
4444 }
4445 return *(this->d_finish - 1);
4446}
4447#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 1
4448
4449#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
4450template <class VALUE_TYPE, class ALLOCATOR>
4451template <class Args_01,
4452 class Args_02>
4453typename deque<VALUE_TYPE, ALLOCATOR>::reference
4454deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4455 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4456 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
4457{
4458 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4460
4461 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4462 "deque<...>::emplace_back(args): deque too big");
4463 }
4464
4466 1 < this->d_finish.remainingInBlock())) {
4467 AllocatorTraits::construct(
4468 this->allocatorRef(),
4469 this->d_finish.valuePtr(),
4470 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4471 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
4472 this->d_finish.valuePtrIncrement();
4473 }
4474 else {
4476
4477 BlockCreator newBlocks(this);
4478 newBlocks.insertAtBack(1);
4479
4480 AllocatorTraits::construct(
4481 this->allocatorRef(),
4482 this->d_finish.valuePtr(),
4483 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4484 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
4485 this->d_finish.nextBlock();
4486 }
4487 return *(this->d_finish - 1);
4488}
4489#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 2
4490
4491#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
4492template <class VALUE_TYPE, class ALLOCATOR>
4493template <class Args_01,
4494 class Args_02,
4495 class Args_03>
4496typename deque<VALUE_TYPE, ALLOCATOR>::reference
4497deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4498 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4499 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4500 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
4501{
4502 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4504
4505 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4506 "deque<...>::emplace_back(args): deque too big");
4507 }
4508
4510 1 < this->d_finish.remainingInBlock())) {
4511 AllocatorTraits::construct(
4512 this->allocatorRef(),
4513 this->d_finish.valuePtr(),
4514 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4515 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4516 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
4517 this->d_finish.valuePtrIncrement();
4518 }
4519 else {
4521
4522 BlockCreator newBlocks(this);
4523 newBlocks.insertAtBack(1);
4524
4525 AllocatorTraits::construct(
4526 this->allocatorRef(),
4527 this->d_finish.valuePtr(),
4528 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4529 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4530 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
4531 this->d_finish.nextBlock();
4532 }
4533 return *(this->d_finish - 1);
4534}
4535#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 3
4536
4537#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
4538template <class VALUE_TYPE, class ALLOCATOR>
4539template <class Args_01,
4540 class Args_02,
4541 class Args_03,
4542 class Args_04>
4543typename deque<VALUE_TYPE, ALLOCATOR>::reference
4544deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4545 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4546 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4547 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4548 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
4549{
4550 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4552
4553 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4554 "deque<...>::emplace_back(args): deque too big");
4555 }
4556
4558 1 < this->d_finish.remainingInBlock())) {
4559 AllocatorTraits::construct(
4560 this->allocatorRef(),
4561 this->d_finish.valuePtr(),
4562 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4563 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4564 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4565 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
4566 this->d_finish.valuePtrIncrement();
4567 }
4568 else {
4570
4571 BlockCreator newBlocks(this);
4572 newBlocks.insertAtBack(1);
4573
4574 AllocatorTraits::construct(
4575 this->allocatorRef(),
4576 this->d_finish.valuePtr(),
4577 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4578 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4579 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4580 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
4581 this->d_finish.nextBlock();
4582 }
4583 return *(this->d_finish - 1);
4584}
4585#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 4
4586
4587#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
4588template <class VALUE_TYPE, class ALLOCATOR>
4589template <class Args_01,
4590 class Args_02,
4591 class Args_03,
4592 class Args_04,
4593 class Args_05>
4594typename deque<VALUE_TYPE, ALLOCATOR>::reference
4595deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4596 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4597 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4598 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4599 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4600 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
4601{
4602 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4604
4605 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4606 "deque<...>::emplace_back(args): deque too big");
4607 }
4608
4610 1 < this->d_finish.remainingInBlock())) {
4611 AllocatorTraits::construct(
4612 this->allocatorRef(),
4613 this->d_finish.valuePtr(),
4614 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4615 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4616 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4617 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4618 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4619 this->d_finish.valuePtrIncrement();
4620 }
4621 else {
4623
4624 BlockCreator newBlocks(this);
4625 newBlocks.insertAtBack(1);
4626
4627 AllocatorTraits::construct(
4628 this->allocatorRef(),
4629 this->d_finish.valuePtr(),
4630 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4631 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4632 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4633 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4634 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4635 this->d_finish.nextBlock();
4636 }
4637 return *(this->d_finish - 1);
4638}
4639#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 5
4640
4641#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
4642template <class VALUE_TYPE, class ALLOCATOR>
4643template <class Args_01,
4644 class Args_02,
4645 class Args_03,
4646 class Args_04,
4647 class Args_05,
4648 class Args_06>
4649typename deque<VALUE_TYPE, ALLOCATOR>::reference
4650deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4651 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4652 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4653 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4654 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4655 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4656 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
4657{
4658 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4660
4661 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4662 "deque<...>::emplace_back(args): deque too big");
4663 }
4664
4666 1 < this->d_finish.remainingInBlock())) {
4667 AllocatorTraits::construct(
4668 this->allocatorRef(),
4669 this->d_finish.valuePtr(),
4670 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4671 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4672 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4673 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4674 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4675 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4676 this->d_finish.valuePtrIncrement();
4677 }
4678 else {
4680
4681 BlockCreator newBlocks(this);
4682 newBlocks.insertAtBack(1);
4683
4684 AllocatorTraits::construct(
4685 this->allocatorRef(),
4686 this->d_finish.valuePtr(),
4687 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4688 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4689 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4690 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4691 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4692 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4693 this->d_finish.nextBlock();
4694 }
4695 return *(this->d_finish - 1);
4696}
4697#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 6
4698
4699#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
4700template <class VALUE_TYPE, class ALLOCATOR>
4701template <class Args_01,
4702 class Args_02,
4703 class Args_03,
4704 class Args_04,
4705 class Args_05,
4706 class Args_06,
4707 class Args_07>
4708typename deque<VALUE_TYPE, ALLOCATOR>::reference
4709deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4710 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4711 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4712 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4713 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4714 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4715 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4716 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
4717{
4718 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4720
4721 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4722 "deque<...>::emplace_back(args): deque too big");
4723 }
4724
4726 1 < this->d_finish.remainingInBlock())) {
4727 AllocatorTraits::construct(
4728 this->allocatorRef(),
4729 this->d_finish.valuePtr(),
4730 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4731 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4732 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4733 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4734 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4735 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4736 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
4737 this->d_finish.valuePtrIncrement();
4738 }
4739 else {
4741
4742 BlockCreator newBlocks(this);
4743 newBlocks.insertAtBack(1);
4744
4745 AllocatorTraits::construct(
4746 this->allocatorRef(),
4747 this->d_finish.valuePtr(),
4748 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4749 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4750 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4751 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4752 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4753 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4754 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
4755 this->d_finish.nextBlock();
4756 }
4757 return *(this->d_finish - 1);
4758}
4759#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 7
4760
4761#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
4762template <class VALUE_TYPE, class ALLOCATOR>
4763template <class Args_01,
4764 class Args_02,
4765 class Args_03,
4766 class Args_04,
4767 class Args_05,
4768 class Args_06,
4769 class Args_07,
4770 class Args_08>
4771typename deque<VALUE_TYPE, ALLOCATOR>::reference
4772deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4773 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4774 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4775 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4776 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4777 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4778 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4779 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4780 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
4781{
4782 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4784
4785 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4786 "deque<...>::emplace_back(args): deque too big");
4787 }
4788
4790 1 < this->d_finish.remainingInBlock())) {
4791 AllocatorTraits::construct(
4792 this->allocatorRef(),
4793 this->d_finish.valuePtr(),
4794 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4795 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4796 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4797 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4798 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4799 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4800 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4801 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
4802 this->d_finish.valuePtrIncrement();
4803 }
4804 else {
4806
4807 BlockCreator newBlocks(this);
4808 newBlocks.insertAtBack(1);
4809
4810 AllocatorTraits::construct(
4811 this->allocatorRef(),
4812 this->d_finish.valuePtr(),
4813 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4814 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4815 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4816 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4817 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4818 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4819 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4820 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
4821 this->d_finish.nextBlock();
4822 }
4823 return *(this->d_finish - 1);
4824}
4825#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 8
4826
4827#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
4828template <class VALUE_TYPE, class ALLOCATOR>
4829template <class Args_01,
4830 class Args_02,
4831 class Args_03,
4832 class Args_04,
4833 class Args_05,
4834 class Args_06,
4835 class Args_07,
4836 class Args_08,
4837 class Args_09>
4838typename deque<VALUE_TYPE, ALLOCATOR>::reference
4839deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4840 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4841 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4842 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4843 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4844 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4845 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4846 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4847 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4848 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
4849{
4850 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4852
4853 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4854 "deque<...>::emplace_back(args): deque too big");
4855 }
4856
4858 1 < this->d_finish.remainingInBlock())) {
4859 AllocatorTraits::construct(
4860 this->allocatorRef(),
4861 this->d_finish.valuePtr(),
4862 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4863 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4864 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4865 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4866 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4867 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4868 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4869 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4870 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
4871 this->d_finish.valuePtrIncrement();
4872 }
4873 else {
4875
4876 BlockCreator newBlocks(this);
4877 newBlocks.insertAtBack(1);
4878
4879 AllocatorTraits::construct(
4880 this->allocatorRef(),
4881 this->d_finish.valuePtr(),
4882 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4883 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4884 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4885 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4886 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4887 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4888 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4889 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4890 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
4891 this->d_finish.nextBlock();
4892 }
4893 return *(this->d_finish - 1);
4894}
4895#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 9
4896
4897#if BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4898template <class VALUE_TYPE, class ALLOCATOR>
4899template <class Args_01,
4900 class Args_02,
4901 class Args_03,
4902 class Args_04,
4903 class Args_05,
4904 class Args_06,
4905 class Args_07,
4906 class Args_08,
4907 class Args_09,
4908 class Args_10>
4909typename deque<VALUE_TYPE, ALLOCATOR>::reference
4910deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
4911 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4912 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4913 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4914 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4915 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4916 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4917 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4918 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4919 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
4920 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
4921{
4922 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4924
4925 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4926 "deque<...>::emplace_back(args): deque too big");
4927 }
4928
4930 1 < this->d_finish.remainingInBlock())) {
4931 AllocatorTraits::construct(
4932 this->allocatorRef(),
4933 this->d_finish.valuePtr(),
4934 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4935 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4936 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4937 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4938 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4939 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4940 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4941 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4942 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
4943 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
4944 this->d_finish.valuePtrIncrement();
4945 }
4946 else {
4948
4949 BlockCreator newBlocks(this);
4950 newBlocks.insertAtBack(1);
4951
4952 AllocatorTraits::construct(
4953 this->allocatorRef(),
4954 this->d_finish.valuePtr(),
4955 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4956 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4957 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4958 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4959 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4960 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4961 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4962 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4963 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
4964 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
4965 this->d_finish.nextBlock();
4966 }
4967 return *(this->d_finish - 1);
4968}
4969#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_C >= 10
4970
4971#else
4972// The generated code below is a workaround for the absence of perfect
4973// forwarding in some compilers.
4974template <class VALUE_TYPE, class ALLOCATOR>
4975template <class... Args>
4976typename deque<VALUE_TYPE, ALLOCATOR>::reference
4977deque<VALUE_TYPE, ALLOCATOR>::emplace_front(
4978 BSLS_COMPILERFEATURES_FORWARD_REF(Args)...arguments)
4979{
4980 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
4982
4983 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4984 "deque<...>::emplace_front(args): deque too big");
4985 }
4986
4988 0 == this->d_start.offsetInBlock())) {
4990
4991 BlockCreator newBlocks(this);
4992 newBlocks.insertAtFront(1);
4993
4994 AllocatorTraits::construct(
4995 this->allocatorRef(),
4996 (this->d_start - 1).valuePtr(),
4997 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
4998 --this->d_start;
4999 }
5000 else {
5001
5002 AllocatorTraits::construct(
5003 this->allocatorRef(),
5004 this->d_start.valuePtr() - 1,
5005 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
5006 this->d_start.valuePtrDecrement();
5007 }
5008 return *(this->d_start);
5009}
5010
5011template <class VALUE_TYPE, class ALLOCATOR>
5012template <class... Args>
5013typename deque<VALUE_TYPE, ALLOCATOR>::reference
5014deque<VALUE_TYPE, ALLOCATOR>::emplace_back(
5015 BSLS_COMPILERFEATURES_FORWARD_REF(Args)...arguments)
5016{
5017 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(this->size() >= max_size())) {
5019
5020 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5021 "deque<...>::emplace_back(args): deque too big");
5022 }
5023
5025 1 < this->d_finish.remainingInBlock())) {
5026 AllocatorTraits::construct(
5027 this->allocatorRef(),
5028 this->d_finish.valuePtr(),
5029 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
5030 this->d_finish.valuePtrIncrement();
5031 }
5032 else {
5034
5035 BlockCreator newBlocks(this);
5036 newBlocks.insertAtBack(1);
5037
5038 AllocatorTraits::construct(
5039 this->allocatorRef(),
5040 this->d_finish.valuePtr(),
5041 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
5042 this->d_finish.nextBlock();
5043 }
5044 return *(this->d_finish - 1);
5045}
5046// }}} END GENERATED CODE
5047#endif
5048
5049#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
5050// {{{ BEGIN GENERATED CODE
5051// Command line: sim_cpp11_features.pl bslstl_deque.h
5052#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT
5053#define BSLSTL_DEQUE_VARIADIC_LIMIT 10
5054#endif
5055#ifndef BSLSTL_DEQUE_VARIADIC_LIMIT_D
5056#define BSLSTL_DEQUE_VARIADIC_LIMIT_D BSLSTL_DEQUE_VARIADIC_LIMIT
5057#endif
5058#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 0
5059template <class VALUE_TYPE, class ALLOCATOR>
5060typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5061deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position)
5062{
5063 BSLS_ASSERT(position >= this->cbegin());
5064 BSLS_ASSERT(position <= this->cend());
5065
5066 if (position == this->cbegin()) {
5067 emplace_front();
5068 return this->begin();
5069 }
5070
5071 if (position == this->cend()) {
5072 emplace_back();
5073 return iterator(this->d_finish - 1);
5074 }
5075
5076
5077 const size_type currentSize = this->size();
5078 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5080
5081 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5082 "deque<...>::emplace(args): deque too big");
5083 }
5084
5085 iterator pos(position.imp());
5086 const size_type posIdx = position - this->cbegin();
5087 if (posIdx <= currentSize / 2) {
5088 BlockCreator newBlocks(this);
5089 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5090 newBlocks.insertAtFront(1);
5091 }
5092
5093 BlockProctor proctor(this, true);
5094 DequePrimitives::emplaceAndMoveToFront(
5095 &this->d_start,
5096 this->d_start,
5097 this->d_start + posIdx,
5098 this->allocatorRef());
5099 proctor.release();
5100 }
5101 else {
5102 BlockCreator newBlocks(this);
5103 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5104 newBlocks.insertAtBack(1);
5105 }
5106
5107 BlockProctor proctor(this, false);
5108 DequePrimitives::emplaceAndMoveToBack(
5109 &this->d_finish,
5110 this->d_finish,
5111 this->d_start + posIdx,
5112 this->allocatorRef());
5113 proctor.release();
5114 }
5115 return this->begin() + posIdx;
5116}
5117#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 0
5118
5119#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 1
5120template <class VALUE_TYPE, class ALLOCATOR>
5121template <class Args_01>
5122typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5123deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5124 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
5125{
5126 BSLS_ASSERT(position >= this->cbegin());
5127 BSLS_ASSERT(position <= this->cend());
5128
5129 if (position == this->cbegin()) {
5130 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
5131 return this->begin();
5132 }
5133
5134 if (position == this->cend()) {
5135 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
5136 return iterator(this->d_finish - 1);
5137 }
5138
5139
5140 const size_type currentSize = this->size();
5141 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5143
5144 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5145 "deque<...>::emplace(args): deque too big");
5146 }
5147
5148 iterator pos(position.imp());
5149 const size_type posIdx = position - this->cbegin();
5150 if (posIdx <= currentSize / 2) {
5151 BlockCreator newBlocks(this);
5152 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5153 newBlocks.insertAtFront(1);
5154 }
5155
5156 BlockProctor proctor(this, true);
5157 DequePrimitives::emplaceAndMoveToFront(
5158 &this->d_start,
5159 this->d_start,
5160 this->d_start + posIdx,
5161 this->allocatorRef(),
5162 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
5163 proctor.release();
5164 }
5165 else {
5166 BlockCreator newBlocks(this);
5167 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5168 newBlocks.insertAtBack(1);
5169 }
5170
5171 BlockProctor proctor(this, false);
5172 DequePrimitives::emplaceAndMoveToBack(
5173 &this->d_finish,
5174 this->d_finish,
5175 this->d_start + posIdx,
5176 this->allocatorRef(),
5177 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
5178 proctor.release();
5179 }
5180 return this->begin() + posIdx;
5181}
5182#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 1
5183
5184#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 2
5185template <class VALUE_TYPE, class ALLOCATOR>
5186template <class Args_01,
5187 class Args_02>
5188typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5189deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5190 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5191 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
5192{
5193 BSLS_ASSERT(position >= this->cbegin());
5194 BSLS_ASSERT(position <= this->cend());
5195
5196 if (position == this->cbegin()) {
5197 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5198 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
5199 return this->begin();
5200 }
5201
5202 if (position == this->cend()) {
5203 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5204 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
5205 return iterator(this->d_finish - 1);
5206 }
5207
5208
5209 const size_type currentSize = this->size();
5210 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5212
5213 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5214 "deque<...>::emplace(args): deque too big");
5215 }
5216
5217 iterator pos(position.imp());
5218 const size_type posIdx = position - this->cbegin();
5219 if (posIdx <= currentSize / 2) {
5220 BlockCreator newBlocks(this);
5221 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5222 newBlocks.insertAtFront(1);
5223 }
5224
5225 BlockProctor proctor(this, true);
5226 DequePrimitives::emplaceAndMoveToFront(
5227 &this->d_start,
5228 this->d_start,
5229 this->d_start + posIdx,
5230 this->allocatorRef(),
5231 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5232 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
5233 proctor.release();
5234 }
5235 else {
5236 BlockCreator newBlocks(this);
5237 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5238 newBlocks.insertAtBack(1);
5239 }
5240
5241 BlockProctor proctor(this, false);
5242 DequePrimitives::emplaceAndMoveToBack(
5243 &this->d_finish,
5244 this->d_finish,
5245 this->d_start + posIdx,
5246 this->allocatorRef(),
5247 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5248 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
5249 proctor.release();
5250 }
5251 return this->begin() + posIdx;
5252}
5253#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 2
5254
5255#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 3
5256template <class VALUE_TYPE, class ALLOCATOR>
5257template <class Args_01,
5258 class Args_02,
5259 class Args_03>
5260typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5261deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5262 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5263 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5264 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
5265{
5266 BSLS_ASSERT(position >= this->cbegin());
5267 BSLS_ASSERT(position <= this->cend());
5268
5269 if (position == this->cbegin()) {
5270 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5271 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5272 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
5273 return this->begin();
5274 }
5275
5276 if (position == this->cend()) {
5277 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5278 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5279 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
5280 return iterator(this->d_finish - 1);
5281 }
5282
5283
5284 const size_type currentSize = this->size();
5285 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5287
5288 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5289 "deque<...>::emplace(args): deque too big");
5290 }
5291
5292 iterator pos(position.imp());
5293 const size_type posIdx = position - this->cbegin();
5294 if (posIdx <= currentSize / 2) {
5295 BlockCreator newBlocks(this);
5296 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5297 newBlocks.insertAtFront(1);
5298 }
5299
5300 BlockProctor proctor(this, true);
5301 DequePrimitives::emplaceAndMoveToFront(
5302 &this->d_start,
5303 this->d_start,
5304 this->d_start + posIdx,
5305 this->allocatorRef(),
5306 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5307 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5308 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
5309 proctor.release();
5310 }
5311 else {
5312 BlockCreator newBlocks(this);
5313 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5314 newBlocks.insertAtBack(1);
5315 }
5316
5317 BlockProctor proctor(this, false);
5318 DequePrimitives::emplaceAndMoveToBack(
5319 &this->d_finish,
5320 this->d_finish,
5321 this->d_start + posIdx,
5322 this->allocatorRef(),
5323 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5324 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5325 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
5326 proctor.release();
5327 }
5328 return this->begin() + posIdx;
5329}
5330#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 3
5331
5332#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 4
5333template <class VALUE_TYPE, class ALLOCATOR>
5334template <class Args_01,
5335 class Args_02,
5336 class Args_03,
5337 class Args_04>
5338typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5339deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5340 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5341 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5342 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5343 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
5344{
5345 BSLS_ASSERT(position >= this->cbegin());
5346 BSLS_ASSERT(position <= this->cend());
5347
5348 if (position == this->cbegin()) {
5349 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5350 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5351 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5352 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
5353 return this->begin();
5354 }
5355
5356 if (position == this->cend()) {
5357 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5358 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5359 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5360 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
5361 return iterator(this->d_finish - 1);
5362 }
5363
5364
5365 const size_type currentSize = this->size();
5366 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5368
5369 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5370 "deque<...>::emplace(args): deque too big");
5371 }
5372
5373 iterator pos(position.imp());
5374 const size_type posIdx = position - this->cbegin();
5375 if (posIdx <= currentSize / 2) {
5376 BlockCreator newBlocks(this);
5377 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5378 newBlocks.insertAtFront(1);
5379 }
5380
5381 BlockProctor proctor(this, true);
5382 DequePrimitives::emplaceAndMoveToFront(
5383 &this->d_start,
5384 this->d_start,
5385 this->d_start + posIdx,
5386 this->allocatorRef(),
5387 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5388 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5389 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5390 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
5391 proctor.release();
5392 }
5393 else {
5394 BlockCreator newBlocks(this);
5395 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5396 newBlocks.insertAtBack(1);
5397 }
5398
5399 BlockProctor proctor(this, false);
5400 DequePrimitives::emplaceAndMoveToBack(
5401 &this->d_finish,
5402 this->d_finish,
5403 this->d_start + posIdx,
5404 this->allocatorRef(),
5405 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5406 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5407 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5408 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
5409 proctor.release();
5410 }
5411 return this->begin() + posIdx;
5412}
5413#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 4
5414
5415#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 5
5416template <class VALUE_TYPE, class ALLOCATOR>
5417template <class Args_01,
5418 class Args_02,
5419 class Args_03,
5420 class Args_04,
5421 class Args_05>
5422typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5423deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5424 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5425 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5426 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5427 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5428 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
5429{
5430 BSLS_ASSERT(position >= this->cbegin());
5431 BSLS_ASSERT(position <= this->cend());
5432
5433 if (position == this->cbegin()) {
5434 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5435 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5436 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5437 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5438 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
5439 return this->begin();
5440 }
5441
5442 if (position == this->cend()) {
5443 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5444 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5445 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5446 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5447 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
5448 return iterator(this->d_finish - 1);
5449 }
5450
5451
5452 const size_type currentSize = this->size();
5453 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5455
5456 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5457 "deque<...>::emplace(args): deque too big");
5458 }
5459
5460 iterator pos(position.imp());
5461 const size_type posIdx = position - this->cbegin();
5462 if (posIdx <= currentSize / 2) {
5463 BlockCreator newBlocks(this);
5464 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5465 newBlocks.insertAtFront(1);
5466 }
5467
5468 BlockProctor proctor(this, true);
5469 DequePrimitives::emplaceAndMoveToFront(
5470 &this->d_start,
5471 this->d_start,
5472 this->d_start + posIdx,
5473 this->allocatorRef(),
5474 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5475 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5476 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5477 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5478 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
5479 proctor.release();
5480 }
5481 else {
5482 BlockCreator newBlocks(this);
5483 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5484 newBlocks.insertAtBack(1);
5485 }
5486
5487 BlockProctor proctor(this, false);
5488 DequePrimitives::emplaceAndMoveToBack(
5489 &this->d_finish,
5490 this->d_finish,
5491 this->d_start + posIdx,
5492 this->allocatorRef(),
5493 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5494 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5495 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5496 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5497 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
5498 proctor.release();
5499 }
5500 return this->begin() + posIdx;
5501}
5502#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 5
5503
5504#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 6
5505template <class VALUE_TYPE, class ALLOCATOR>
5506template <class Args_01,
5507 class Args_02,
5508 class Args_03,
5509 class Args_04,
5510 class Args_05,
5511 class Args_06>
5512typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5513deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5514 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5515 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5516 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5517 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5518 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5519 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
5520{
5521 BSLS_ASSERT(position >= this->cbegin());
5522 BSLS_ASSERT(position <= this->cend());
5523
5524 if (position == this->cbegin()) {
5525 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5526 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5527 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5528 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5529 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5530 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
5531 return this->begin();
5532 }
5533
5534 if (position == this->cend()) {
5535 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5536 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5537 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5538 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5539 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5540 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
5541 return iterator(this->d_finish - 1);
5542 }
5543
5544
5545 const size_type currentSize = this->size();
5546 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5548
5549 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5550 "deque<...>::emplace(args): deque too big");
5551 }
5552
5553 iterator pos(position.imp());
5554 const size_type posIdx = position - this->cbegin();
5555 if (posIdx <= currentSize / 2) {
5556 BlockCreator newBlocks(this);
5557 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5558 newBlocks.insertAtFront(1);
5559 }
5560
5561 BlockProctor proctor(this, true);
5562 DequePrimitives::emplaceAndMoveToFront(
5563 &this->d_start,
5564 this->d_start,
5565 this->d_start + posIdx,
5566 this->allocatorRef(),
5567 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5568 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5569 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5570 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5571 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5572 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
5573 proctor.release();
5574 }
5575 else {
5576 BlockCreator newBlocks(this);
5577 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5578 newBlocks.insertAtBack(1);
5579 }
5580
5581 BlockProctor proctor(this, false);
5582 DequePrimitives::emplaceAndMoveToBack(
5583 &this->d_finish,
5584 this->d_finish,
5585 this->d_start + posIdx,
5586 this->allocatorRef(),
5587 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5588 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5589 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5590 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5591 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5592 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
5593 proctor.release();
5594 }
5595 return this->begin() + posIdx;
5596}
5597#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 6
5598
5599#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 7
5600template <class VALUE_TYPE, class ALLOCATOR>
5601template <class Args_01,
5602 class Args_02,
5603 class Args_03,
5604 class Args_04,
5605 class Args_05,
5606 class Args_06,
5607 class Args_07>
5608typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5609deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5610 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5611 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5612 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5613 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5614 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5615 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5616 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
5617{
5618 BSLS_ASSERT(position >= this->cbegin());
5619 BSLS_ASSERT(position <= this->cend());
5620
5621 if (position == this->cbegin()) {
5622 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5623 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5624 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5625 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5626 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5627 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5628 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
5629 return this->begin();
5630 }
5631
5632 if (position == this->cend()) {
5633 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5634 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5635 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5636 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5637 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5638 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5639 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
5640 return iterator(this->d_finish - 1);
5641 }
5642
5643
5644 const size_type currentSize = this->size();
5645 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5647
5648 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5649 "deque<...>::emplace(args): deque too big");
5650 }
5651
5652 iterator pos(position.imp());
5653 const size_type posIdx = position - this->cbegin();
5654 if (posIdx <= currentSize / 2) {
5655 BlockCreator newBlocks(this);
5656 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5657 newBlocks.insertAtFront(1);
5658 }
5659
5660 BlockProctor proctor(this, true);
5661 DequePrimitives::emplaceAndMoveToFront(
5662 &this->d_start,
5663 this->d_start,
5664 this->d_start + posIdx,
5665 this->allocatorRef(),
5666 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5667 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5668 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5669 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5670 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5671 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5672 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
5673 proctor.release();
5674 }
5675 else {
5676 BlockCreator newBlocks(this);
5677 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5678 newBlocks.insertAtBack(1);
5679 }
5680
5681 BlockProctor proctor(this, false);
5682 DequePrimitives::emplaceAndMoveToBack(
5683 &this->d_finish,
5684 this->d_finish,
5685 this->d_start + posIdx,
5686 this->allocatorRef(),
5687 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5688 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5689 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5690 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5691 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5692 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5693 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
5694 proctor.release();
5695 }
5696 return this->begin() + posIdx;
5697}
5698#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 7
5699
5700#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 8
5701template <class VALUE_TYPE, class ALLOCATOR>
5702template <class Args_01,
5703 class Args_02,
5704 class Args_03,
5705 class Args_04,
5706 class Args_05,
5707 class Args_06,
5708 class Args_07,
5709 class Args_08>
5710typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5711deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5712 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5713 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5714 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5715 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5716 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5717 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5718 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5719 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
5720{
5721 BSLS_ASSERT(position >= this->cbegin());
5722 BSLS_ASSERT(position <= this->cend());
5723
5724 if (position == this->cbegin()) {
5725 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5726 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5727 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5728 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5729 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5730 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5731 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5732 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5733 return this->begin();
5734 }
5735
5736 if (position == this->cend()) {
5737 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5738 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5739 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5740 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5741 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5742 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5743 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5744 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5745 return iterator(this->d_finish - 1);
5746 }
5747
5748
5749 const size_type currentSize = this->size();
5750 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5752
5753 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5754 "deque<...>::emplace(args): deque too big");
5755 }
5756
5757 iterator pos(position.imp());
5758 const size_type posIdx = position - this->cbegin();
5759 if (posIdx <= currentSize / 2) {
5760 BlockCreator newBlocks(this);
5761 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5762 newBlocks.insertAtFront(1);
5763 }
5764
5765 BlockProctor proctor(this, true);
5766 DequePrimitives::emplaceAndMoveToFront(
5767 &this->d_start,
5768 this->d_start,
5769 this->d_start + posIdx,
5770 this->allocatorRef(),
5771 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5772 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5773 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5774 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5775 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5776 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5777 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5778 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5779 proctor.release();
5780 }
5781 else {
5782 BlockCreator newBlocks(this);
5783 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5784 newBlocks.insertAtBack(1);
5785 }
5786
5787 BlockProctor proctor(this, false);
5788 DequePrimitives::emplaceAndMoveToBack(
5789 &this->d_finish,
5790 this->d_finish,
5791 this->d_start + posIdx,
5792 this->allocatorRef(),
5793 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5794 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5795 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5796 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5797 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5798 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5799 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5800 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5801 proctor.release();
5802 }
5803 return this->begin() + posIdx;
5804}
5805#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 8
5806
5807#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 9
5808template <class VALUE_TYPE, class ALLOCATOR>
5809template <class Args_01,
5810 class Args_02,
5811 class Args_03,
5812 class Args_04,
5813 class Args_05,
5814 class Args_06,
5815 class Args_07,
5816 class Args_08,
5817 class Args_09>
5818typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5819deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5820 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5821 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5822 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5823 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5824 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5825 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5826 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5827 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
5828 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
5829{
5830 BSLS_ASSERT(position >= this->cbegin());
5831 BSLS_ASSERT(position <= this->cend());
5832
5833 if (position == this->cbegin()) {
5834 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5835 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5836 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5837 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5838 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5839 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5840 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5841 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5842 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5843 return this->begin();
5844 }
5845
5846 if (position == this->cend()) {
5847 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5848 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5849 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5850 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5851 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5852 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5853 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5854 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5855 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5856 return iterator(this->d_finish - 1);
5857 }
5858
5859
5860 const size_type currentSize = this->size();
5861 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5863
5864 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5865 "deque<...>::emplace(args): deque too big");
5866 }
5867
5868 iterator pos(position.imp());
5869 const size_type posIdx = position - this->cbegin();
5870 if (posIdx <= currentSize / 2) {
5871 BlockCreator newBlocks(this);
5872 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5873 newBlocks.insertAtFront(1);
5874 }
5875
5876 BlockProctor proctor(this, true);
5877 DequePrimitives::emplaceAndMoveToFront(
5878 &this->d_start,
5879 this->d_start,
5880 this->d_start + posIdx,
5881 this->allocatorRef(),
5882 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5883 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5884 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5885 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5886 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5887 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5888 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5889 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5890 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5891 proctor.release();
5892 }
5893 else {
5894 BlockCreator newBlocks(this);
5895 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
5896 newBlocks.insertAtBack(1);
5897 }
5898
5899 BlockProctor proctor(this, false);
5900 DequePrimitives::emplaceAndMoveToBack(
5901 &this->d_finish,
5902 this->d_finish,
5903 this->d_start + posIdx,
5904 this->allocatorRef(),
5905 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5906 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5907 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5908 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5909 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5910 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5911 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5912 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5913 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5914 proctor.release();
5915 }
5916 return this->begin() + posIdx;
5917}
5918#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 9
5919
5920#if BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 10
5921template <class VALUE_TYPE, class ALLOCATOR>
5922template <class Args_01,
5923 class Args_02,
5924 class Args_03,
5925 class Args_04,
5926 class Args_05,
5927 class Args_06,
5928 class Args_07,
5929 class Args_08,
5930 class Args_09,
5931 class Args_10>
5932typename deque<VALUE_TYPE, ALLOCATOR>::iterator
5933deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
5934 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5935 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5936 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5937 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5938 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5939 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5940 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5941 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
5942 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
5943 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
5944{
5945 BSLS_ASSERT(position >= this->cbegin());
5946 BSLS_ASSERT(position <= this->cend());
5947
5948 if (position == this->cbegin()) {
5949 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5950 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5951 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5952 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5953 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5954 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5955 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5956 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5957 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
5958 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
5959 return this->begin();
5960 }
5961
5962 if (position == this->cend()) {
5963 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5964 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5965 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5966 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5967 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5968 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5969 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5970 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5971 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
5972 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
5973 return iterator(this->d_finish - 1);
5974 }
5975
5976
5977 const size_type currentSize = this->size();
5978 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
5980
5981 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5982 "deque<...>::emplace(args): deque too big");
5983 }
5984
5985 iterator pos(position.imp());
5986 const size_type posIdx = position - this->cbegin();
5987 if (posIdx <= currentSize / 2) {
5988 BlockCreator newBlocks(this);
5989 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
5990 newBlocks.insertAtFront(1);
5991 }
5992
5993 BlockProctor proctor(this, true);
5994 DequePrimitives::emplaceAndMoveToFront(
5995 &this->d_start,
5996 this->d_start,
5997 this->d_start + posIdx,
5998 this->allocatorRef(),
5999 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
6000 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
6001 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
6002 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
6003 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
6004 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
6005 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
6006 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
6007 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
6008 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
6009 proctor.release();
6010 }
6011 else {
6012 BlockCreator newBlocks(this);
6013 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
6014 newBlocks.insertAtBack(1);
6015 }
6016
6017 BlockProctor proctor(this, false);
6018 DequePrimitives::emplaceAndMoveToBack(
6019 &this->d_finish,
6020 this->d_finish,
6021 this->d_start + posIdx,
6022 this->allocatorRef(),
6023 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
6024 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
6025 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
6026 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
6027 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
6028 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
6029 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
6030 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
6031 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
6032 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
6033 proctor.release();
6034 }
6035 return this->begin() + posIdx;
6036}
6037#endif // BSLSTL_DEQUE_VARIADIC_LIMIT_D >= 10
6038
6039#else
6040// The generated code below is a workaround for the absence of perfect
6041// forwarding in some compilers.
6042template <class VALUE_TYPE, class ALLOCATOR>
6043template <class... Args>
6044typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6045deque<VALUE_TYPE, ALLOCATOR>::emplace(const_iterator position,
6046 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments)
6047{
6048 BSLS_ASSERT(position >= this->cbegin());
6049 BSLS_ASSERT(position <= this->cend());
6050
6051 if (position == this->cbegin()) {
6052 emplace_front(BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
6053 return this->begin();
6054 }
6055
6056 if (position == this->cend()) {
6057 emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
6058 return iterator(this->d_finish - 1);
6059 }
6060
6061
6062 const size_type currentSize = this->size();
6063 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
6065
6066 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
6067 "deque<...>::emplace(args): deque too big");
6068 }
6069
6070 iterator pos(position.imp());
6071 const size_type posIdx = position - this->cbegin();
6072 if (posIdx <= currentSize / 2) {
6073 BlockCreator newBlocks(this);
6074 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
6075 newBlocks.insertAtFront(1);
6076 }
6077
6078 BlockProctor proctor(this, true);
6079 DequePrimitives::emplaceAndMoveToFront(
6080 &this->d_start,
6081 this->d_start,
6082 this->d_start + posIdx,
6083 this->allocatorRef(),
6084 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
6085 proctor.release();
6086 }
6087 else {
6088 BlockCreator newBlocks(this);
6089 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
6090 newBlocks.insertAtBack(1);
6091 }
6092
6093 BlockProctor proctor(this, false);
6094 DequePrimitives::emplaceAndMoveToBack(
6095 &this->d_finish,
6096 this->d_finish,
6097 this->d_start + posIdx,
6098 this->allocatorRef(),
6099 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
6100 proctor.release();
6101 }
6102 return this->begin() + posIdx;
6103}
6104// }}} END GENERATED CODE
6105#endif
6106
6107template <class VALUE_TYPE, class ALLOCATOR>
6108void deque<VALUE_TYPE, ALLOCATOR>::pop_front()
6109{
6110 BSLS_ASSERT(!this->empty());
6111
6112 BloombergLP::bslma::DestructionUtil::destroy(this->d_start.valuePtr());
6113
6114 if (1 == this->d_start.remainingInBlock()) {
6115 this->deallocateBlock(*this->d_start.blockPtr());
6116 this->d_start.nextBlock();
6117 return; // RETURN
6118 }
6119
6120 this->d_start.valuePtrIncrement();
6121}
6122
6123template <class VALUE_TYPE, class ALLOCATOR>
6124void deque<VALUE_TYPE, ALLOCATOR>::pop_back()
6125{
6126 BSLS_ASSERT(!this->empty());
6127
6128 if (0 == this->d_finish.offsetInBlock()) {
6129 --this->d_finish;
6130 BloombergLP::bslma::DestructionUtil::destroy(
6131 this->d_finish.valuePtr());
6132 this->deallocateBlock(this->d_finish.blockPtr()[1]);
6133 return; // RETURN
6134 }
6135
6136 this->d_finish.valuePtrDecrement();
6137 BloombergLP::bslma::DestructionUtil::destroy(this->d_finish.valuePtr());
6138}
6139
6140template <class VALUE_TYPE, class ALLOCATOR>
6141typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6142deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
6143 const VALUE_TYPE& value)
6144{
6145 BSLS_ASSERT(position >= this->cbegin());
6146 BSLS_ASSERT(position <= this->cend());
6147
6148 if (position == this->cbegin()) {
6149 push_front(value);
6150 return this->begin(); // RETURN
6151 }
6152
6153 if (position == this->cend()) {
6154 push_back(value);
6155 return iterator(this->d_finish - 1); // RETURN
6156 }
6157
6158 // The test is placed here because 'push_front' and 'push_back' do the same
6159 // check.
6160
6161 const size_type currentSize = this->size();
6162 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
6164
6165 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
6166 "deque<...>::insert(pos,n,v): deque too big");
6167 }
6168
6169 iterator pos(position.imp());
6170 const size_type posIdx = position - this->cbegin();
6171 if (posIdx <= currentSize / 2) {
6172 BlockCreator newBlocks(this);
6173 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
6174 newBlocks.insertAtFront(1);
6175 }
6176 DequePrimitives::insertAndMoveToFront(&this->d_start,
6177 this->d_start,
6178 this->d_start + posIdx,
6179 1,
6180 value,
6181 this->allocatorRef());
6182 }
6183 else {
6184 BlockCreator newBlocks(this);
6185 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
6186 newBlocks.insertAtBack(1);
6187 }
6188 DequePrimitives::insertAndMoveToBack(&this->d_finish,
6189 this->d_finish,
6190 this->d_start + posIdx,
6191 1,
6192 value,
6193 this->allocatorRef());
6194 }
6195 return this->begin() + posIdx;
6196}
6197
6198template <class VALUE_TYPE, class ALLOCATOR>
6199typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6200deque<VALUE_TYPE, ALLOCATOR>::insert(
6201 const_iterator position,
6202 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value)
6203{
6204 BSLS_ASSERT(position >= this->cbegin());
6205 BSLS_ASSERT(position <= this->cend());
6206
6207 VALUE_TYPE& lvalue = value;
6208
6209 if (position == this->cbegin()) {
6210 push_front(MoveUtil::move(lvalue));
6211 return this->begin(); // RETURN
6212 }
6213
6214 if (position == this->cend()) {
6215 push_back(MoveUtil::move(lvalue));
6216 return iterator(this->d_finish - 1); // RETURN
6217 }
6218
6219 // The test is placed here because 'push_front' and 'push_back' do the same
6220 // check.
6221
6222 const size_type currentSize = this->size();
6223 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(currentSize >= max_size())) {
6225
6226 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
6227 "deque<...>::insert(pos,n,v): deque too big");
6228 }
6229
6230 iterator pos(position.imp());
6231 const size_type posIdx = position - this->cbegin();
6232 if (posIdx <= currentSize / 2) {
6233 BlockCreator newBlocks(this);
6234 if (this->d_start.remainingInBlock() == BLOCK_LENGTH) {
6235 newBlocks.insertAtFront(1);
6236 }
6237 DequePrimitives::moveInsertAndMoveToFront(&this->d_start,
6238 this->d_start,
6239 this->d_start + posIdx,
6240 MoveUtil::move(lvalue),
6241 this->allocatorRef());
6242 }
6243 else {
6244 BlockCreator newBlocks(this);
6245 if (this->d_finish.offsetInBlock() == BLOCK_LENGTH - 1) {
6246 newBlocks.insertAtBack(1);
6247 }
6248 DequePrimitives::moveInsertAndMoveToBack(&this->d_finish,
6249 this->d_finish,
6250 this->d_start + posIdx,
6251 MoveUtil::move(lvalue),
6252 this->allocatorRef());
6253 }
6254 return this->begin() + posIdx;
6255}
6256
6257template <class VALUE_TYPE, class ALLOCATOR>
6258typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6259deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
6260 size_type numElements,
6261 const VALUE_TYPE& value)
6262{
6263 BSLS_ASSERT(position >= this->cbegin());
6264 BSLS_ASSERT(position <= this->cend());
6265
6266 const size_type posIdx = position - this->cbegin();
6267
6268 if (0 == numElements) {
6269 return this->begin() + posIdx; // RETURN
6270 }
6271
6272 const size_type currentSize = this->size();
6274 numElements > max_size() - currentSize)) {
6276
6277 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
6278 "deque<...>::insert(pos,n,v): deque too big");
6279 }
6280
6281 if (position == this->cbegin()) {
6282 privatePrependRaw(numElements, value);
6283
6284 return this->begin(); // RETURN
6285 }
6286
6287 if (position == this->cend()) {
6288 privateAppendRaw(numElements, value);
6289
6290 return this->begin() + posIdx; // RETURN
6291 }
6292
6293 if (posIdx <= currentSize / 2) {
6294 // Create new blocks at front. In case an exception is thrown, any
6295 // unused blocks are returned to the allocator.
6296
6297 size_type numNewBlocks = (this->d_start.remainingInBlock()
6298 + numElements - 1) / BLOCK_LENGTH;
6299 BlockCreator newBlocks(this);
6300 newBlocks.insertAtFront(numNewBlocks);
6301
6302 DequePrimitives::insertAndMoveToFront(&this->d_start,
6303 this->d_start,
6304 this->d_start + posIdx,
6305 numElements,
6306 value,
6307 this->allocatorRef());
6308 }
6309 else {
6310 // Create new blocks at back. In case an exception is thrown, any
6311 // unused blocks are returned to the allocator.
6312
6313 size_type numNewBlocks = (this->d_finish.offsetInBlock() + numElements)
6314 / BLOCK_LENGTH;
6315 BlockCreator newBlocks(this);
6316 newBlocks.insertAtBack(numNewBlocks);
6317
6318 DequePrimitives::insertAndMoveToBack(&this->d_finish,
6319 this->d_finish,
6320 this->d_start + posIdx,
6321 numElements,
6322 value,
6323 this->allocatorRef());
6324 }
6325
6326 return this->begin() + posIdx;
6327}
6328
6329template <class VALUE_TYPE, class ALLOCATOR>
6330template <class INPUT_ITERATOR>
6331inline
6332typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6333deque<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
6334 INPUT_ITERATOR first,
6335 INPUT_ITERATOR last)
6336{
6337 BSLS_ASSERT_SAFE(position >= this->cbegin());
6338 BSLS_ASSERT_SAFE(position <= this->cend());
6339
6340 const size_type posIdx = position - this->cbegin();
6341
6342 privateInsertDispatch(position,
6343 first,
6344 last,
6345 first,
6346 BloombergLP::bslmf::Nil());
6347
6348 return this->begin() + posIdx;
6349}
6350
6351#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6352template <class VALUE_TYPE, class ALLOCATOR>
6353inline
6354typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6355deque<VALUE_TYPE, ALLOCATOR>::insert(
6356 const_iterator position,
6357 std::initializer_list<value_type> values)
6358{
6359 BSLS_ASSERT_SAFE(position >= this->cbegin());
6360 BSLS_ASSERT_SAFE(position <= this->cend());
6361
6362 return insert(position, values.begin(), values.end());
6363}
6364#endif
6365
6366template <class VALUE_TYPE, class ALLOCATOR>
6367template <class t_RANGE>
6369typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6370deque<VALUE_TYPE, ALLOCATOR>::insert_range(
6371 const_iterator position,
6372 BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
6373{
6374 const size_type posIdx = position - this->cbegin();
6375 privateInsert(position, ranges::begin(range), ranges::end(range));
6376 return this->begin() + posIdx;
6377}
6378
6379template <class VALUE_TYPE, class ALLOCATOR>
6380typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6381deque<VALUE_TYPE, ALLOCATOR>::erase(const_iterator position)
6382{
6383 BSLS_ASSERT(position >= this->cbegin());
6384 BSLS_ASSERT(position < this->cend());
6385
6386 if (position == const_iterator(this->d_start)) {
6387 pop_front();
6388 return this->begin(); // RETURN
6389 }
6390
6391 if (position + 1 == const_iterator(this->d_finish)) {
6392 pop_back();
6393 return this->end(); // RETURN
6394 }
6395
6396 return erase(position, position + 1);
6397}
6398
6399template <class VALUE_TYPE, class ALLOCATOR>
6400typename deque<VALUE_TYPE, ALLOCATOR>::iterator
6401deque<VALUE_TYPE, ALLOCATOR>::erase(const_iterator first, const_iterator last)
6402{
6403 BSLS_ASSERT(first >= this->cbegin());
6404 BSLS_ASSERT(first <= this->cend());
6405 BSLS_ASSERT(first <= last);
6406 BSLS_ASSERT(last <= this->cend());
6407
6408 iterator first_imp = this->begin() + (first - this->cbegin());
6409 iterator last_imp = this->begin() + (last - this->cbegin());
6410 iterator oldStart = this->begin();
6411 iterator oldFinish = this->end();
6412 iterator result = iterator(DequePrimitives::erase(&this->d_start,
6413 &this->d_finish,
6414 this->d_start,
6415 first_imp.imp(),
6416 last_imp.imp(),
6417 this->d_finish,
6418 this->allocatorRef()));
6419
6420 // Deallocate blocks no longer used.
6421
6422 for ( ; oldStart.imp().blockPtr() != this->d_start.blockPtr();
6423 oldStart.imp().nextBlock()) {
6424 this->deallocateBlock(oldStart.imp().blockPtr()[0]);
6425 }
6426 for ( ; oldFinish.imp().blockPtr() != this->d_finish.blockPtr();
6427 oldFinish.imp().previousBlock()) {
6428 this->deallocateBlock(oldFinish.imp().blockPtr()[0]);
6429 }
6430 return result;
6431}
6432
6433template <class VALUE_TYPE, class ALLOCATOR>
6434void deque<VALUE_TYPE, ALLOCATOR>::swap(deque<VALUE_TYPE, ALLOCATOR>& other)
6436 AllocatorTraits::is_always_equal::value)
6437{
6438 typedef typename
6439 AllocatorTraits::propagate_on_container_swap Propagate;
6440 if (Propagate::value) {
6441 Deque_Util::swap(static_cast<Base *>(this),
6442 static_cast<Base *>(&other));
6443 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
6444 Propagate());
6445 }
6446 else {
6448 this->get_allocator() == other.get_allocator())) {
6449 Deque_Util::swap(static_cast<Base *>(this),
6450 static_cast<Base *>(&other));
6451 }
6452 else {
6454
6455 deque toOtherCopy(MoveUtil::move(*this), other.get_allocator());
6456 deque toThisCopy( MoveUtil::move(other), this->get_allocator());
6457
6458 Deque_Util::swap(static_cast<Base *>(&toThisCopy),
6459 static_cast<Base *>(this));
6460 Deque_Util::swap(static_cast<Base *>(&toOtherCopy),
6461 static_cast<Base *>(&other));
6462 }
6463 }
6464}
6465
6466template <class VALUE_TYPE, class ALLOCATOR>
6467void deque<VALUE_TYPE, ALLOCATOR>::clear() BSLS_KEYWORD_NOEXCEPT
6468{
6469 DequePrimitives::destruct(this->d_start,
6470 this->d_finish,
6471 this->allocatorRef());
6472
6473 // Deallocate all blocks except 'finishBlock'.
6474
6475 BlockPtr *startBlock = this->d_start.blockPtr();
6476 BlockPtr *finishBlock = this->d_finish.blockPtr();
6477 for ( ; startBlock != finishBlock; ++startBlock) {
6478 this->deallocateBlock(*startBlock);
6479 }
6480
6481 // Reposition in the middle.
6482
6483 size_type blockOffset = this->d_blocksLength / 2;
6484 int offset = BLOCK_LENGTH / 2;
6485 BlockPtr *blockPtr = this->d_blocks_p + blockOffset;
6486
6487 *blockPtr = *finishBlock;
6488
6489 this->d_start = this->d_finish = IteratorImp(blockPtr,
6490 (*blockPtr)->d_data + offset);
6491}
6492
6493// ACCESSORS
6494template <class VALUE_TYPE, class ALLOCATOR>
6495inline
6496typename deque<VALUE_TYPE, ALLOCATOR>::allocator_type
6497deque<VALUE_TYPE, ALLOCATOR>::get_allocator() const BSLS_KEYWORD_NOEXCEPT
6498{
6499 return this->allocatorRef();
6500}
6501
6502template <class VALUE_TYPE, class ALLOCATOR>
6503inline
6504typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6505deque<VALUE_TYPE, ALLOCATOR>::max_size() const BSLS_KEYWORD_NOEXCEPT
6506{
6507 return AllocatorTraits::max_size(this->get_allocator());
6508}
6509
6510// FREE OPERATORS
6511template <class VALUE_TYPE, class ALLOCATOR>
6512bool operator==(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6513 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6514{
6515 if (lhs.size() != rhs.size()) {
6516 return false; // RETURN
6517 }
6518
6519 enum {
6520 BLOCK_LENGTH = Deque_BlockLengthCalcUtil<VALUE_TYPE>::BLOCK_LENGTH
6521 };
6522
6523 typedef BloombergLP::bslalg::DequeIterator<VALUE_TYPE,
6524 BLOCK_LENGTH> Iterator;
6525
6526 Iterator lhsBegin = lhs.begin().imp();
6527 Iterator lhsEnd = lhs.end().imp();
6528 Iterator rhsBegin = rhs.begin().imp();
6529
6530 for (; !(lhsBegin == lhsEnd); ++lhsBegin, ++rhsBegin) {
6531 if (!(*lhsBegin == *rhsBegin)) {
6532 return false; // RETURN
6533 }
6534 }
6535 return true;
6536}
6537
6538#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
6539
6540template <class VALUE_TYPE, class ALLOCATOR>
6541inline
6542bool operator!=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6543 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6544{
6545 return !(lhs == rhs);
6546}
6547
6548#endif
6549
6550#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
6551
6552template <class VALUE_TYPE, class ALLOCATOR>
6553inline
6554BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
6555 const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6556 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6557{
6558 return bsl::lexicographical_compare_three_way(
6559 lhs.begin(),
6560 lhs.end(),
6561 rhs.begin(),
6562 rhs.end(),
6563 BloombergLP::bslalg::SynthThreeWayUtil::compare);
6564}
6565
6566#else
6567
6568template <class VALUE_TYPE, class ALLOCATOR>
6569inline
6570bool operator<(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6571 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6572{
6573 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
6574 lhs.end(),
6575 lhs.size(),
6576 rhs.begin(),
6577 rhs.end(),
6578 rhs.size());
6579}
6580
6581template <class VALUE_TYPE, class ALLOCATOR>
6582inline
6583bool operator>(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6584 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6585{
6586 return rhs < lhs;
6587}
6588
6589template <class VALUE_TYPE, class ALLOCATOR>
6590inline
6591bool operator<=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6592 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6593{
6594 return !(rhs < lhs);
6595}
6596
6597template <class VALUE_TYPE, class ALLOCATOR>
6598inline
6599bool operator>=(const deque<VALUE_TYPE, ALLOCATOR>& lhs,
6600 const deque<VALUE_TYPE, ALLOCATOR>& rhs)
6601{
6602 return !(lhs < rhs);
6603}
6604
6605#endif // BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
6606
6607// FREE FUNCTIONS
6608template <class VALUE_TYPE, class ALLOCATOR, class BDE_OTHER_TYPE>
6609inline typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6610erase(deque<VALUE_TYPE, ALLOCATOR>& deq, const BDE_OTHER_TYPE& value)
6611{
6612 typename deque<VALUE_TYPE, ALLOCATOR>::size_type oldSize = deq.size();
6613 deq.erase(bsl::remove(deq.begin(), deq.end(), value), deq.end());
6614 return oldSize - deq.size();
6615}
6616
6617template <class VALUE_TYPE, class ALLOCATOR, class PREDICATE>
6618inline typename deque<VALUE_TYPE, ALLOCATOR>::size_type
6619erase_if(deque<VALUE_TYPE, ALLOCATOR>& deq, PREDICATE predicate)
6620{
6621 typename deque<VALUE_TYPE, ALLOCATOR>::size_type oldSize = deq.size();
6622 deq.erase(bsl::remove_if(deq.begin(), deq.end(), predicate), deq.end());
6623 return oldSize - deq.size();
6624}
6625
6626template <class VALUE_TYPE, class ALLOCATOR>
6627inline
6628void swap(deque<VALUE_TYPE, ALLOCATOR>& a, deque<VALUE_TYPE, ALLOCATOR>& b)
6630 a.swap(b)))
6631{
6632 a.swap(b);
6633}
6634
6635 // ------------------------
6636 // class Deque_BlockCreator
6637 // ------------------------
6638
6639// CREATORS
6640template <class VALUE_TYPE, class ALLOCATOR>
6641inline
6642Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::Deque_BlockCreator(
6643 deque<VALUE_TYPE, ALLOCATOR> *deque)
6644: d_deque_p(deque)
6645, d_boundary_p(0)
6646{
6647}
6648
6649template <class VALUE_TYPE, class ALLOCATOR>
6650Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::~Deque_BlockCreator()
6651{
6652 if (0 != d_boundary_p) {
6653 BlockPtr *delFirst, *delLast;
6654 if (d_boundary_p <= d_deque_p->d_start.blockPtr()) {
6655 delFirst = d_boundary_p;
6656 delLast = d_deque_p->d_start.blockPtr();
6657 }
6658 else {
6659 delFirst = d_deque_p->d_finish.blockPtr() + 1;
6660 delLast = d_boundary_p;
6661 }
6662
6663 for (; delFirst != delLast; ++delFirst) {
6664 // Deallocate the block that '*delFirst' points to.
6665 d_deque_p->deallocateBlock(*delFirst);
6666 }
6667 }
6668}
6669
6670// MANIPULATORS
6671template <class VALUE_TYPE, class ALLOCATOR>
6672void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::insertAtFront(size_type n)
6673{
6674 d_boundary_p = reserveBlockSlots(n, true);
6675 for ( ; n > 0; --n) {
6676 d_boundary_p[-1] = d_deque_p->allocateBlock();
6677
6678 --d_boundary_p;
6679 }
6680}
6681
6682template <class VALUE_TYPE, class ALLOCATOR>
6683void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::insertAtBack(size_type n)
6684{
6685 d_boundary_p = reserveBlockSlots(n, false);
6686 for ( ; n > 0; --n) {
6687 *d_boundary_p = d_deque_p->allocateBlock();
6688 ++d_boundary_p;
6689 }
6690}
6691
6692template <class VALUE_TYPE, class ALLOCATOR>
6693typename Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::BlockPtr *
6694Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::reserveBlockSlots(
6695 size_type numNewBlocks,
6696 bool atFront)
6697{
6698 BlockPtr *blocks = d_deque_p->d_blocks_p;
6699 size_type blocksLength = d_deque_p->d_blocksLength;
6700
6701 BlockPtr *firstSlot = d_deque_p->d_start.blockPtr();
6702 BlockPtr *lastSlot = d_deque_p->d_finish.blockPtr() + 1;
6703
6704 if (atFront) {
6705 if (d_boundary_p) {
6706 firstSlot = d_boundary_p;
6707 }
6708 if (size_type(firstSlot - blocks) >= numNewBlocks) {
6709 // Enough room to insert at the front.
6710
6711 return firstSlot; // RETURN
6712 }
6713 }
6714 else {
6715 if (d_boundary_p) {
6716 lastSlot = d_boundary_p;
6717 }
6718 if (size_type(blocks + blocksLength - lastSlot) >= numNewBlocks) {
6719 // Enough room to insert at the back.
6720
6721 return lastSlot; // RETURN
6722 }
6723 }
6724
6725 BlockPtr *newBlocks = blocks;
6726 size_type newBlocksLength = blocksLength;
6727 size_type numUsedBlocks = lastSlot - firstSlot;
6728 size_type blockOffsetStart = d_deque_p->d_start.blockPtr() - firstSlot;
6729 size_type numCommittedBlocks = (d_deque_p->d_finish.blockPtr() -
6730 d_deque_p->d_start.blockPtr() + 1);
6731 size_type newNumUsedBlocks = numUsedBlocks + numNewBlocks;
6732
6733 if (newNumUsedBlocks > blocksLength) {
6734 const size_type newThreshold = newNumUsedBlocks +
6735 2 * Imp::BLOCK_ARRAY_PADDING;
6736 while (newThreshold > newBlocksLength) {
6737 // Insufficient room. Allocate new blocks array with geometric
6738 // growth. Note that this should never overflow because there are
6739 // at least 16 elements in each block, thus the requested block
6740 // array pointer will never be close to 'max_size() / 2'.
6741
6742 newBlocksLength *= 2;
6743 }
6744 newBlocks = d_deque_p->allocateBlockPtrs(newBlocksLength);
6745 }
6746
6747 // Center block pointers within new blocks array.
6748
6749 BlockPtr *newFirstSlot = newBlocks +
6750 (newBlocksLength - newNumUsedBlocks) / 2;
6751
6752 if (atFront) {
6753 newFirstSlot += numNewBlocks;
6754 }
6755
6756 // Calculate offset for start and finish. Need to do this before moving
6757 // around blocks.
6758
6759 const size_type offsetStart = d_deque_p->d_start.offsetInBlock();
6760 const size_type offsetFinish = d_deque_p->d_finish.offsetInBlock();
6761
6762 // Move old block pointers into new position.
6763
6764 std::memmove(newFirstSlot, firstSlot, numUsedBlocks * sizeof(BlockPtr));
6765
6766 if (newBlocks != blocks) {
6767 // Deallocate old blocks array and install the new one.
6768
6769 if (blocks) {
6770 d_deque_p->deallocateBlockPtrs(blocks, d_deque_p->d_blocksLength);
6771 }
6772 d_deque_p->d_blocks_p = newBlocks;
6773 d_deque_p->d_blocksLength = newBlocksLength;
6774 }
6775
6776 // Adjust start and finish iterators.
6777
6778 d_deque_p->d_start.setBlock(newFirstSlot + blockOffsetStart);
6779 d_deque_p->d_start += offsetStart;
6780 d_deque_p->d_finish.setBlock(newFirstSlot + blockOffsetStart +
6781 numCommittedBlocks - 1);
6782 d_deque_p->d_finish += offsetFinish;
6783
6784 BlockPtr *ret = newFirstSlot;
6785 if (!atFront) {
6786 ret += numUsedBlocks;
6787 }
6788
6789 return ret;
6790}
6791
6792template <class VALUE_TYPE, class ALLOCATOR>
6793inline
6794void Deque_BlockCreator<VALUE_TYPE, ALLOCATOR>::release()
6795{
6796 d_boundary_p = 0;
6797}
6798
6799 // ------------------------
6800 // class Deque_BlockProctor
6801 // ------------------------
6802
6803// CREATORS
6804template <class VALUE_TYPE, class ALLOCATOR>
6805Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::Deque_BlockProctor(
6806 deque<VALUE_TYPE, ALLOCATOR> *deque,
6807 bool atFront)
6808: d_deque_p(deque)
6809, d_boundary_p(atFront
6810 ? d_deque_p->d_start.blockPtr()
6811 : d_deque_p->d_finish.blockPtr())
6812, d_atFront(atFront)
6813{
6814}
6815
6816template <class VALUE_TYPE, class ALLOCATOR>
6817Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::~Deque_BlockProctor()
6818{
6819 if (0 != d_deque_p) {
6820 BlockPtr *delFirst, *delLast;
6821
6822 if (d_atFront && d_boundary_p < d_deque_p->d_start.blockPtr()) {
6823 // Blocks at the front of the deque have been emptied since this
6824 // proctor was created.
6825
6826 delFirst = d_boundary_p;
6827 delLast = d_deque_p->d_start.blockPtr();
6828 }
6829 else if (!d_atFront && d_boundary_p > d_deque_p->d_finish.blockPtr()) {
6830 // Blocks at the back of the deque have been emptied since this
6831 // proctor was created.
6832
6833 delFirst = d_deque_p->d_finish.blockPtr() + 1;
6834 delLast = d_boundary_p + 1;
6835 }
6836 else {
6837 return; // RETURN
6838 }
6839
6840 for (; delFirst != delLast; ++delFirst) {
6841 // Deallocate the block that '*delFirst' points to.
6842
6843 d_deque_p->deallocateBlock(*delFirst);
6844 }
6845 }
6846}
6847
6848// MANIPULATORS
6849template <class VALUE_TYPE, class ALLOCATOR>
6850inline
6851void Deque_BlockProctor<VALUE_TYPE, ALLOCATOR>::release()
6852{
6853 d_deque_p = 0;
6854}
6855
6856 // ----------------------
6857 // class Deque_ClearGuard
6858 // ----------------------
6859
6860// CREATORS
6861template <class VALUE_TYPE, class ALLOCATOR>
6862inline
6863Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::Deque_ClearGuard(
6864 deque<VALUE_TYPE, ALLOCATOR> *deque)
6865: d_deque_p(deque)
6866{
6867}
6868
6869template <class VALUE_TYPE, class ALLOCATOR>
6870inline
6871Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::~Deque_ClearGuard()
6872{
6873 if (d_deque_p) {
6874 d_deque_p->clear();
6875 }
6876}
6877
6878// MANIPULATORS
6879template <class VALUE_TYPE, class ALLOCATOR>
6880inline
6881void Deque_ClearGuard<VALUE_TYPE, ALLOCATOR>::release()
6882{
6883 d_deque_p = 0;
6884}
6885
6886 // -----------------
6887 // class Deque_Guard
6888 // -----------------
6889
6890// CREATORS
6891template <class VALUE_TYPE, class ALLOCATOR>
6892inline
6893Deque_Guard<VALUE_TYPE, ALLOCATOR>::Deque_Guard(
6894 deque<VALUE_TYPE, ALLOCATOR> *deque,
6895 bool isTail)
6896: d_deque_p(deque)
6897, d_count(0)
6898, d_isTail(isTail)
6899{
6900}
6901
6902template <class VALUE_TYPE, class ALLOCATOR>
6903Deque_Guard<VALUE_TYPE, ALLOCATOR>::~Deque_Guard()
6904{
6905 if (0 == d_count) {
6906 return; // RETURN
6907 }
6908
6909 IteratorImp begin, end;
6910
6911 if (d_isTail) {
6912 begin = d_deque_p->d_finish;
6913 end = begin + d_count;
6914 }
6915 else {
6916 end = d_deque_p->d_start;
6917 begin = end - d_count;
6918 }
6919
6920 DequePrimitives::destruct(begin, end, d_deque_p->get_allocator());
6921}
6922
6923// MANIPULATORS
6924template <class VALUE_TYPE, class ALLOCATOR>
6925inline
6926std::size_t Deque_Guard<VALUE_TYPE, ALLOCATOR>::operator++()
6927{
6928 return ++d_count;
6929}
6930
6931template <class VALUE_TYPE, class ALLOCATOR>
6932inline
6933std::size_t Deque_Guard<VALUE_TYPE, ALLOCATOR>::operator--()
6934{
6935 return --d_count;
6936}
6937
6938template <class VALUE_TYPE, class ALLOCATOR>
6939inline
6940void Deque_Guard<VALUE_TYPE, ALLOCATOR>::release()
6941{
6942 d_count = 0;
6943}
6944
6945// ACCESSORS
6946template <class VALUE_TYPE, class ALLOCATOR>
6947inline
6948std::size_t
6949Deque_Guard<VALUE_TYPE, ALLOCATOR>::count() const BSLS_KEYWORD_NOEXCEPT
6950{
6951 return d_count;
6952}
6953
6954template <class VALUE_TYPE, class ALLOCATOR>
6955inline
6956typename Deque_Guard<VALUE_TYPE, ALLOCATOR>::IteratorImp
6957Deque_Guard<VALUE_TYPE, ALLOCATOR>::begin() const BSLS_KEYWORD_NOEXCEPT
6958{
6959 return d_deque_p->d_start - d_count;
6960}
6961
6962template <class VALUE_TYPE, class ALLOCATOR>
6963inline
6964typename Deque_Guard<VALUE_TYPE, ALLOCATOR>::IteratorImp
6965Deque_Guard<VALUE_TYPE, ALLOCATOR>::end() const BSLS_KEYWORD_NOEXCEPT
6966{
6967 return d_deque_p->d_finish + d_count;
6968}
6969
6970} // close namespace bsl
6971
6972// ============================================================================
6973// TYPE TRAITS
6974// ============================================================================
6975
6976// Type traits for STL *sequence* containers:
6977//: o A sequence container defines STL iterators.
6978//: o A sequence container is bitwise-movable if its allocator is
6979//: bitwise-movable.
6980//: o A sequence container uses 'bslma' allocators if the (template parameter)
6981//: type 'ALLOCATOR' is convertible from 'bslma::Allocator *'.
6982
6983
6984
6985namespace bslalg {
6986
6987template <class VALUE_TYPE, class ALLOCATOR>
6988struct HasStlIterators<bsl::deque<VALUE_TYPE, ALLOCATOR> > : bsl::true_type
6989{
6990};
6991
6992} // close namespace bslalg
6993
6994namespace bslmf {
6995
6996template <class VALUE_TYPE, class ALLOCATOR>
6997struct IsBitwiseMoveable<bsl::deque<VALUE_TYPE, ALLOCATOR> >
6998 : IsBitwiseMoveable<ALLOCATOR>
6999{
7000};
7001
7002} // close namespace bslmf
7003
7004namespace bslma {
7005
7006template <class VALUE_TYPE, class ALLOCATOR>
7007struct UsesBslmaAllocator<bsl::deque<VALUE_TYPE, ALLOCATOR> >
7008 : bsl::is_convertible<Allocator *, ALLOCATOR>
7009{
7010};
7011
7012} // close namespace bslma
7013
7014
7015
7016#else // if ! defined(DEFINED_BSLSTL_DEQUE_H)
7017# error Not valid except when included from bslstl_deque.h
7018#endif // ! defined(COMPILING_BSLSTL_DEQUE_H)
7019
7020#endif // ! defined(INCLUDED_BSLSTL_DEQUE_CPP03)
7021
7022// ----------------------------------------------------------------------------
7023// Copyright 2013 Bloomberg Finance L.P.
7024//
7025// Licensed under the Apache License, Version 2.0 (the "License");
7026// you may not use this file except in compliance with the License.
7027// You may obtain a copy of the License at
7028//
7029// http://www.apache.org/licenses/LICENSE-2.0
7030//
7031// Unless required by applicable law or agreed to in writing, software
7032// distributed under the License is distributed on an "AS IS" BASIS,
7033// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7034// See the License for the specific language governing permissions and
7035// limitations under the License.
7036// ----------------------------- END-OF-FILE ----------------------------------
7037
7038/** @} */
7039/** @} */
7040/** @} */
IteratorImp d_finish
Definition bslstl_deque.h:659
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2233
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2107
reference back()
Definition bslstl_deque.h:2164
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2115
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements contained by this deque.
Definition bslstl_deque.h:2241
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2185
bsl::reverse_iterator< Iterator > reverse_iterator
Definition bslstl_deque.h:651
std::size_t d_blocksLength
Definition bslstl_deque.h:657
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2123
bsl::reverse_iterator< ConstIterator > const_reverse_iterator
Definition bslstl_deque.h:652
reference front()
Definition bslstl_deque.h:2154
BlockPtr * d_blocks_p
Definition bslstl_deque.h:656
Iterator iterator
Definition bslstl_deque.h:638
ConstIterator const_iterator
Definition bslstl_deque.h:639
VALUE_TYPE value_type
Definition bslstl_deque.h:642
iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2099
const VALUE_TYPE & const_reference
Definition bslstl_deque.h:637
size_type capacity() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2248
std::size_t size_type
Definition bslstl_deque.h:640
reference at(size_type position)
Definition bslstl_deque.h:2140
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2201
bool empty() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2287
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_deque.h:2217
VALUE_TYPE & reference
Definition bslstl_deque.h:636
IteratorImp d_start
Definition bslstl_deque.h:658
std::ptrdiff_t difference_type
Definition bslstl_deque.h:641
Definition bslma_bslallocator.h:588
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
static const t_TYPE value
Definition bslmf_integralconstant.h:267
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:2045
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:677
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLS_PERFORMANCEHINT_PREDICT_LIKELY(expr)
Definition bsls_performancehint.h:451
#define BSLS_PERFORMANCEHINT_UNLIKELY_HINT
Definition bsls_performancehint.h:484
#define BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(expr)
Definition bsls_performancehint.h:452
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:296
#define BSLSTL_DEQUE_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
Definition bslstl_deque.h:524
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 reserve(TYPE *array, int numElements)
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:408
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
Definition bdlat_valuetypefunctions.h:939
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1709
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4424
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
T::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1651
ALLOCATOR & lhs
Definition bslstl_string.h:3917
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4433
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1377
Definition bdlc_flathashmap.h:2218
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
@ DEFAULT_BLOCK_SIZE
Definition bslstl_deque.h:565
@ BLOCK_LENGTH
Definition bslstl_deque.h:567
static void swap(void *a, void *b)
static void move(void *dst, void *src)
Definition bslma_allocatortraits.h:1089
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1196
Definition bslmf_isconvertible.h:875