BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_vector_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_vector_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_vector_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_VECTOR_CPP03
12#define INCLUDED_BSLSTL_VECTOR_CPP03
13
14/// @defgroup bslstl_vector_cpp03 bslstl_vector_cpp03
15/// @brief Provide C++03 implementation for bslstl_vector.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_vector_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_vector_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_vector_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_vector_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_vector_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_vector.h
30///
31/// # Classes {#bslstl_vector_cpp03-classes}
32/// See bslstl_vector.h for list of classes
33///
34/// @see bslstl_vector
35///
36/// # Description {#bslstl_vector_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 Sun Sep 1 05:39:12 2024
48/// Command line: sim_cpp11_features.pl bslstl_vector.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_vector_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_VECTOR_H
64
65namespace bsl {
66
67// Forward declarations
68
69template <class VALUE_TYPE, class ITERATOR>
70class vector_UintPtrConversionIterator;
71
72 // ==================
73 // struct Vector_Util
74 // ==================
75
76/// This `struct` provides a namespace for implementing the `swap` member
77/// function of `vector<VALUE_TYPE, ALLOCATOR>`. `swap` can be implemented
78/// irrespective of the `VALUE_TYPE` or `ALLOCATOR` template parameters,
79/// which is why we implement it in this non-parameterized, non-inlined
80/// utility.
81struct Vector_Util {
82
83 // CLASS METHODS
84
85 /// Return a capacity that is at least the specified `newLength` and at
86 /// least the minimum of twice the specified `capacity` and the
87 /// specified `maxSize`. The behavior is undefined unless
88 /// `capacity < newLength` and `newLength <= maxSize`. Note that the
89 /// returned value is always at most `maxSize`.
90 static std::size_t computeNewCapacity(std::size_t newLength,
91 std::size_t capacity,
92 std::size_t maxSize);
93
94 /// Exchange the value of the specified `a` vector with that of the
95 /// specified `b` vector.
96 static void swap(void *a, void *b);
97};
98
99
100 // ===================================
101 // class Vector_DeduceIteratorCategory
102 // ===================================
103
104/// This `struct` provides a primitive means to distinguish between iterator
105/// types and fundamental types, in order to dispatch to the correct
106/// implementation of a function template (or constructor template) passed
107/// two arguments of identical type. By default, it is assumed that any
108/// type that is not a fundamental type, as determined by the type trait
109/// `bsl::is_fundamental`, must be an iterator type. `std::iterator_traits`
110/// is updated in C++17 to provide a SFINAE-friendly instantiation of the
111/// primary-template for types that do not provide all of the nested typedef
112/// names, but we cannot portably rely on such a scheme yet.
113template <class BSLSTL_ITERATOR,
114 bool BSLSTL_NOTSPECIALIZED = is_fundamental<BSLSTL_ITERATOR>::value>
115struct Vector_DeduceIteratorCategory {
116
117 // PUBLIC TYPES
118 typedef typename bsl::iterator_traits<BSLSTL_ITERATOR>::iterator_category
119 type;
120};
121
122/// This partial specialization of the `struct` template for fundamental
123/// types provides a nested `type` that is not an iterator category, so can
124/// be used to control the internal dispatch of function template overloads
125/// taking two arguments of the same type.
126template <class BSLSTL_ITERATOR>
127struct Vector_DeduceIteratorCategory<BSLSTL_ITERATOR, true> {
128
129 // PUBLIC TYPES
130 typedef BloombergLP::bslmf::Nil type;
131};
132
133
134 // ======================================
135 // class vector_UintPtrConversionIterator
136 // ======================================
137
138/// This metafunction provides an appropriate iterator adaptor for the
139/// specified (template parameter) type `ITERATOR` in order to implement
140/// members of the `vector` partial template specialization for vectors of
141/// pointers to the (template parameter) type `TARGET`. The metafunction
142/// will return the original `ITERATOR` type unless it truly is an iterator,
143/// using `is_integral` as a proxy for testing that a type is NOT an
144/// iterator. This is needed to disambiguate only the cases of users
145/// passing `0` as a null-pointer value to functions requesting a number of
146/// identical copies of an element.
147template <class TARGET, class ITERATOR, bool = is_integral<ITERATOR>::value>
148struct vector_ForwardIteratorForPtrs {
149
150 // PUBLIC TYPES
151 typedef ITERATOR type;
152};
153
154/// This metafunction specialization provides an appropriate iterator
155/// adaptor for the specified (template parameter) type `ITERATOR` in order
156/// to implement members of the `vector` partial template specialization for
157/// vectors of pointers to the (template parameter) type `TARGET`.
158template <class TARGET, class ITERATOR>
159struct vector_ForwardIteratorForPtrs<TARGET, ITERATOR, false> {
160
161 // PUBLIC TYPES
162 typedef vector_UintPtrConversionIterator<TARGET *, ITERATOR> type;
163};
164
165#if defined(BSLS_ASSERT_SAFE_IS_USED)
166
167template <class BSLSTL_ITERATOR>
168struct Vector_IsRandomAccessIterator :
169 bsl::is_same<typename Vector_DeduceIteratorCategory<BSLSTL_ITERATOR>::type,
170 bsl::random_access_iterator_tag>::type
171{
172};
173
174
175 // =======================
176 // class Vector_RangeCheck
177 // =======================
178
179struct Vector_RangeCheck {
180 // This utility class provides a test-support facility to diagnose when a
181 // pair of iterators do *not* form a valid range. This support is offered
182 // only for random access iterators, and identifies only the case of two
183 // valid iterators into the same range forming a "reverse" range. Note
184 // that the two functions declared using 'enable_if' must be defined inline
185 // in the class definition due to a bug in the Microsoft C++ compiler (see
186 // @ref bslmf_enableif ).
187
188 // CLASS METHODS
189 template <class BSLSTL_ITERATOR>
190 static
191 typename bsl::enable_if<
192 !Vector_IsRandomAccessIterator<BSLSTL_ITERATOR>::value, bool>::type
193 isInvalidRange(BSLSTL_ITERATOR, BSLSTL_ITERATOR);
194 // Return 'false'. Note that we know of no way to identify an input
195 // iterator range that is guaranteed to be invalid.
196
197 template <class BSLSTL_ITERATOR>
198 static
199 typename bsl::enable_if<
200 Vector_IsRandomAccessIterator<BSLSTL_ITERATOR>::value, bool>::type
201 isInvalidRange(BSLSTL_ITERATOR first, BSLSTL_ITERATOR last);
202 // Return 'true' if 'last < first', and 'false' otherwise. The
203 // behavior is undefined unless both 'first' and 'last' are valid
204 // iterators that refer to the same range.
205};
206
207#endif
208
209 // ================
210 // class vectorBase
211 // ================
212
213/// This class describes the basic layout for a vector class, to be included
214/// into the `vector` layout *before* the allocator (provided by
215/// `bslalg::ContainerBase`) to take better advantage of cache prefetching.
216/// It is parameterized by `VALUE_TYPE` only, and implements the portion of
217/// `vector` that does not need to know about its (template parameter) type
218/// `ALLOCATOR` (in order to generate shorter debug strings). This class
219/// intentionally has *no* creators (other than the compiler-generated
220/// ones).
221///
222/// See @ref bslstl_vector_cpp03
223template <class VALUE_TYPE>
224class vectorBase {
225
226 // PRIVATE TYPES
227
228 /// This `typedef` is a convenient alias for the utility associated with
229 /// movable references.
230 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
231
232 protected:
233 // PROTECTED DATA
234 VALUE_TYPE *d_dataBegin_p; // beginning of data storage (owned)
235 VALUE_TYPE *d_dataEnd_p; // one past the end of data storage
236 std::size_t d_capacity; // capacity of data storage in # of elements
237
238 public:
239 // PUBLIC TYPES
240 typedef VALUE_TYPE value_type;
241 typedef VALUE_TYPE& reference;
242 typedef VALUE_TYPE const& const_reference;
243 typedef VALUE_TYPE *iterator;
244 typedef VALUE_TYPE const *const_iterator;
245 typedef std::size_t size_type;
246 typedef std::ptrdiff_t difference_type;
247 typedef bsl::reverse_iterator<iterator> reverse_iterator;
248 typedef bsl::reverse_iterator<const_iterator> const_reverse_iterator;
249
250 public:
251 // CREATORS
252
253 /// Create an empty base object with no capacity.
254 vectorBase();
255
256 // MANIPULATORS
257
258 /// Adopt all outstanding memory allocations associated with the
259 /// specified `base` object. The behavior is undefined unless this
260 /// object is in a default-constructed state.
261 void adopt(BloombergLP::bslmf::MovableRef<vectorBase> base);
262
263 // *** iterators ***
264
265 /// Return an iterator providing modifiable access to the first element
266 /// in this vector, or the past-the-end iterator if this vector is
267 /// empty.
269
270 /// Return the past-the-end iterator providing modifiable access to this
271 /// vector.
273
274 /// Return a reverse iterator providing modifiable access to the last
275 /// element in this vector, and the past-the-end reverse iterator if
276 /// this vector is empty.
278
279 /// Return the past-the-end reverse iterator providing modifiable access
280 /// to this vector.
282
283 // *** element access ***
284
285 /// Return a reference providing modifiable access to the element at the
286 /// specified `position` in this vector. The behavior is undefined
287 /// unless `position < size()`.
288 reference operator[](size_type position);
289
290 /// Return a reference providing modifiable access to the element at the
291 /// specified `position` in this vector. Throw a `std::out_of_range`
292 /// exception if `position >= size()`.
293 reference at(size_type position);
294
295 /// Return a reference providing modifiable access to the first element
296 /// in this vector. The behavior is undefined unless this vector is not
297 /// empty.
299
300 /// Return a reference providing modifiable access to the last element
301 /// in this vector. The behavior is undefined unless this vector is not
302 /// empty.
303 reference back();
304
305 /// Return the address of the modifiable first element in this vector,
306 /// or a valid, but non-dereferenceable pointer value if this vector is
307 /// empty.
308 VALUE_TYPE *data() BSLS_KEYWORD_NOEXCEPT;
309
310 // ACCESSORS
311
312 // *** iterators ***
313
315
316 /// Return an iterator providing non-modifiable access to the first
317 /// element in this vector, and the past-the-end iterator if this vector
318 /// is empty.
320
322
323 /// Return the past-the-end (forward) iterator providing non-modifiable
324 /// access to this vector.
326
328
329 /// Return a reverse iterator providing non-modifiable access to the
330 /// last element in this vector, and the past-the-end reverse iterator
331 /// if this vector is empty.
333
335
336 /// Return the past-the-end reverse iterator providing non-modifiable
337 /// access to this vector.
339
340 // *** capacity ***
341
342 /// Return the number of elements in this vector.
344
345 /// Return the capacity of this vector, i.e., the maximum number of
346 /// elements for which resizing is guaranteed not to trigger a
347 /// reallocation.
349
350 /// Return `true` if this vector has size 0, and `false` otherwise.
351 bool empty() const BSLS_KEYWORD_NOEXCEPT;
352
353 // *** element access ***
354
355 /// Return a reference providing non-modifiable access to the element at
356 /// the specified `position` in this vector. The behavior is undefined
357 /// unless `position < size()`.
358 const_reference operator[](size_type position) const;
359
360 /// Return a reference providing non-modifiable access to the element at
361 /// the specified `position` in this vector. Throw a
362 /// `bsl::out_of_range` exception if `position >= size()`.
363 const_reference at(size_type position) const;
364
365 /// Return a reference providing non-modifiable access to the first
366 /// element in this vector. The behavior is undefined unless this
367 /// vector is not empty.
368 const_reference front() const;
369
370 /// Return a reference providing non-modifiable access to the last
371 /// element in this vector. The behavior is undefined unless this
372 /// vector is not empty.
373 const_reference back() const;
374
375 /// Return the address of the non-modifiable first element in this
376 /// vector, or a valid, but non-dereferenceable pointer value if this
377 /// vector is empty.
378 const VALUE_TYPE *data() const BSLS_KEYWORD_NOEXCEPT;
379};
380
381 // ============
382 // class vector
383 // ============
384
385/// This class template provides an STL-compliant `vector` that conforms to
386/// the `bslma::Allocator` model. For the requirements of a vector class,
387/// consult the C++11 standard. In particular, this implementation offers
388/// the general rules that:
389///
390/// 1. A call to any method that would result in a vector having a size
391/// or capacity greater than the value returned by @ref max_size triggers a
392/// call to `bslstl::StdExceptUtil::throwLengthError`.
393/// 2. A call to an `at` method that attempts to access a position outside
394/// of the valid range of a vector triggers a call to
395/// `bslstl::StdExceptUtil::throwOutOfRange`.
396///
397/// Note that portions of the standard methods are implemented in
398/// `vectorBase`, which is parameterized on only `VALUE_TYPE` in order to
399/// generate smaller debug strings.
400///
401/// This class:
402/// * supports a complete set of *value-semantic* operations
403/// - except for `BDEX` serialization
404/// * is *exception-neutral*
405/// * is *alias-safe*
406/// * is `const` *thread-safe*
407/// For terminology see @ref bsldoc_glossary .
408///
409/// In addition, the following members offer a full guarantee of rollback:
410/// if an exception is thrown during the invocation of `push_back` or
411/// `insert` with a single element at the end of a pre-existing object, the
412/// object is left in a valid state and its value is unchanged.
413template <class VALUE_TYPE, class ALLOCATOR = allocator<VALUE_TYPE> >
414class vector : public vectorBase<VALUE_TYPE>
415 , private BloombergLP::bslalg::ContainerBase<ALLOCATOR> {
416
417 // PRIVATE TYPES
418
419 /// This `typedef` is an alias for a utility class that provides many
420 /// useful functions that operate on arrays.
421 typedef BloombergLP::bslalg::ArrayPrimitives ArrayPrimitives;
422
423 /// This `typedef` is a convenient alias for the utility associated with
424 /// movable references.
425 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
426
427 /// This `typedef` is an alias for a utility class that provides many
428 /// useful functions that operate on allocators.
429 typedef BloombergLP::bslma::AllocatorUtil AllocatorUtil;
430
431 /// This `typedef` is an alias for the allocator traits type associated
432 /// with this container.
433 typedef allocator_traits<ALLOCATOR> AllocatorTraits;
434
435 public:
436 // PUBLIC TYPES
437 typedef VALUE_TYPE value_type;
438 typedef ALLOCATOR allocator_type;
439 typedef VALUE_TYPE& reference;
440 typedef const VALUE_TYPE& const_reference;
441
442 typedef typename AllocatorTraits::size_type size_type;
443 typedef typename AllocatorTraits::difference_type difference_type;
444 typedef typename AllocatorTraits::pointer pointer;
445 typedef typename AllocatorTraits::const_pointer const_pointer;
446
447 typedef VALUE_TYPE *iterator;
448 typedef VALUE_TYPE const *const_iterator;
449 typedef bsl::reverse_iterator<iterator> reverse_iterator;
450 typedef bsl::reverse_iterator<const_iterator> const_reverse_iterator;
451
452 private:
453 // PRIVATE TYPES
454
455 /// Implementation base type, with iterator-related functionality.
456 typedef vectorBase<VALUE_TYPE> ImpBase;
457
458 /// Container base type, containing the allocator and applying the empty
459 /// base class optimization (EBO) whenever appropriate.
460 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
461
462 /// This class provides a proctor for deallocating an array of
463 /// `VALUE_TYPE` objects, to be used in the `vector` constructors.
464 ///
465 /// See @ref bslstl_vector_cpp03
466 class Proctor {
467
468 // DATA
469 VALUE_TYPE *d_data_p; // array pointer
470 std::size_t d_capacity; // capacity of the array
471 ContainerBase *d_container_p; // container base pointer
472
473 private:
474 // NOT IMPLEMENTED
475 Proctor(const Proctor&);
476 Proctor& operator=(const Proctor&);
477
478 public:
479 // CREATORS
480
481 /// Create a proctor for the specified `data` array of the specified
482 /// `capacity`, using the `deallocateN` method of the specified
483 /// `container` to return `data` to its allocator upon destruction,
484 /// unless this proctor's `release` is called prior.
485 Proctor(VALUE_TYPE *data,
486 std::size_t capacity,
487 ContainerBase *container);
488
489 /// Destroy this proctor, deallocating any data under management.
490 ~Proctor();
491
492 // MANIPULATORS
493
494 /// Release the data from management by this proctor.
495 void release();
496 };
497
498 // PRIVATE MANIPULATORS
499
500 /// Populate a default-constructed vector with the values held in the
501 /// specified range `[first, last)`. The additional
502 /// `std::*iterator__tag` should be a default-constructed tag that
503 /// corresponds to that found in `std::iterator_traits` for the
504 /// (template parameter) `*_ITER` type. This method should be called
505 /// only from a constructor. The behavior is undefined unless
506 /// `first != last`.
507 template <class FWD_ITER>
508 void constructFromRange(FWD_ITER first,
509 FWD_ITER last,
510 std::forward_iterator_tag);
511 template <class INPUT_ITER>
512 void constructFromRange(INPUT_ITER first,
513 INPUT_ITER last,
514 std::input_iterator_tag);
515
516 /// Populate a default-constructed vector with the specified
517 /// `initialSize` elements, where each such element is a copy of the
518 /// specified `value`. The `bslmf::Nil` traits value distinguished this
519 /// overload of two identical (presumed integral) types from the pair of
520 /// iterator overloads above. This method should be called only from a
521 /// constructor.
522 template <class INTEGRAL>
523 void constructFromRange(INTEGRAL initialSize,
524 INTEGRAL value,
525 BloombergLP::bslmf::Nil);
526
527
528 /// Match integral type for `INPUT_ITER`.
529 template <class INPUT_ITER>
530 void privateInsertDispatch(
531 const_iterator position,
532 INPUT_ITER count,
533 INPUT_ITER value,
534 BloombergLP::bslmf::MatchArithmeticType ,
535 BloombergLP::bslmf::Nil );
536
537 /// Match non-integral type for `INPUT_ITER`.
538 template <class INPUT_ITER>
539 void privateInsertDispatch(const_iterator position,
540 INPUT_ITER first,
541 INPUT_ITER last,
542 BloombergLP::bslmf::MatchAnyType ,
543 BloombergLP::bslmf::MatchAnyType );
544
545 /// Specialized insertion for input iterators.
546 template <class INPUT_ITER>
547 void privateInsert(const_iterator position,
548 INPUT_ITER first,
549 INPUT_ITER last,
550 const std::input_iterator_tag&);
551
552 /// Specialized insertion for forward, bidirectional, and random-access
553 /// iterators.
554 template <class FWD_ITER>
555 void privateInsert(const_iterator position,
556 FWD_ITER first,
557 FWD_ITER last,
558 const std::forward_iterator_tag&);
559
560 /// Destructive move insertion from a temporary vector, to avoid
561 /// duplicate copies after importing from an input iterator into a
562 /// temporary vector.
563 void privateMoveInsert(vector *fromVector,
564 const_iterator position);
565
566 /// Reserve exactly the specified `numElements`. The behavior is
567 /// undefined unless this vector is empty and has no capacity.
568 void privateReserveEmpty(size_type numElements);
569
570#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
571// {{{ BEGIN GENERATED CODE
572// Command line: sim_cpp11_features.pl bslstl_vector.h
573#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT
574#define BSLSTL_VECTOR_VARIADIC_LIMIT 10
575#endif
576#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT_A
577#define BSLSTL_VECTOR_VARIADIC_LIMIT_A BSLSTL_VECTOR_VARIADIC_LIMIT
578#endif
579#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 0
580 void privateEmplaceBackWithAllocation(
581 );
582#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 0
583
584#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 1
585 template <class Args_01>
586 void privateEmplaceBackWithAllocation(
587 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
588#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 1
589
590#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 2
591 template <class Args_01,
592 class Args_02>
593 void privateEmplaceBackWithAllocation(
594 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
595 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
596#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 2
597
598#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 3
599 template <class Args_01,
600 class Args_02,
601 class Args_03>
602 void privateEmplaceBackWithAllocation(
603 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
604 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
605 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
606#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 3
607
608#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 4
609 template <class Args_01,
610 class Args_02,
611 class Args_03,
612 class Args_04>
613 void privateEmplaceBackWithAllocation(
614 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
615 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
616 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
617 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
618#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 4
619
620#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 5
621 template <class Args_01,
622 class Args_02,
623 class Args_03,
624 class Args_04,
625 class Args_05>
626 void privateEmplaceBackWithAllocation(
627 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
628 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
629 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
630 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
631 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
632#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 5
633
634#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 6
635 template <class Args_01,
636 class Args_02,
637 class Args_03,
638 class Args_04,
639 class Args_05,
640 class Args_06>
641 void privateEmplaceBackWithAllocation(
642 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
643 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
644 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
645 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
646 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
647 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
648#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 6
649
650#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 7
651 template <class Args_01,
652 class Args_02,
653 class Args_03,
654 class Args_04,
655 class Args_05,
656 class Args_06,
657 class Args_07>
658 void privateEmplaceBackWithAllocation(
659 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
660 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
661 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
662 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
663 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
664 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
665 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
666#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 7
667
668#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 8
669 template <class Args_01,
670 class Args_02,
671 class Args_03,
672 class Args_04,
673 class Args_05,
674 class Args_06,
675 class Args_07,
676 class Args_08>
677 void privateEmplaceBackWithAllocation(
678 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
679 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
680 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
681 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
682 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
683 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
684 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
685 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
686#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 8
687
688#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 9
689 template <class Args_01,
690 class Args_02,
691 class Args_03,
692 class Args_04,
693 class Args_05,
694 class Args_06,
695 class Args_07,
696 class Args_08,
697 class Args_09>
698 void privateEmplaceBackWithAllocation(
699 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
700 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
701 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
702 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
703 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
704 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
705 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
706 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
707 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
708#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 9
709
710#if BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 10
711 template <class Args_01,
712 class Args_02,
713 class Args_03,
714 class Args_04,
715 class Args_05,
716 class Args_06,
717 class Args_07,
718 class Args_08,
719 class Args_09,
720 class Args_10>
721 void privateEmplaceBackWithAllocation(
722 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
723 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
724 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
725 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
726 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
727 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
728 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
729 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
730 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
731 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
732#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_A >= 10
733
734#else
735// The generated code below is a workaround for the absence of perfect
736// forwarding in some compilers.
737 template <class... Args>
738 void privateEmplaceBackWithAllocation(
739 BSLS_COMPILERFEATURES_FORWARD_REF(Args)...arguments);
740// }}} END GENERATED CODE
741#endif
742
743 /// Append a copy of the specified `value` to the end of this vector
744 /// after changing its capacity. If an exception is thrown, `*this` is
745 /// unaffected. Throw `std::length_error` if `size() == max_size()`.
746 void privatePushBackWithAllocation(const VALUE_TYPE& value);
747
748 /// Append the specified move-insertable `value` to the end of this
749 /// vector after changing its capacity. `value` is left in a valid but
750 /// unspecified state. If an exception is thrown (other than by the
751 /// move constructor of a non-copy-insertable `value_type`), `*this` is
752 /// unaffected. Throw `std::length_error` if `size() == max_size()`.
753 void privatePushBackWithAllocation(
754 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value);
755
756 public:
757 // CREATORS
758
759 // *** construct/copy/destroy ***
760
761 vector() BSLS_KEYWORD_NOEXCEPT;
762
763 /// Create an empty vector. Optionally specify a `basicAllocator` used
764 /// to supply memory. If `basicAllocator` is not specified, a
765 /// default-constructed object of the (template parameter) type
766 /// `ALLOCATOR` is used. If the type `ALLOCATOR` is `bsl::allocator`
767 /// and `basicAllocator` is not supplied, the currently installed
768 /// default allocator is used. Note that a `bslma::Allocator *` can be
769 /// supplied for `basicAllocator` if the type `ALLOCATOR` is
770 /// `bsl::allocator` (the default).
771 explicit vector(const ALLOCATOR& basicAllocator) BSLS_KEYWORD_NOEXCEPT;
772
773 /// Create a vector of the specified `initialSize` whose every element
774 /// is a default-constructed object of the (template parameter) type
775 /// `VALUE_TYPE`. Optionally specify a `basicAllocator` used to supply
776 /// memory. If `basicAllocator` is not specified, a default-constructed
777 /// object of the (template parameter) type `ALLOCATOR` is used. If the
778 /// type `ALLOCATOR` is `bsl::allocator` and `basicAllocator` is not
779 /// supplied, the currently installed default allocator is used. Throw
780 /// `std::length_error` if `initialSize > max_size()`. This method
781 /// requires that the type `VALUE_TYPE` be `default-insertable` into
782 /// this vector (see {Requirements on `VALUE_TYPE`}). Note that a
783 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
784 /// type `ALLOCATOR` is `bsl::allocator` (the default).
785 explicit vector(size_type initialSize,
786 const ALLOCATOR& basicAllocator = ALLOCATOR());
787
788 /// Create a vector of the specified `initialSize` whose every element
789 /// is a copy of the specified `value`. Optionally specify a
790 /// `basicAllocator` used to supply memory. If `basicAllocator` is not
791 /// specified, a default-constructed object of the (template parameter)
792 /// type `ALLOCATOR` is used. If the type `ALLOCATOR` is
793 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
794 /// installed default allocator is used. Throw `std::length_error` if
795 /// `initialSize > max_size()`. This method requires that the (template
796 /// parameter) type `VALUE_TYPE` be `copy-insertable` into this vector
797 /// (see {Requirements on `VALUE_TYPE`}). Note that a
798 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
799 /// type `ALLOCATOR` is `bsl::allocator` (the default).
800 vector(size_type initialSize,
801 const VALUE_TYPE& value,
802 const ALLOCATOR& basicAllocator = ALLOCATOR());
803
804 /// Create a vector, and insert (in order) each `VALUE_TYPE` object in
805 /// the range starting at the specified `first` element, and ending
806 /// immediately before the specified `last` element. Optionally specify
807 /// a `basicAllocator` used to supply memory. If `basicAllocator` is
808 /// not specified, a default-constructed object of the (template
809 /// parameter) type `ALLOCATOR` is used. If the type `ALLOCATOR` is
810 /// `bsl::allocator` and `basicAllocator` is not supplied, the currently
811 /// installed default allocator is used. Throw `std::length_error` if
812 /// the number of elements in `[first .. last)` exceeds the value
813 /// returned by the method @ref max_size . The (template parameter) type
814 /// `INPUT_ITER` shall meet the requirements of an input iterator
815 /// defined in the C++11 standard [24.2.3] providing access to values of
816 /// a type convertible to `value_type`, and `value_type` must be
817 /// `emplace-constructible` from `*i` into this vector, where `i` is a
818 /// dereferenceable iterator in the range `[first .. last)` (see
819 /// {Requirements on `VALUE_TYPE`}). The behavior is undefined unless
820 /// `first` and `last` refer to a range of valid values where `first`
821 /// is at a position at or before `last`. Note that a
822 /// `bslma::Allocator *` can be supplied for `basicAllocator` if the
823 /// type `ALLOCATOR` is `bsl::allocator` (the default).
824 template <class INPUT_ITER>
825 vector(INPUT_ITER first,
826 INPUT_ITER last,
827 const ALLOCATOR& basicAllocator = ALLOCATOR());
828
829 /// Create a vector having the same value as the specified `original`
830 /// object. Use the allocator returned by
831 /// 'bsl::allocator_traits<ALLOCATOR>::
832 /// select_on_container_copy_construction(original.get_allocator())' to
833 /// allocate memory. This method requires that the (template parameter)
834 /// type `VALUE_TYPE` be `copy-insertable` into this vector (see
835 /// {Requirements on `VALUE_TYPE`}).
836 vector(const vector& original);
837
838 /// Create a vector having the same value as the specified `original`
839 /// object by moving (in constant time) the contents of `original` to
840 /// the new vector. The allocator associated with `original` is
841 /// propagated for use in the newly-created vector. `original` is left
842 /// in a valid but unspecified state.
843 vector(BloombergLP::bslmf::MovableRef<vector> original)
844 BSLS_KEYWORD_NOEXCEPT; // IMPLICIT
845
846 /// Create a vector having the same value as the specified `original`
847 /// object that uses the specified `basicAllocator` to supply memory.
848 /// This method requires that the (template parameter) type `VALUE_TYPE`
849 /// be `copy-insertable` into this vector (see {Requirements on
850 /// `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied
851 /// for `basicAllocator` if the (template parameter) type `ALLOCATOR` is
852 /// `bsl::allocator` (the default).
853 vector(const vector& original,
854 const typename type_identity<ALLOCATOR>::type& basicAllocator);
855
856 /// Create a vector having the same value as the specified `original`
857 /// object that uses the specified `basicAllocator` to supply memory.
858 /// The contents of `original` are moved (in constant time) to the new
859 /// vector if `basicAllocator == original.get_allocator()`, and are
860 /// move-inserted (in linear time) using `basicAllocator` otherwise.
861 /// `original` is left in a valid but unspecified state. This method
862 /// requires that the (template parameter) type `VALUE_TYPE` be
863 /// `move-insertable` into this vector (see {Requirements on
864 /// `VALUE_TYPE`}). Note that a `bslma::Allocator *` can be supplied
865 /// for `basicAllocator` if the (template parameter) type `ALLOCATOR` is
866 /// `bsl::allocator` (the default).
867 vector(BloombergLP::bslmf::MovableRef<vector> original,
868 const typename type_identity<ALLOCATOR>::type& basicAllocator);
869
870#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
871 vector(std::initializer_list<VALUE_TYPE> values,
872 const ALLOCATOR& basicAllocator = ALLOCATOR());
873 // IMPLICIT
874 // Create a vector and insert (in order) each 'VALUE_TYPE' object in
875 // the specified 'values' initializer list. Optionally specify a
876 // 'basicAllocator' used to supply memory. If 'basicAllocator' is not
877 // specified, a default-constructed object of the (template parameter)
878 // type 'ALLOCATOR' is used. If the type 'ALLOCATOR' is
879 // 'bsl::allocator' and 'basicAllocator' is not supplied, the currently
880 // installed default allocator is used. This method requires that the
881 // (template parameter) type 'VALUE_TYPE' be 'copy-insertable' into
882 // this vector (see {Requirements on 'VALUE_TYPE'}). Note that a
883 // 'bslma::Allocator *' can be supplied for 'basicAllocator' if the
884 // type 'ALLOCATOR' is 'bsl::allocator' (the default).
885#endif
886
887 /// Destroy this vector.
888 ~vector();
889
890 // MANIPULATORS
891
892 /// Assign to this object the value of the specified `rhs` object,
893 /// propagate to this object the allocator of `rhs` if the `ALLOCATOR`
894 /// type has trait `propagate_on_container_copy_assignment`, and return
895 /// a reference providing modifiable access to this object. If an
896 /// exception is thrown, `*this` is left in a valid but unspecified
897 /// state. This method requires that the (template parameter) type
898 /// `VALUE_TYPE` be `copy-assignable` and `copy-insertable` into this
899 /// vector (see {Requirements on `VALUE_TYPE`}).
900 vector& operator=(const vector& rhs);
901
902 vector& operator=(
903 BloombergLP::bslmf::MovableRef<vector<VALUE_TYPE, ALLOCATOR> > rhs)
905 AllocatorTraits::propagate_on_container_move_assignment::value ||
906 AllocatorTraits::is_always_equal::value);
907 // Assign to this object the value of the specified 'rhs' object,
908 // propagate to this object the allocator of 'rhs' if the 'ALLOCATOR'
909 // type has trait 'propagate_on_container_move_assignment', and return
910 // a reference providing modifiable access to this object. The
911 // contents of 'rhs' are moved (in constant time) to this vector if
912 // 'get_allocator() == rhs.get_allocator()' (after accounting for the
913 // aforementioned trait); otherwise, all elements in this vector are
914 // either destroyed or move-assigned to and each additional element in
915 // 'rhs' is move-inserted into this vector. 'rhs' is left in a valid
916 // but unspecified state, and if an exception is thrown, '*this' is
917 // left in a valid but unspecified state. This method requires that
918 // the (template parameter) type 'VALUE_TYPE' be 'move-assignable' and
919 // 'move-insertable' into this vector (see {Requirements on
920 // 'VALUE_TYPE'}). Note that the 'vector' template arguments must be
921 // explicitly spelled out to work around an MSVC 2022 bug, see DRQS
922 // 171087946.
923
924#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
925 /// Assign to this object the value resulting from first clearing this
926 /// vector and then inserting (in order) each `VALUE_TYPE` object in the
927 /// specified `values` initializer list, and return a reference
928 /// providing modifiable access to this object. If an exception is
929 /// thrown, `*this` is left in a valid but unspecified state. This
930 /// method requires that the (template parameter) type `VALUE_TYPE` be
931 /// `copy-insertable` into this vector (see {Requirements on
932 /// `VALUE_TYPE`}).
933 vector& operator=(std::initializer_list<VALUE_TYPE> values);
934
935 /// Assign to this object the value resulting from first clearing this
936 /// vector and then inserting (in order) each `VALUE_TYPE` object in the
937 /// specified `values` initializer list. If an exception is thrown,
938 /// `*this` is left in a valid but unspecified state. This method
939 /// requires that the (template parameter) type `VALUE_TYPE` be
940 /// `copy-insertable` into this vector (see {Requirements on
941 /// `VALUE_TYPE`}).
942 void assign(std::initializer_list<VALUE_TYPE> values);
943#endif
944
945 /// Assign to this object the value resulting from first clearing this
946 /// vector and then inserting (in order) each `value_type` object in the
947 /// range starting at the specified `first` element, and ending
948 /// immediately before the specified `last` element. If an exception is
949 /// thrown, `*this` is left in a valid but unspecified state. Throw
950 /// `std::length_error` if `distance(first,last) > max_size()`. The
951 /// (template parameter) type `INPUT_ITER` shall meet the requirements
952 /// of an input iterator defined in the C++11 standard [24.2.3]
953 /// providing access to values of a type convertible to `value_type`,
954 /// and `value_type` must be `emplace-constructible` from `*i` into this
955 /// vector, where `i` is a dereferenceable iterator in the range
956 /// `[first .. last)` (see {Requirements on `VALUE_TYPE`}). The
957 /// behavior is undefined unless `first` and `last` refer to a range of
958 /// valid values where `first` is at a position at or before `last`.
959 template <class INPUT_ITER>
960 void assign(INPUT_ITER first, INPUT_ITER last);
961
962 /// Assign to this object the value resulting from first clearing this
963 /// vector and then inserting the specified `numElements` copies of the
964 /// specified `value`. If an exception is thrown, `*this` is left in a
965 /// valid but unspecified state. Throw `std::length_error` if
966 /// `numElements > max_size()`. This method requires that the (template
967 /// parameter) type `VALUE_TYPE` be `copy-insertable` into this vector
968 /// (see {Requirements on `VALUE_TYPE`}).
969 void assign(size_type numElements, const VALUE_TYPE& value);
970
971
972 // *** capacity ***
973
974 /// Change the size of this vector to the specified `newSize`. If
975 /// `newSize < size()`, the elements in the range `[newSize .. size())`
976 /// are erased, and this function does not throw. If
977 /// `newSize > size()`, the (newly created) elements in the range
978 /// `[size() .. newSize)` are default-constructed `value_type` objects,
979 /// and if an exception is thrown (other than by the move constructor of
980 /// a non-copy-insertable `value_type`), `*this` is unaffected. Throw
981 /// `std::length_error` if `newSize > max_size()`. This method requires
982 /// that the (template parameter) type `VALUE_TYPE` be
983 /// `default-insertable` and `move-insertable` into this vector (see
984 /// {Requirements on `VALUE_TYPE`}).
985 void resize(size_type newSize);
986
987 /// Change the size of this vector to the specified `newSize`, inserting
988 /// `newSize - size()` copies of the specified `value` at the end of
989 /// this vector if `newSize > size()`. If `newSize < size()`, the
990 /// elements in the range `[newSize .. size())` are erased, `value` is
991 /// ignored, and this method does not throw. If `newSize > size()` and
992 /// an exception is thrown, `*this` is unaffected. Throw
993 /// `std::length_error` if `newSize > max_size()`. This method requires
994 /// that the (template parameter) type `VALUE_TYPE` be `copy-insertable`
995 /// into this vector (see {Requirements on `VALUE_TYPE`}).
996 void resize(size_type newSize, const VALUE_TYPE& value);
997
998 /// Change the capacity of this vector to the specified `newCapacity`.
999 /// If an exception is thrown (other than by the move constructor of a
1000 /// non-copy-insertable `value_type`), `*this` is unaffected. Throw
1001 /// `bsl::length_error` if `newCapacity > max_size()`. This method
1002 /// requires that the (template parameter) type `VALUE_TYPE` be
1003 /// `move-insertable` into this vector (see {Requirements on
1004 /// `VALUE_TYPE`}). Note that the capacity of this vector after this
1005 /// operation has completed may be greater than `newCapacity`.
1006 void reserve(size_type newCapacity);
1007
1008 /// Reduce the capacity of this vector to its size. If an exception is
1009 /// thrown (other than by the move constructor of a non-copy-insertable
1010 /// `value_type`), `*this` is unaffected. Note that this method has no
1011 /// effect if the capacity is equivalent to the size.
1012 void shrink_to_fit();
1013
1014 // *** modifiers ***
1015
1016#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1017// {{{ BEGIN GENERATED CODE
1018// Command line: sim_cpp11_features.pl bslstl_vector.h
1019#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT
1020#define BSLSTL_VECTOR_VARIADIC_LIMIT 10
1021#endif
1022#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT_B
1023#define BSLSTL_VECTOR_VARIADIC_LIMIT_B BSLSTL_VECTOR_VARIADIC_LIMIT
1024#endif
1025#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 0
1026 VALUE_TYPE &emplace_back(
1027 );
1028#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 0
1029
1030#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 1
1031 template <class Args_01>
1032 VALUE_TYPE &emplace_back(
1033 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
1034#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 1
1035
1036#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 2
1037 template <class Args_01,
1038 class Args_02>
1039 VALUE_TYPE &emplace_back(
1040 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1041 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
1042#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 2
1043
1044#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 3
1045 template <class Args_01,
1046 class Args_02,
1047 class Args_03>
1048 VALUE_TYPE &emplace_back(
1049 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1050 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1051 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
1052#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 3
1053
1054#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 4
1055 template <class Args_01,
1056 class Args_02,
1057 class Args_03,
1058 class Args_04>
1059 VALUE_TYPE &emplace_back(
1060 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1061 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1062 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1063 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
1064#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 4
1065
1066#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 5
1067 template <class Args_01,
1068 class Args_02,
1069 class Args_03,
1070 class Args_04,
1071 class Args_05>
1072 VALUE_TYPE &emplace_back(
1073 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1074 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1075 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1076 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1077 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
1078#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 5
1079
1080#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 6
1081 template <class Args_01,
1082 class Args_02,
1083 class Args_03,
1084 class Args_04,
1085 class Args_05,
1086 class Args_06>
1087 VALUE_TYPE &emplace_back(
1088 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1089 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1090 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1091 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1092 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1093 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
1094#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 6
1095
1096#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 7
1097 template <class Args_01,
1098 class Args_02,
1099 class Args_03,
1100 class Args_04,
1101 class Args_05,
1102 class Args_06,
1103 class Args_07>
1104 VALUE_TYPE &emplace_back(
1105 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1106 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1107 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1108 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1109 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1110 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1111 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
1112#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 7
1113
1114#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 8
1115 template <class Args_01,
1116 class Args_02,
1117 class Args_03,
1118 class Args_04,
1119 class Args_05,
1120 class Args_06,
1121 class Args_07,
1122 class Args_08>
1123 VALUE_TYPE &emplace_back(
1124 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1125 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1126 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1127 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1128 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1129 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1130 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1131 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
1132#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 8
1133
1134#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 9
1135 template <class Args_01,
1136 class Args_02,
1137 class Args_03,
1138 class Args_04,
1139 class Args_05,
1140 class Args_06,
1141 class Args_07,
1142 class Args_08,
1143 class Args_09>
1144 VALUE_TYPE &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 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1151 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1152 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1153 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
1154#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 9
1155
1156#if BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 10
1157 template <class Args_01,
1158 class Args_02,
1159 class Args_03,
1160 class Args_04,
1161 class Args_05,
1162 class Args_06,
1163 class Args_07,
1164 class Args_08,
1165 class Args_09,
1166 class Args_10>
1167 VALUE_TYPE &emplace_back(
1168 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1169 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1170 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1171 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1172 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1173 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1174 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1175 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1176 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1177 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
1178#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_B >= 10
1179
1180#else
1181// The generated code below is a workaround for the absence of perfect
1182// forwarding in some compilers.
1183 template <class... Args>
1184 VALUE_TYPE &emplace_back(
1185 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
1186// }}} END GENERATED CODE
1187#endif
1188
1189 /// Append to the end of this vector a copy of the specified `value`.
1190 /// If an exception is thrown, `*this` is unaffected. Throw
1191 /// `std::length_error` if `size() == max_size()`. This method
1192 /// requires that the (template parameter) type `VALUE_TYPE` be
1193 /// `copy-constructible` (see {Requirements on `VALUE_TYPE`}).
1194 void push_back(const VALUE_TYPE& value);
1195
1196 /// Append to the end of this vector the specified move-insertable
1197 /// `value`. `value` is left in a valid but unspecified state. If an
1198 /// exception is thrown (other than by the move constructor of a
1199 /// non-copy-insertable `value_type`), `*this` is unaffected. Throw
1200 /// `std::length_error` if `size() == max_size()`. This method requires
1201 /// that the (template parameter) type `VALUE_TYPE` be `move-insertable`
1202 /// into this vector (see {Requirements on `VALUE_TYPE`}).
1203 void push_back(BloombergLP::bslmf::MovableRef<VALUE_TYPE> value);
1204
1205 /// Erase the last element from this vector. The behavior is undefined
1206 /// if this vector is empty.
1207 void pop_back();
1208
1209#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1210// {{{ BEGIN GENERATED CODE
1211// Command line: sim_cpp11_features.pl bslstl_vector.h
1212#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT
1213#define BSLSTL_VECTOR_VARIADIC_LIMIT 10
1214#endif
1215#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT_C
1216#define BSLSTL_VECTOR_VARIADIC_LIMIT_C BSLSTL_VECTOR_VARIADIC_LIMIT
1217#endif
1218#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 0
1219 iterator emplace(const_iterator position)
1220 {
1221 BSLS_ASSERT_SAFE(this->begin() <= position);
1222 BSLS_ASSERT_SAFE(position <= this->end());
1223
1224 const size_type index = position - this->begin();
1225
1226 const iterator& pos = const_cast<const iterator&>(position);
1227
1228 const size_type maxSize = max_size();
1230 maxSize - this->size())) {
1232 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1233 "vector<...>::emplace(pos,arguments): vector too long");
1234 }
1235
1236 const size_type newSize = this->size() + 1;
1237 if (newSize > this->d_capacity) {
1239 newSize, this->d_capacity, maxSize);
1240 vector temp(this->get_allocator());
1241 temp.privateReserveEmpty(newCapacity);
1242
1243 ArrayPrimitives::destructiveMoveAndEmplace(
1244 temp.d_dataBegin_p,
1245 &this->d_dataEnd_p,
1246 this->d_dataBegin_p,
1247 pos,
1248 this->d_dataEnd_p,
1249 this->allocatorRef());
1250
1251 temp.d_dataEnd_p += newSize;
1252 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1253 }
1254 else {
1255 ArrayPrimitives::emplace(
1256 pos,
1257 this->end(),
1258 this->allocatorRef());
1259 ++this->d_dataEnd_p;
1260 }
1261
1262 return this->begin() + index;
1263 }
1264#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 0
1265
1266#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 1
1267 template <class Args_01>
1268 iterator emplace(const_iterator position,
1269 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
1270 {
1271 BSLS_ASSERT_SAFE(this->begin() <= position);
1272 BSLS_ASSERT_SAFE(position <= this->end());
1273
1274 const size_type index = position - this->begin();
1275
1276 const iterator& pos = const_cast<const iterator&>(position);
1277
1278 const size_type maxSize = max_size();
1280 maxSize - this->size())) {
1282 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1283 "vector<...>::emplace(pos,arguments): vector too long");
1284 }
1285
1286 const size_type newSize = this->size() + 1;
1287 if (newSize > this->d_capacity) {
1289 newSize, this->d_capacity, maxSize);
1290 vector temp(this->get_allocator());
1291 temp.privateReserveEmpty(newCapacity);
1292
1293 ArrayPrimitives::destructiveMoveAndEmplace(
1294 temp.d_dataBegin_p,
1295 &this->d_dataEnd_p,
1296 this->d_dataBegin_p,
1297 pos,
1298 this->d_dataEnd_p,
1299 this->allocatorRef(),
1300 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
1301
1302 temp.d_dataEnd_p += newSize;
1303 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1304 }
1305 else {
1306 ArrayPrimitives::emplace(
1307 pos,
1308 this->end(),
1309 this->allocatorRef(),
1310 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
1311 ++this->d_dataEnd_p;
1312 }
1313
1314 return this->begin() + index;
1315 }
1316#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 1
1317
1318#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 2
1319 template <class Args_01,
1320 class Args_02>
1321 iterator emplace(const_iterator position,
1322 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
1324 {
1325 BSLS_ASSERT_SAFE(this->begin() <= position);
1326 BSLS_ASSERT_SAFE(position <= this->end());
1327
1328 const size_type index = position - this->begin();
1329
1330 const iterator& pos = const_cast<const iterator&>(position);
1331
1332 const size_type maxSize = max_size();
1334 maxSize - this->size())) {
1336 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1337 "vector<...>::emplace(pos,arguments): vector too long");
1338 }
1339
1340 const size_type newSize = this->size() + 1;
1341 if (newSize > this->d_capacity) {
1343 newSize, this->d_capacity, maxSize);
1344 vector temp(this->get_allocator());
1345 temp.privateReserveEmpty(newCapacity);
1346
1347 ArrayPrimitives::destructiveMoveAndEmplace(
1348 temp.d_dataBegin_p,
1349 &this->d_dataEnd_p,
1350 this->d_dataBegin_p,
1351 pos,
1352 this->d_dataEnd_p,
1353 this->allocatorRef(),
1354 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1355 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
1356
1357 temp.d_dataEnd_p += newSize;
1358 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1359 }
1360 else {
1361 ArrayPrimitives::emplace(
1362 pos,
1363 this->end(),
1364 this->allocatorRef(),
1365 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1366 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
1367 ++this->d_dataEnd_p;
1368 }
1369
1370 return this->begin() + index;
1371 }
1372#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 2
1373
1374#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 3
1375 template <class Args_01,
1376 class Args_02,
1377 class Args_03>
1378 iterator emplace(const_iterator position,
1379 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1380 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1381 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
1382 {
1383 BSLS_ASSERT_SAFE(this->begin() <= position);
1384 BSLS_ASSERT_SAFE(position <= this->end());
1385
1386 const size_type index = position - this->begin();
1387
1388 const iterator& pos = const_cast<const iterator&>(position);
1389
1390 const size_type maxSize = max_size();
1392 maxSize - this->size())) {
1394 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1395 "vector<...>::emplace(pos,arguments): vector too long");
1396 }
1397
1398 const size_type newSize = this->size() + 1;
1399 if (newSize > this->d_capacity) {
1401 newSize, this->d_capacity, maxSize);
1402 vector temp(this->get_allocator());
1403 temp.privateReserveEmpty(newCapacity);
1404
1405 ArrayPrimitives::destructiveMoveAndEmplace(
1406 temp.d_dataBegin_p,
1407 &this->d_dataEnd_p,
1408 this->d_dataBegin_p,
1409 pos,
1410 this->d_dataEnd_p,
1411 this->allocatorRef(),
1412 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1413 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1414 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
1415
1416 temp.d_dataEnd_p += newSize;
1417 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1418 }
1419 else {
1420 ArrayPrimitives::emplace(
1421 pos,
1422 this->end(),
1423 this->allocatorRef(),
1424 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1425 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1426 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
1427 ++this->d_dataEnd_p;
1428 }
1429
1430 return this->begin() + index;
1431 }
1432#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 3
1433
1434#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 4
1435 template <class Args_01,
1436 class Args_02,
1437 class Args_03,
1438 class Args_04>
1439 iterator emplace(const_iterator position,
1440 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1441 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1442 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1443 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
1444 {
1445 BSLS_ASSERT_SAFE(this->begin() <= position);
1446 BSLS_ASSERT_SAFE(position <= this->end());
1447
1448 const size_type index = position - this->begin();
1449
1450 const iterator& pos = const_cast<const iterator&>(position);
1451
1452 const size_type maxSize = max_size();
1454 maxSize - this->size())) {
1456 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1457 "vector<...>::emplace(pos,arguments): vector too long");
1458 }
1459
1460 const size_type newSize = this->size() + 1;
1461 if (newSize > this->d_capacity) {
1463 newSize, this->d_capacity, maxSize);
1464 vector temp(this->get_allocator());
1465 temp.privateReserveEmpty(newCapacity);
1466
1467 ArrayPrimitives::destructiveMoveAndEmplace(
1468 temp.d_dataBegin_p,
1469 &this->d_dataEnd_p,
1470 this->d_dataBegin_p,
1471 pos,
1472 this->d_dataEnd_p,
1473 this->allocatorRef(),
1474 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1475 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1476 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1477 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
1478
1479 temp.d_dataEnd_p += newSize;
1480 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1481 }
1482 else {
1483 ArrayPrimitives::emplace(
1484 pos,
1485 this->end(),
1486 this->allocatorRef(),
1487 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1488 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1489 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1490 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
1491 ++this->d_dataEnd_p;
1492 }
1493
1494 return this->begin() + index;
1495 }
1496#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 4
1497
1498#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 5
1499 template <class Args_01,
1500 class Args_02,
1501 class Args_03,
1502 class Args_04,
1503 class Args_05>
1504 iterator emplace(const_iterator position,
1505 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1506 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1507 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1508 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1509 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
1510 {
1511 BSLS_ASSERT_SAFE(this->begin() <= position);
1512 BSLS_ASSERT_SAFE(position <= this->end());
1513
1514 const size_type index = position - this->begin();
1515
1516 const iterator& pos = const_cast<const iterator&>(position);
1517
1518 const size_type maxSize = max_size();
1520 maxSize - this->size())) {
1522 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1523 "vector<...>::emplace(pos,arguments): vector too long");
1524 }
1525
1526 const size_type newSize = this->size() + 1;
1527 if (newSize > this->d_capacity) {
1529 newSize, this->d_capacity, maxSize);
1530 vector temp(this->get_allocator());
1531 temp.privateReserveEmpty(newCapacity);
1532
1533 ArrayPrimitives::destructiveMoveAndEmplace(
1534 temp.d_dataBegin_p,
1535 &this->d_dataEnd_p,
1536 this->d_dataBegin_p,
1537 pos,
1538 this->d_dataEnd_p,
1539 this->allocatorRef(),
1540 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1541 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1542 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1543 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1544 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
1545
1546 temp.d_dataEnd_p += newSize;
1547 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1548 }
1549 else {
1550 ArrayPrimitives::emplace(
1551 pos,
1552 this->end(),
1553 this->allocatorRef(),
1554 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1555 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1556 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1557 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1558 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
1559 ++this->d_dataEnd_p;
1560 }
1561
1562 return this->begin() + index;
1563 }
1564#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 5
1565
1566#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 6
1567 template <class Args_01,
1568 class Args_02,
1569 class Args_03,
1570 class Args_04,
1571 class Args_05,
1572 class Args_06>
1573 iterator emplace(const_iterator position,
1574 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1575 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1576 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1577 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1578 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1579 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
1580 {
1581 BSLS_ASSERT_SAFE(this->begin() <= position);
1582 BSLS_ASSERT_SAFE(position <= this->end());
1583
1584 const size_type index = position - this->begin();
1585
1586 const iterator& pos = const_cast<const iterator&>(position);
1587
1588 const size_type maxSize = max_size();
1590 maxSize - this->size())) {
1592 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1593 "vector<...>::emplace(pos,arguments): vector too long");
1594 }
1595
1596 const size_type newSize = this->size() + 1;
1597 if (newSize > this->d_capacity) {
1599 newSize, this->d_capacity, maxSize);
1600 vector temp(this->get_allocator());
1601 temp.privateReserveEmpty(newCapacity);
1602
1603 ArrayPrimitives::destructiveMoveAndEmplace(
1604 temp.d_dataBegin_p,
1605 &this->d_dataEnd_p,
1606 this->d_dataBegin_p,
1607 pos,
1608 this->d_dataEnd_p,
1609 this->allocatorRef(),
1610 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1611 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1612 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1613 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1614 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1615 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
1616
1617 temp.d_dataEnd_p += newSize;
1618 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1619 }
1620 else {
1621 ArrayPrimitives::emplace(
1622 pos,
1623 this->end(),
1624 this->allocatorRef(),
1625 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1626 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1627 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1628 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1629 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1630 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
1631 ++this->d_dataEnd_p;
1632 }
1633
1634 return this->begin() + index;
1635 }
1636#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 6
1637
1638#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 7
1639 template <class Args_01,
1640 class Args_02,
1641 class Args_03,
1642 class Args_04,
1643 class Args_05,
1644 class Args_06,
1645 class Args_07>
1646 iterator emplace(const_iterator position,
1647 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1648 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1649 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1650 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1651 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1652 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1653 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
1654 {
1655 BSLS_ASSERT_SAFE(this->begin() <= position);
1656 BSLS_ASSERT_SAFE(position <= this->end());
1657
1658 const size_type index = position - this->begin();
1659
1660 const iterator& pos = const_cast<const iterator&>(position);
1661
1662 const size_type maxSize = max_size();
1664 maxSize - this->size())) {
1666 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1667 "vector<...>::emplace(pos,arguments): vector too long");
1668 }
1669
1670 const size_type newSize = this->size() + 1;
1671 if (newSize > this->d_capacity) {
1673 newSize, this->d_capacity, maxSize);
1674 vector temp(this->get_allocator());
1675 temp.privateReserveEmpty(newCapacity);
1676
1677 ArrayPrimitives::destructiveMoveAndEmplace(
1678 temp.d_dataBegin_p,
1679 &this->d_dataEnd_p,
1680 this->d_dataBegin_p,
1681 pos,
1682 this->d_dataEnd_p,
1683 this->allocatorRef(),
1684 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1685 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1686 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1687 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1688 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1689 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1690 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
1691
1692 temp.d_dataEnd_p += newSize;
1693 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1694 }
1695 else {
1696 ArrayPrimitives::emplace(
1697 pos,
1698 this->end(),
1699 this->allocatorRef(),
1700 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1701 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1702 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1703 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1704 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1705 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1706 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
1707 ++this->d_dataEnd_p;
1708 }
1709
1710 return this->begin() + index;
1711 }
1712#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 7
1713
1714#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 8
1715 template <class Args_01,
1716 class Args_02,
1717 class Args_03,
1718 class Args_04,
1719 class Args_05,
1720 class Args_06,
1721 class Args_07,
1722 class Args_08>
1723 iterator emplace(const_iterator position,
1724 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1725 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1726 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1727 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1728 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1729 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1730 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1731 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
1732 {
1733 BSLS_ASSERT_SAFE(this->begin() <= position);
1734 BSLS_ASSERT_SAFE(position <= this->end());
1735
1736 const size_type index = position - this->begin();
1737
1738 const iterator& pos = const_cast<const iterator&>(position);
1739
1740 const size_type maxSize = max_size();
1742 maxSize - this->size())) {
1744 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1745 "vector<...>::emplace(pos,arguments): vector too long");
1746 }
1747
1748 const size_type newSize = this->size() + 1;
1749 if (newSize > this->d_capacity) {
1751 newSize, this->d_capacity, maxSize);
1752 vector temp(this->get_allocator());
1753 temp.privateReserveEmpty(newCapacity);
1754
1755 ArrayPrimitives::destructiveMoveAndEmplace(
1756 temp.d_dataBegin_p,
1757 &this->d_dataEnd_p,
1758 this->d_dataBegin_p,
1759 pos,
1760 this->d_dataEnd_p,
1761 this->allocatorRef(),
1762 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1763 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1764 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1765 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1766 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1767 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1768 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1769 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
1770
1771 temp.d_dataEnd_p += newSize;
1772 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1773 }
1774 else {
1775 ArrayPrimitives::emplace(
1776 pos,
1777 this->end(),
1778 this->allocatorRef(),
1779 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1780 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1781 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1782 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1783 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1784 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1785 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1786 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
1787 ++this->d_dataEnd_p;
1788 }
1789
1790 return this->begin() + index;
1791 }
1792#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 8
1793
1794#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 9
1795 template <class Args_01,
1796 class Args_02,
1797 class Args_03,
1798 class Args_04,
1799 class Args_05,
1800 class Args_06,
1801 class Args_07,
1802 class Args_08,
1803 class Args_09>
1804 iterator emplace(const_iterator position,
1805 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1806 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1807 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1808 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1809 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1810 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1811 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1812 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1813 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
1814 {
1815 BSLS_ASSERT_SAFE(this->begin() <= position);
1816 BSLS_ASSERT_SAFE(position <= this->end());
1817
1818 const size_type index = position - this->begin();
1819
1820 const iterator& pos = const_cast<const iterator&>(position);
1821
1822 const size_type maxSize = max_size();
1824 maxSize - this->size())) {
1826 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1827 "vector<...>::emplace(pos,arguments): vector too long");
1828 }
1829
1830 const size_type newSize = this->size() + 1;
1831 if (newSize > this->d_capacity) {
1833 newSize, this->d_capacity, maxSize);
1834 vector temp(this->get_allocator());
1835 temp.privateReserveEmpty(newCapacity);
1836
1837 ArrayPrimitives::destructiveMoveAndEmplace(
1838 temp.d_dataBegin_p,
1839 &this->d_dataEnd_p,
1840 this->d_dataBegin_p,
1841 pos,
1842 this->d_dataEnd_p,
1843 this->allocatorRef(),
1844 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1845 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1846 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1847 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1848 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1849 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1850 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1851 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
1852 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
1853
1854 temp.d_dataEnd_p += newSize;
1855 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1856 }
1857 else {
1858 ArrayPrimitives::emplace(
1859 pos,
1860 this->end(),
1861 this->allocatorRef(),
1862 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1863 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1864 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1865 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1866 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1867 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1868 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1869 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
1870 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
1871 ++this->d_dataEnd_p;
1872 }
1873
1874 return this->begin() + index;
1875 }
1876#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 9
1877
1878#if BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 10
1879 template <class Args_01,
1880 class Args_02,
1881 class Args_03,
1882 class Args_04,
1883 class Args_05,
1884 class Args_06,
1885 class Args_07,
1886 class Args_08,
1887 class Args_09,
1888 class Args_10>
1889 iterator emplace(const_iterator position,
1890 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1891 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1892 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1893 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1894 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1895 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1896 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1897 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1898 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1899 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
1900 {
1901 BSLS_ASSERT_SAFE(this->begin() <= position);
1902 BSLS_ASSERT_SAFE(position <= this->end());
1903
1904 const size_type index = position - this->begin();
1905
1906 const iterator& pos = const_cast<const iterator&>(position);
1907
1908 const size_type maxSize = max_size();
1910 maxSize - this->size())) {
1912 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1913 "vector<...>::emplace(pos,arguments): vector too long");
1914 }
1915
1916 const size_type newSize = this->size() + 1;
1917 if (newSize > this->d_capacity) {
1919 newSize, this->d_capacity, maxSize);
1920 vector temp(this->get_allocator());
1921 temp.privateReserveEmpty(newCapacity);
1922
1923 ArrayPrimitives::destructiveMoveAndEmplace(
1924 temp.d_dataBegin_p,
1925 &this->d_dataEnd_p,
1926 this->d_dataBegin_p,
1927 pos,
1928 this->d_dataEnd_p,
1929 this->allocatorRef(),
1930 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1931 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1932 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1933 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1934 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1935 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1936 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1937 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
1938 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
1939 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
1940
1941 temp.d_dataEnd_p += newSize;
1942 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
1943 }
1944 else {
1945 ArrayPrimitives::emplace(
1946 pos,
1947 this->end(),
1948 this->allocatorRef(),
1949 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
1950 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
1951 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
1952 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
1953 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
1954 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
1955 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
1956 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
1957 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
1958 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
1959 ++this->d_dataEnd_p;
1960 }
1961
1962 return this->begin() + index;
1963 }
1964#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_C >= 10
1965
1966#else
1967// The generated code below is a workaround for the absence of perfect
1968// forwarding in some compilers.
1969 template <class... Args>
1970 iterator emplace(const_iterator position,
1971 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments)
1972 {
1973 BSLS_ASSERT_SAFE(this->begin() <= position);
1974 BSLS_ASSERT_SAFE(position <= this->end());
1975
1976 const size_type index = position - this->begin();
1977
1978 const iterator& pos = const_cast<const iterator&>(position);
1979
1980 const size_type maxSize = max_size();
1982 maxSize - this->size())) {
1984 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
1985 "vector<...>::emplace(pos,arguments): vector too long");
1986 }
1987
1988 const size_type newSize = this->size() + 1;
1989 if (newSize > this->d_capacity) {
1991 newSize, this->d_capacity, maxSize);
1992 vector temp(this->get_allocator());
1993 temp.privateReserveEmpty(newCapacity);
1994
1995 ArrayPrimitives::destructiveMoveAndEmplace(
1996 temp.d_dataBegin_p,
1997 &this->d_dataEnd_p,
1998 this->d_dataBegin_p,
1999 pos,
2000 this->d_dataEnd_p,
2001 this->allocatorRef(),
2002 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
2003
2004 temp.d_dataEnd_p += newSize;
2005 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
2006 }
2007 else {
2008 ArrayPrimitives::emplace(
2009 pos,
2010 this->end(),
2011 this->allocatorRef(),
2012 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
2013 ++this->d_dataEnd_p;
2014 }
2015
2016 return this->begin() + index;
2017 }
2018// }}} END GENERATED CODE
2019#endif
2020
2021 /// Insert at the specified `position` in this vector a copy of the
2022 /// specified `value`, and return an iterator referring to the newly
2023 /// inserted element. If an exception is thrown (other than by the copy
2024 /// constructor, move constructor, assignment operator, or move
2025 /// assignment operator of `VALUE_TYPE`), `*this` is unaffected. Throw
2026 /// `std::length_error` if `size() == max_size()`. The behavior is
2027 /// undefined unless `position` is an iterator in the range
2028 /// `[begin() .. end()]` (both endpoints included). This method
2029 /// requires that the (template parameter) type `VALUE_TYPE` be
2030 /// `copy-insertable` into this vector (see {Requirements on
2031 /// `VALUE_TYPE`}).
2032 iterator insert(const_iterator position, const VALUE_TYPE& value);
2033
2034 /// Insert at the specified `position` in this vector the specified
2035 /// move-insertable `value`, and return an iterator referring to the
2036 /// newly inserted element. `value` is left in a valid but unspecified
2037 /// state. If an exception is thrown (other than by the copy
2038 /// constructor, move constructor, assignment operator, or move
2039 /// assignment operator of `VALUE_TYPE`), `this` is unaffected. Throw
2040 /// `std::length_error` if `size() == max_size()`. The behavior is
2041 /// undefined unless `position` is an iterator in the range
2042 /// `[begin() .. end()]` (both endpoints included). This method
2043 /// requires that the (template parameter) type `VALUE_TYPE` be
2044 /// `move-insertable` into this vector (see {Requirements on
2045 /// `VALUE_TYPE`}).
2046 iterator insert(const_iterator position,
2047 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value);
2048
2049 /// Insert at the specified `position` in this vector the specified
2050 /// `numElements` copies of the specified `value`, and return an
2051 /// iterator referring to the first newly inserted element. If an
2052 /// exception is thrown (other than by the copy constructor, move
2053 /// constructor, assignment operator, or move assignment operator of
2054 /// `VALUE_TYPE`), `*this` is unaffected. Throw `std::length_error` if
2055 /// `size() + numElements > max_size()`. The behavior is undefined
2056 /// unless `position` is an iterator in the range `[begin() .. end()]`
2057 /// (both endpoints included). This method requires that the (template
2058 /// parameter) type `VALUE_TYPE` be `copy-insertable` into this vector
2059 /// (see {Requirements on `VALUE_TYPE`}).
2060 iterator insert(const_iterator position,
2061 size_type numElements,
2062 const VALUE_TYPE& value);
2063
2064 /// Insert at the specified `position` in this vector the values in the
2065 /// range starting at the specified `first` element, and ending
2066 /// immediately before the specified `last` element. Return an iterator
2067 /// referring to the first newly inserted element. If an exception is
2068 /// thrown (other than by the copy constructor, move constructor,
2069 /// assignment operator, or move assignment operator of `value_type`),
2070 /// `*this` is unaffected. Throw `std::length_error` if
2071 /// `size() + distance(first, last) > max_size()`. The (template
2072 /// parameter) type `INPUT_ITER` shall meet the requirements of an input
2073 /// iterator defined in the C++11 standard [24.2.3] providing access to
2074 /// values of a type convertible to `value_type`, and `value_type` must
2075 /// be `emplace-constructible` from `*i` into this vector, where `i` is
2076 /// a dereferenceable iterator in the range `[first .. last)` (see
2077 /// {Requirements on `VALUE_TYPE`}). The behavior is undefined unless
2078 /// `position` is an iterator in the range `[begin() .. end()]` (both
2079 /// endpoints included), and `first` and `last` refer to a range of
2080 /// valid values where `first` is at a position at or before `last`.
2081 ///
2082 /// NOTE: This function has been implemented inline due to an issue with
2083 /// the Sun compiler.
2084 template <class INPUT_ITER>
2085 iterator insert(const_iterator position, INPUT_ITER first, INPUT_ITER last)
2086 {
2087 BSLS_ASSERT_SAFE(this->begin() <= position);
2088 BSLS_ASSERT_SAFE(position <= this->end());
2089 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
2090
2091 // If 'first' and 'last' are integral, then they are not iterators and
2092 // we should call 'insert(position, first, last)', where 'first' is
2093 // actually a misnamed count, and 'last' is a misnamed value. We can
2094 // assume that any fundamental type passed to this function is integral
2095 // or else compilation errors will result. The extra argument,
2096 // 'bslmf::Nil()', is to avoid an overloading ambiguity: In case
2097 // 'first' is an integral type, it would be convertible both to
2098 // 'bslmf::MatchArithmeticType' and 'bslmf::MatchAnyType'; but the
2099 // 'bslmf::Nil()' will be an exact match to 'bslmf::Nil', so the
2100 // overload with 'bslmf::MatchArithmeticType' will be preferred.
2101
2102 const size_type index = position - this->begin();
2103 privateInsertDispatch(
2104 position, first, last, first, BloombergLP::bslmf::Nil());
2105 return this->begin() + index;
2106 }
2107
2108#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2109 /// Insert at the specified `position` in this vector each `VALUE_TYPE`
2110 /// object in the specified `values` initializer list, and return an
2111 /// iterator referring to the first newly inserted element. If an
2112 /// exception is thrown (other than by the copy constructor, move
2113 /// constructor, assignment operator, and move assignment operator of
2114 /// `VALUE_TYPE`), `*this` is unaffected. Throw `std::length_error` if
2115 /// `size() + values.size() > max_size()`. The behavior is undefined
2116 /// unless `position` is an iterator in the range `[begin() .. end()]`
2117 /// (both endpoints included). This method requires that the (template
2118 /// parameter) type `VALUE_TYPE` be `copy-insertable` into this vector
2119 /// (see {Requirements on `VALUE_TYPE`}).
2120 iterator insert(const_iterator position,
2121 std::initializer_list<VALUE_TYPE> values);
2122#endif
2123
2124 /// Remove from this vector the element at the specified `position`, and
2125 /// return an iterator providing modifiable access to the element
2126 /// immediately following the removed element, or the position returned
2127 /// by the method `end` if the removed element was the last in the
2128 /// sequence. The behavior is undefined unless `position` is an
2129 /// iterator in the range `[cbegin() .. cend())`.
2130 iterator erase(const_iterator position);
2131
2133 /// Remove from this vector the sequence of elements starting at the
2134 /// specified `first` position and ending before the specified `last`
2135 /// position, and return an iterator providing modifiable access to the
2136 /// element immediately following the last removed element, or the
2137 /// position returned by the method `end` if the removed elements were
2138 /// last in the sequence. The behavior is undefined unless `first` is
2139 /// an iterator in the range `[cbegin() .. cend()]` (both endpoints
2140 /// included) and `last` is an iterator in the range
2141 /// `[first .. cend()]` (both endpoints included).
2142
2143 void swap(vector& other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(
2144 AllocatorTraits::propagate_on_container_swap::value ||
2145 AllocatorTraits::is_always_equal::value);
2146 // Exchange the value of this object with that of the specified 'other'
2147 // object; also exchange the allocator of this object with that of
2148 // 'other' if the (template parameter) type 'ALLOCATOR' has the
2149 // 'propagate_on_container_swap' trait, and do not modify either
2150 // allocator otherwise. This method provides the no-throw
2151 // exception-safety guarantee. This operation has 'O[1]' complexity if
2152 // either this object was created with the same allocator as 'other' or
2153 // 'ALLOCATOR' has the 'propagate_on_container_swap' trait; otherwise,
2154 // it has 'O[n + m]' complexity, where 'n' and 'm' are the number of
2155 // elements in this object and 'other', respectively. Note that this
2156 // method's support for swapping objects created with different
2157 // allocators when 'ALLOCATOR' does not have the
2158 // 'propagate_on_container_swap' trait is a departure from the
2159 // C++ Standard.
2160
2161 /// Remove all elements from this vector making its size 0. Note that
2162 /// although this vector is empty after this method returns, it
2163 /// preserves the same capacity it had before the method was called.
2164 void clear() BSLS_KEYWORD_NOEXCEPT;
2165
2166 // ACCESSORS
2167
2168 /// Return (a copy of) the allocator used for memory allocation by this
2169 /// vector.
2170 allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT;
2171
2172 /// Return a theoretical upper bound on the largest number of elements
2173 /// that this vector could possibly hold. Note that there is no
2174 /// guarantee that the vector can successfully grow to the returned
2175 /// size, or even close to that size without running out of resources.
2176 /// Also note that requests to create a vector longer than this number
2177 /// of elements are guaranteed to raise a `std::length_error` exception.
2178 size_type max_size() const BSLS_KEYWORD_NOEXCEPT;
2179};
2180
2181// FREE OPERATORS
2182
2183 // *** relational operators ***
2184
2185/// Return `true` if the specified `lhs` and `rhs` objects have the same
2186/// value, and `false` otherwise. Two `vector` objects `lhs` and `rhs` have
2187/// the same value if they have the same number of elements, and each
2188/// element in the ordered sequence of elements of `lhs` has the same value
2189/// as the corresponding element in the ordered sequence of elements of
2190/// `rhs`. This method requires that the (template parameter) type
2191/// `VALUE_TYPE` be `equality-comparable` (see {Requirements on
2192/// `VALUE_TYPE`}).
2193template <class VALUE_TYPE, class ALLOCATOR>
2194bool operator==(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2195 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2196
2197#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2198template <class VALUE_TYPE, class ALLOCATOR>
2199bool operator!=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2200 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2201 // Return 'true' if the specified 'lhs' and 'rhs' objects do not have the
2202 // same value, and 'false' otherwise. Two 'vector' objects 'lhs' and 'rhs'
2203 // do not have the same value if they do not have the same number of
2204 // elements, or some element in the ordered sequence of elements of 'lhs'
2205 // does not have the same value as the corresponding element in the ordered
2206 // sequence of elements of 'rhs'. This method requires that the (template
2207 // parameter) type 'VALUE_TYPE' be 'equality-comparable' (see {Requirements
2208 // on 'VALUE_TYPE'}).
2209#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2210
2211#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2212
2213/// Perform a lexicographic three-way comparison of the specified `lhs` and
2214/// the specified `rhs` vectors by using the comparison operators of
2215/// `VALUE_TYPE` on each element; return the result of that comparison.
2216template <class VALUE_TYPE, class ALLOCATOR>
2217BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
2218 const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2219 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2220
2221#else
2222
2223template <class VALUE_TYPE, class ALLOCATOR>
2224bool operator<(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2225 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2226 // Return 'true' if the value of the specified 'lhs' vector is
2227 // lexicographically less than that of the specified 'rhs' vector, and
2228 // 'false' otherwise. Given iterators 'i' and 'j' over the respective
2229 // sequences '[lhs.begin() .. lhs.end())' and '[rhs.begin() .. rhs.end())',
2230 // the value of vector 'lhs' is lexicographically less than that of vector
2231 // 'rhs' if 'true == *i < *j' for the first pair of corresponding iterator
2232 // positions where '*i < *j' and '*j < *i' are not both 'false'. If no
2233 // such corresponding iterator position exists, the value of 'lhs' is
2234 // lexicographically less than that of 'rhs' if 'lhs.size() < rhs.size()'.
2235 // This method requires that 'operator<', inducing a total order, be
2236 // defined for 'value_type'.
2237
2238template <class VALUE_TYPE, class ALLOCATOR>
2239bool operator>(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2240 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2241 // Return 'true' if the value of the specified 'lhs' vector is
2242 // lexicographically greater than that of the specified 'rhs' vector, and
2243 // 'false' otherwise. The value of vector 'lhs' is lexicographically
2244 // greater than that of vector 'rhs' if 'rhs' is lexicographically less
2245 // than 'lhs' (see 'operator<'). This method requires that 'operator<',
2246 // inducing a total order, be defined for 'value_type'. Note that this
2247 // operator returns 'rhs < lhs'.
2248
2249template <class VALUE_TYPE, class ALLOCATOR>
2250bool operator<=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2251 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2252 // Return 'true' if the value of the specified 'lhs' vector is
2253 // lexicographically less than or equal to that of the specified 'rhs'
2254 // vector, and 'false' otherwise. The value of vector 'lhs' is
2255 // lexicographically less than or equal to that of vector 'rhs' if 'rhs' is
2256 // not lexicographically less than 'lhs' (see 'operator<'). This method
2257 // requires that 'operator<', inducing a total order, be defined for
2258 // 'value_type'. Note that this operator returns '!(rhs < lhs)'.
2259
2260template <class VALUE_TYPE, class ALLOCATOR>
2261bool operator>=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
2262 const vector<VALUE_TYPE, ALLOCATOR>& rhs);
2263 // Return 'true' if the value of the specified 'lhs' vector is
2264 // lexicographically greater than or equal to that of the specified 'rhs'
2265 // vector, and 'false' otherwise. The value of vector 'lhs' is
2266 // lexicographically greater than or equal to that of vector 'rhs' if 'lhs'
2267 // is not lexicographically less than 'rhs' (see 'operator<'). This method
2268 // requires that 'operator<', inducing a total order, be defined for
2269 // 'value_type'. Note that this operator returns '!(lhs < rhs)'.
2270
2271#endif // BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2272
2273// FREE FUNCTIONS
2274
2275/// Erase all the elements in the specified vector `vec` that compare equal
2276/// to the specified `value`. Return the number of elements erased.
2277template <class VALUE_TYPE, class ALLOCATOR, class BDE_OTHER_TYPE>
2279erase(vector<VALUE_TYPE, ALLOCATOR>& vec, const BDE_OTHER_TYPE& value);
2280
2281/// Erase all the elements in the specified vector `vec` that satisfy the
2282/// specified predicate `predicate`. Return the number of elements erased.
2283template <class VALUE_TYPE, class ALLOCATOR, class PREDICATE>
2285erase_if(vector<VALUE_TYPE, ALLOCATOR>& vec, PREDICATE predicate);
2286
2287template <class VALUE_TYPE, class ALLOCATOR>
2288void swap(vector<VALUE_TYPE, ALLOCATOR>& a,
2289 vector<VALUE_TYPE, ALLOCATOR>& b)
2291 a.swap(b)));
2292 // Exchange the value of the specified 'a' object with that of the
2293 // specified 'b' object; also exchange the allocator of 'a' with that of
2294 // 'b' if the (template parameter) type 'ALLOCATOR' has the
2295 // 'propagate_on_container_swap' trait, and do not modify either allocator
2296 // otherwise. This function provides the no-throw exception-safety
2297 // guarantee. This operation has 'O[1]' complexity if either 'a' was
2298 // created with the same allocator as 'b' or 'ALLOCATOR' has the
2299 // 'propagate_on_container_swap' trait; otherwise, it has 'O[n + m]'
2300 // complexity, where 'n' and 'm' are the number of elements in 'a' and 'b',
2301 // respectively. Note that this function's support for swapping objects
2302 // created with different allocators when 'ALLOCATOR' does not have the
2303 // 'propagate_on_container_swap' trait is a departure from the C++
2304 // Standard.
2305
2306
2307 // =====================================
2308 // class vector<VALUE_TYPE *, ALLOCATOR>
2309 // =====================================
2310
2311/// This partial specialization of `vector` for pointer types to a (template
2312/// parameter) `VALUE_TYPE` type is implemented in terms of
2313/// `vector<UintPtr>` to reduce the amount of code generated. Note that
2314/// this specialization rebinds the (template parameter) `ALLOCATOR` type to
2315/// an allocator of `UintPtr` so as to satisfy the invariant in the `vector`
2316/// base class. Note that the contract for all members is the same as the
2317/// primary template, so documentation is not repeated to avoid accidentally
2318/// introducing inconsistency over time.
2319template <class VALUE_TYPE, class ALLOCATOR>
2320class vector<VALUE_TYPE *, ALLOCATOR>
2321{
2322
2323 // PRIVATE TYPES
2324 typedef BloombergLP::bsls::Types::UintPtr UintPtr;
2325#if defined(BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES)
2326 typedef typename allocator_traits<ALLOCATOR>::
2327 template rebind_alloc<UintPtr> ImplAlloc;
2328#else
2329 typedef typename ALLOCATOR::template rebind<UintPtr>::other ImplAlloc;
2330#endif
2331 typedef vector<UintPtr, ImplAlloc> Impl;
2332 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
2333
2334 // PRIVATE DATA
2335 Impl d_impl; // The 'UintPtr' vector used for the implementation.
2336
2337 public:
2338 // PUBLIC TYPES
2339 typedef VALUE_TYPE *value_type;
2340 typedef value_type& reference;
2341 typedef const value_type& const_reference;
2342 typedef VALUE_TYPE **iterator;
2343 typedef VALUE_TYPE *const *const_iterator;
2344 typedef std::size_t size_type;
2345 typedef std::ptrdiff_t difference_type;
2346 typedef ALLOCATOR allocator_type;
2347 typedef typename ALLOCATOR::pointer pointer;
2348 typedef typename ALLOCATOR::const_pointer const_pointer;
2349 typedef bsl::reverse_iterator<iterator> reverse_iterator;
2350 typedef bsl::reverse_iterator<const_iterator> const_reverse_iterator;
2351
2352 // *** construct/copy/destroy ***
2353
2354 // CREATORS
2355 vector() BSLS_KEYWORD_NOEXCEPT;
2356
2357 explicit vector(const ALLOCATOR& basicAllocator) BSLS_KEYWORD_NOEXCEPT;
2358
2359 explicit vector(size_type initialSize,
2360 const ALLOCATOR& basicAllocator = ALLOCATOR());
2361
2362 vector(size_type initialSize,
2363 VALUE_TYPE *value,
2364 const ALLOCATOR& basicAllocator = ALLOCATOR());
2365
2366 template <class INPUT_ITER>
2367 vector(INPUT_ITER first,
2368 INPUT_ITER last,
2369 const ALLOCATOR& basicAllocator = ALLOCATOR());
2370
2371 vector(const vector& original);
2372
2373 vector(BloombergLP::bslmf::MovableRef<vector> original)
2374 BSLS_KEYWORD_NOEXCEPT; // IMPLICIT
2375
2376 vector(const vector& original,
2377 const typename type_identity<ALLOCATOR>::type& basicAllocator);
2378
2379 vector(BloombergLP::bslmf::MovableRef<vector> original,
2380 const typename type_identity<ALLOCATOR>::type& basicAllocator);
2381
2382
2383#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2384 vector(std::initializer_list<VALUE_TYPE *> values,
2385 const ALLOCATOR& basicAllocator = ALLOCATOR());
2386#endif
2387
2388 ~vector();
2389
2390 // MANIPULATORS
2391 vector& operator=(const vector& rhs);
2392
2393 /// NOTE: This function has been implemented inline due to an issue with
2394 /// the Sun compiler.
2395 vector& operator=(
2396 BloombergLP::bslmf::MovableRef<vector<VALUE_TYPE *, ALLOCATOR> > rhs)
2398 d_impl = MoveUtil::move(MoveUtil::access(rhs).d_impl)))
2399 {
2400 d_impl = MoveUtil::move(MoveUtil::access(rhs).d_impl);
2401 return *this;
2402 }
2403
2404#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2405 vector& operator=(std::initializer_list<VALUE_TYPE *> values);
2406
2407 void assign(std::initializer_list<VALUE_TYPE *> values);
2408
2409#endif
2410
2411 template <class INPUT_ITER>
2412 void assign(INPUT_ITER first, INPUT_ITER last);
2413 void assign(size_type numElements, VALUE_TYPE *value);
2414
2415
2416 // *** iterators ***
2417
2420
2423
2424 // *** element access ***
2425
2426 reference operator[](size_type position);
2427 reference at(size_type position);
2428
2429 reference front();
2430 reference back();
2431
2432 VALUE_TYPE **data() BSLS_KEYWORD_NOEXCEPT;
2433
2434 // *** capacity ***
2435
2436 void resize(size_type newLength);
2437 void resize(size_type newLength, VALUE_TYPE *value);
2438
2439 void reserve(size_type newCapacity);
2440 void shrink_to_fit();
2441
2442 // *** modifiers ***
2443
2444 value_type &emplace_back();
2445
2446# if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
2447 template <class ARG>
2448 value_type &emplace_back(ARG&& arg);
2449# else
2450 value_type &emplace_back(VALUE_TYPE *ptr);
2451# endif
2452
2453 void push_back(VALUE_TYPE *value);
2454
2455 void pop_back();
2456
2457 iterator emplace(const_iterator position);
2458
2459# if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
2460 template <class ARG>
2461 iterator emplace(const_iterator position, ARG&& arg);
2462# else
2463 iterator emplace(const_iterator position, VALUE_TYPE *ptr);
2464# endif
2465
2466 iterator insert(const_iterator position, VALUE_TYPE *value);
2467 iterator insert(const_iterator position,
2468 size_type numElements,
2469 VALUE_TYPE *value);
2470
2471 template <class INPUT_ITER>
2472 iterator insert(const_iterator position,
2473 INPUT_ITER first,
2474 INPUT_ITER last)
2475 {
2476 // NOTE: This function has been implemented inline due to an issue with
2477 // the Sun compiler.
2478
2479 typedef typename vector_ForwardIteratorForPtrs<VALUE_TYPE,
2480 INPUT_ITER>::type Iter;
2481
2482 return (iterator)d_impl.insert(
2483 (const UintPtr *)position, Iter(first), Iter(last));
2484 }
2485
2486#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2487 iterator insert(const_iterator position,
2488 std::initializer_list<VALUE_TYPE *> values);
2489#endif
2490
2491 iterator erase(const_iterator position);
2493
2494 void swap(vector<VALUE_TYPE *, ALLOCATOR>& other)
2496 d_impl.swap(other.d_impl)));
2497
2498 void clear() BSLS_KEYWORD_NOEXCEPT;
2499
2500 // ACCESSORS
2501 allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT;
2502
2503 size_type max_size() const BSLS_KEYWORD_NOEXCEPT;
2504
2505 // *** iterators ***
2506
2511
2516
2517 // *** capacity ***
2518
2521 bool empty() const BSLS_KEYWORD_NOEXCEPT;
2522
2523 // *** element access ***
2524
2525 const_reference operator[](size_type position) const;
2526
2527 const_reference at(size_type position) const;
2528
2529 const_reference front() const;
2530 const_reference back() const;
2531
2532 VALUE_TYPE *const *data() const BSLS_KEYWORD_NOEXCEPT;
2533
2534 // FRIENDS
2535 friend
2536 bool operator==(const vector& lhs, const vector& rhs)
2537 {
2538 return lhs.d_impl == rhs.d_impl;
2539 }
2540
2541#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2542
2543 friend BloombergLP::bslalg::SynthThreeWayUtil::Result<Impl>
2544 operator<=>(const vector& lhs, const vector& rhs)
2545 {
2546 return BloombergLP::bslalg::SynthThreeWayUtil::compare(lhs.d_impl,
2547 rhs.d_impl);
2548 }
2549
2550#else
2551
2552 friend
2553 bool operator!=(const vector& lhs, const vector& rhs)
2554 {
2555 return lhs.d_impl != rhs.d_impl;
2556 }
2557
2558 friend
2559 bool operator<(const vector& lhs, const vector& rhs)
2560 {
2561 return lhs.d_impl < rhs.d_impl;
2562 }
2563
2564 friend
2565 bool operator>(const vector& lhs, const vector& rhs)
2566 {
2567 return lhs.d_impl > rhs.d_impl;
2568 }
2569
2570 friend
2571 bool operator<=(const vector& lhs, const vector& rhs)
2572 {
2573 return lhs.d_impl <= rhs.d_impl;
2574 }
2575
2576 friend
2577 bool operator>=(const vector& lhs, const vector& rhs)
2578 {
2579 return lhs.d_impl >= rhs.d_impl;
2580 }
2581
2582#endif // BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2583
2584 friend
2585 void swap(vector& a, vector& b)
2587 a.d_impl.swap(b.d_impl)))
2588 {
2589 a.d_impl.swap(b.d_impl);
2590 }
2591};
2592
2593#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2594// CLASS TEMPLATE DEDUCTION GUIDES
2595
2596/// Deduce the template parameter `VALUE` from the corresponding parameter
2597/// supplied to the constructor of `vector`. This deduction guide does not
2598/// participate unless the supplied allocator is convertible to
2599/// `bsl::allocator<VALUE>`.
2600template <
2601 class SIZE_TYPE,
2602 class VALUE,
2603 class ALLOC,
2604 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
2605 class = bsl::enable_if_t<
2606 bsl::is_convertible_v<
2607 SIZE_TYPE,
2609 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
2610 >
2611vector(SIZE_TYPE, VALUE, ALLOC *) -> vector<VALUE>;
2612
2613/// Deduce the template parameter `VALUE` from the `value_type` of the
2614/// iterators supplied to the constructor of `vector`.
2615template <
2616 class INPUT_ITERATOR,
2617 class VALUE =
2618 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
2619 >
2620vector(INPUT_ITERATOR, INPUT_ITERATOR) -> vector<VALUE>;
2621
2622/// Deduce the template parameter `VALUE` from the `value_type` of the
2623/// iterators supplied to the constructor of `vector`. This deduction
2624/// guide does not participate unless the supplied allocator meets the
2625/// requirements of a standard allocator.
2626template<
2627 class INPUT_ITERATOR,
2628 class ALLOCATOR,
2629 class VALUE =
2630 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
2631 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
2632 >
2633vector(INPUT_ITERATOR, INPUT_ITERATOR, ALLOCATOR) -> vector<VALUE, ALLOCATOR>;
2634
2635/// Deduce the template parameter `VALUE` from the `value_type` of the
2636/// iterators supplied to the constructor of `vector`. This deduction
2637/// guide does not participate unless the supplied allocator is convertible
2638/// to `bsl::allocator<VALUE>`.
2639template<
2640 class INPUT_ITERATOR,
2641 class ALLOC,
2642 class VALUE =
2643 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
2644 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
2645 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
2646 >
2647vector(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
2648-> vector<VALUE>;
2649
2650/// Deduce the template parameter `VALUE` from the `value_type` of the
2651/// initializer_list supplied to the constructor of `vector`. This
2652/// deduction guide does not participate unless the supplied allocator is
2653/// convertible to `bsl::allocator<VALUE>`.
2654template<
2655 class VALUE,
2656 class ALLOC,
2657 class DEFAULT_ALLOCATOR = bsl::allocator<VALUE>,
2658 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
2659 >
2660vector(std::initializer_list<VALUE>, ALLOC *)
2661-> vector<VALUE>;
2662#endif
2663
2664
2665// ============================================================================
2666// TEMPLATE AND INLINE FUNCTION DEFINITIONS
2667// ============================================================================
2668// See IMPLEMENTATION NOTES in the .cpp before modifying anything below.
2669
2670 // ======================================
2671 // class vector_UintPtrConversionIterator
2672 // ======================================
2673
2674/// This class provides a minimal proxy iterator adapter, transforming
2675/// pointers to `uintptr_t` values on the fly, for only the operations
2676/// needed to implement the member functions and constructors of the
2677/// `vector` partial template specialization that take iterator ranges as
2678/// arguments. While it does not provide a standard conforming iterator
2679/// itself, if provides exactly sufficient behavior to implement all the
2680/// needed members. `VALUE_TYPE` shall be a pointer type, and `ITERATOR`
2681/// shall be a standard conforming iterator that dereferences to a type
2682/// implicitly convertible to `VALUE_TYPE`
2683///
2684/// See @ref bslstl_vector_cpp03
2685template <class VALUE_TYPE, class ITERATOR>
2686class vector_UintPtrConversionIterator {
2687
2688 private:
2689 // DATA
2690 ITERATOR d_iter;
2691
2692 public:
2693 // PUBLIC TYPES
2694 typedef BloombergLP::bsls::Types::UintPtr UintPtr;
2695
2696 typedef UintPtr value_type;
2697 typedef UintPtr *pointer;
2698 typedef UintPtr reference;
2699 typedef typename iterator_traits<ITERATOR>::difference_type
2700 difference_type;
2701 typedef typename iterator_traits<ITERATOR>::iterator_category
2702 iterator_category;
2703
2704 // CREATORS
2705
2706 /// Create a proxy iterator adapting the specified `it`.
2707 vector_UintPtrConversionIterator(ITERATOR it); // IMPLICIT
2708
2709 // MANIPULATORS
2710
2711 /// Increment this iterator to refer to the next element in the
2712 /// underlying sequence, and return a reference to this object.
2713 vector_UintPtrConversionIterator& operator++();
2714
2715 // ACCESSORS
2716
2717 /// Return the value of the pointer this iterator refers to, converted
2718 /// to an unsigned integer.
2719 UintPtr operator*() const;
2720
2721#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2722
2723 /// Perform a three-way comparison with the specified `other` object and
2724 /// return the result of that comparison. Where the underlying (wrapped)
2725 /// iterator of type `ITERATOR` supports 3 way comparison, the default
2726 /// spaceship operator will defer to `ITERATOR::operator<=>` and have
2727 /// the same return type as `ITERATOR::operator<=>`; otherwise, this
2728 /// operator will be deleted.
2729 auto
2730 operator<=>(const vector_UintPtrConversionIterator& other) const = default;
2731
2732#else
2733
2734 // FRIENDS
2735 friend
2736 bool operator!=(const vector_UintPtrConversionIterator& lhs,
2737 const vector_UintPtrConversionIterator& rhs)
2738 // Return 'true' if the specified 'lhs' and 'rhs' iterators do not
2739 // refer to the same element in the same underlying sequence and no
2740 // more than one refers to the past-the-end element of the sequence,
2741 // and 'false' otherwise. The behavior is undefined if 'lhs' and 'rhs'
2742 // do not iterate over the same sequence.
2743 {
2744 return lhs.d_iter != rhs.d_iter;
2745 }
2746
2747#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2748
2749 // FRIENDS
2750
2751 /// Return `true` if the specified `lhs` and `rhs` iterators refer to
2752 /// the same element in the same underlying sequence or both refer to
2753 /// the past-the-end element of the same sequence, and `false`
2754 /// otherwise. The behavior is undefined if `lhs` and `rhs` do not
2755 /// iterate over the same sequence.
2756 friend
2757 bool operator==(const vector_UintPtrConversionIterator& lhs,
2758 const vector_UintPtrConversionIterator& rhs)
2759 {
2760 return lhs.d_iter == rhs.d_iter;
2761 }
2762
2763 /// Return `true` if the specified `lhs` iterator is earlier in the
2764 /// underlying sequence than the specified `rhs` iterator, and `false`
2765 /// otherwise. The behavior is undefined if `lhs` and `rhs` do not
2766 /// iterate over the same sequence, or if the (template parameter) type
2767 /// `ITERATOR` is not a random access iterator.
2768 friend
2769 bool operator<(const vector_UintPtrConversionIterator& lhs,
2770 const vector_UintPtrConversionIterator& rhs)
2771 {
2772 return lhs.d_iter < rhs.d_iter;
2773 }
2774
2775 /// Return the distance between the specified `lhs` iterator and the
2776 /// specified `rhs` iterator. The behavior is undefined if `lhs` and
2777 /// `rhs` do not iterate over the same sequence, or if the (template
2778 /// parameter) type `ITERATOR` is not a random access iterator.
2779 friend
2780 difference_type operator-(const vector_UintPtrConversionIterator& lhs,
2781 const vector_UintPtrConversionIterator& rhs)
2782 {
2783 return lhs.d_iter - rhs.d_iter;
2784 }
2785};
2786
2787 // --------------------------------------
2788 // class vector_UintPtrConversionIterator
2789 // --------------------------------------
2790
2791// CREATORS
2792template <class VALUE_TYPE, class ITERATOR>
2793inline
2796: d_iter(it)
2797{
2798}
2799
2800// MANIPULATORS
2801template <class VALUE_TYPE, class ITERATOR>
2802inline
2803vector_UintPtrConversionIterator<VALUE_TYPE, ITERATOR>&
2804vector_UintPtrConversionIterator<VALUE_TYPE, ITERATOR>::operator++()
2805{
2806 ++d_iter;
2807 return *this;
2808}
2809
2810// ACCESSORS
2811template <class VALUE_TYPE, class ITERATOR>
2812inline
2813BloombergLP::bsls::Types::UintPtr
2814vector_UintPtrConversionIterator<VALUE_TYPE, ITERATOR>::operator*() const
2815{
2816 VALUE_TYPE const ptr = *d_iter;
2817 return reinterpret_cast<UintPtr>(ptr);
2818}
2819
2820
2821 // ========================
2822 // class Vector_PushProctor
2823 // ========================
2824
2825/// This class template provides a proctor for a newly created object that
2826/// is managed by an allocator. The object will be constructed through a
2827/// call to `allocator_traits<ALLOCATOR>::construct`, and it should be
2828/// destroyed by a call to `allocator_traits<ALLOCATOR>::destroy`. Note
2829/// that this proctor takes no responsibility for the allocated memory that
2830/// the supplied value is constructed in.
2831///
2832/// See @ref bslstl_vector_cpp03
2833template <class VALUE_TYPE, class ALLOCATOR>
2834class Vector_PushProctor {
2835
2836 // DATA
2837 VALUE_TYPE *d_target_p; // managed object
2838 ALLOCATOR d_allocator; // allocator to be used to destroy managed object
2839
2840 private:
2841 // NOT IMPLEMENTED
2842 Vector_PushProctor(const Vector_PushProctor&); // = delete;
2843 Vector_PushProctor& operator=(const Vector_PushProctor&); // = delete;
2844
2845 public:
2846 // CREATORS
2847
2848 /// Create a proctor that conditionally manages the specified `target`
2849 /// object (if non-zero) by destroying the managed object with a call to
2850 /// `allocator_traits<ALLOCATOR>::destroy` using the specified
2851 /// `allocator` upon destruction of this proctor, unless the managed
2852 /// objects has been released.
2853 Vector_PushProctor(VALUE_TYPE *target, const ALLOCATOR& allocator);
2854
2855 /// Destroy this proctor, and destroy the object it manages (if any) by
2856 /// a call to `allocator_traits<ALLOCATOR>::destroy` using the allocator
2857 /// supplied at construction. If no object is currently being managed,
2858 /// this method has no effect.
2859 ~Vector_PushProctor();
2860
2861 // MANIPULATORS
2862
2863 /// Release from management the object currently managed by this
2864 /// proctor. If no object is currently being managed, this method has
2865 /// no effect.
2866 void release();
2867};
2868
2869 // ------------------------
2870 // class Vector_PushProctor
2871 // ------------------------
2872
2873// CREATORS
2874template <class VALUE_TYPE, class ALLOCATOR>
2875inline
2876Vector_PushProctor<VALUE_TYPE,ALLOCATOR>::Vector_PushProctor(
2877 VALUE_TYPE *target,
2878 const ALLOCATOR& allocator)
2879: d_target_p(target)
2880, d_allocator(allocator)
2881{
2882}
2883
2884template <class VALUE_TYPE, class ALLOCATOR>
2885inline
2886Vector_PushProctor<VALUE_TYPE,ALLOCATOR>::~Vector_PushProctor()
2887{
2888 if (d_target_p) {
2889 bsl::allocator_traits<ALLOCATOR>::destroy(d_allocator, d_target_p);
2890 }
2891}
2892
2893// MANIPULATORS
2894template <class VALUE_TYPE, class ALLOCATOR>
2895inline
2896void Vector_PushProctor<VALUE_TYPE,ALLOCATOR>::release()
2897{
2898 d_target_p = 0;
2899}
2900
2901#if defined(BSLS_ASSERT_SAFE_IS_USED)
2902 // -----------------------
2903 // class Vector_RangeCheck
2904 // -----------------------
2905
2906template <class BSLSTL_ITERATOR>
2907inline
2908typename enable_if<!Vector_IsRandomAccessIterator<BSLSTL_ITERATOR>::value,
2909 bool>::type
2910Vector_RangeCheck::isInvalidRange(BSLSTL_ITERATOR, BSLSTL_ITERATOR)
2911{
2912 return false;
2913}
2914
2915template <class BSLSTL_ITERATOR>
2916inline
2917typename enable_if<Vector_IsRandomAccessIterator<BSLSTL_ITERATOR>::value,
2918 bool>::type
2919Vector_RangeCheck::isInvalidRange(BSLSTL_ITERATOR first, BSLSTL_ITERATOR last)
2920{
2921 return last < first;
2922}
2923#endif
2924
2925 // ----------------
2926 // class vectorBase
2927 // ----------------
2928
2929// CREATORS
2930template <class VALUE_TYPE>
2931inline
2932vectorBase<VALUE_TYPE>::vectorBase()
2933: d_dataBegin_p(0)
2934, d_dataEnd_p(0)
2935, d_capacity(0)
2936{
2937}
2938
2939// MANIPULATORS
2940
2941template <class VALUE_TYPE>
2942inline
2943void
2944vectorBase<VALUE_TYPE>::adopt(BloombergLP::bslmf::MovableRef<vectorBase> base)
2945{
2946 BSLS_ASSERT_SAFE(0 == d_dataBegin_p);
2947 BSLS_ASSERT_SAFE(0 == d_dataEnd_p);
2948 BSLS_ASSERT_SAFE(0 == d_capacity);
2949
2950 vectorBase& lvalue = base;
2951 d_dataBegin_p = lvalue.d_dataBegin_p;
2952 d_dataEnd_p = lvalue.d_dataEnd_p;
2953 d_capacity = lvalue.d_capacity;
2954
2955 lvalue.d_dataBegin_p = 0;
2956 lvalue.d_dataEnd_p = 0;
2957 lvalue.d_capacity = 0;
2958}
2959 // *** iterators ***
2960template <class VALUE_TYPE>
2961inline
2962typename vectorBase<VALUE_TYPE>::iterator
2963vectorBase<VALUE_TYPE>::begin() BSLS_KEYWORD_NOEXCEPT
2964{
2965 return d_dataBegin_p;
2966}
2967
2968template <class VALUE_TYPE>
2969inline
2970typename vectorBase<VALUE_TYPE>::iterator
2971vectorBase<VALUE_TYPE>::end() BSLS_KEYWORD_NOEXCEPT
2972{
2973 return d_dataEnd_p;
2974}
2975
2976template <class VALUE_TYPE>
2977inline
2978typename vectorBase<VALUE_TYPE>::reverse_iterator
2979vectorBase<VALUE_TYPE>::rbegin() BSLS_KEYWORD_NOEXCEPT
2980{
2981 return reverse_iterator(end());
2982}
2983
2984template <class VALUE_TYPE>
2985inline
2986typename vectorBase<VALUE_TYPE>::reverse_iterator
2987vectorBase<VALUE_TYPE>::rend() BSLS_KEYWORD_NOEXCEPT
2988{
2989 return reverse_iterator(begin());
2990}
2991
2992 // *** element access ***
2993
2994template <class VALUE_TYPE>
2995inline
2996typename vectorBase<VALUE_TYPE>::reference
2997vectorBase<VALUE_TYPE>::operator[](size_type position)
2998{
2999 BSLS_ASSERT_SAFE(size() > position);
3000
3001 return d_dataBegin_p[position];
3002}
3003
3004template <class VALUE_TYPE>
3005typename vectorBase<VALUE_TYPE>::reference
3006vectorBase<VALUE_TYPE>::at(size_type position)
3007{
3008 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(position >= size())) {
3010 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
3011 "vector<...>::at(position): invalid position");
3012 }
3013 return d_dataBegin_p[position];
3014}
3015
3016template <class VALUE_TYPE>
3017inline
3018typename vectorBase<VALUE_TYPE>::reference
3019vectorBase<VALUE_TYPE>::front()
3020{
3022
3023 return *d_dataBegin_p;
3024}
3025
3026template <class VALUE_TYPE>
3027inline
3028typename vectorBase<VALUE_TYPE>::reference
3029vectorBase<VALUE_TYPE>::back()
3030{
3032
3033 return *(d_dataEnd_p - 1);
3034}
3035
3036template <class VALUE_TYPE>
3037inline
3038VALUE_TYPE *
3039vectorBase<VALUE_TYPE>::data() BSLS_KEYWORD_NOEXCEPT
3040{
3041 return d_dataBegin_p;
3042}
3043
3044// ACCESSORS
3045
3046 // *** iterators ***
3047template <class VALUE_TYPE>
3048inline
3049typename vectorBase<VALUE_TYPE>::const_iterator
3050vectorBase<VALUE_TYPE>::begin() const BSLS_KEYWORD_NOEXCEPT
3051{
3052 return d_dataBegin_p;
3053}
3054
3055template <class VALUE_TYPE>
3056inline
3057typename vectorBase<VALUE_TYPE>::const_iterator
3058vectorBase<VALUE_TYPE>::cbegin() const BSLS_KEYWORD_NOEXCEPT
3059{
3060 return d_dataBegin_p;
3061}
3062
3063template <class VALUE_TYPE>
3064inline
3065typename vectorBase<VALUE_TYPE>::const_iterator
3066vectorBase<VALUE_TYPE>::end() const BSLS_KEYWORD_NOEXCEPT
3067{
3068 return d_dataEnd_p;
3069}
3070
3071template <class VALUE_TYPE>
3072inline
3073typename vectorBase<VALUE_TYPE>::const_iterator
3074vectorBase<VALUE_TYPE>::cend() const BSLS_KEYWORD_NOEXCEPT
3075{
3076 return d_dataEnd_p;
3077}
3078
3079template <class VALUE_TYPE>
3080inline
3081typename vectorBase<VALUE_TYPE>::const_reverse_iterator
3082vectorBase<VALUE_TYPE>::rbegin() const BSLS_KEYWORD_NOEXCEPT
3083{
3084 return const_reverse_iterator(end());
3085}
3086
3087template <class VALUE_TYPE>
3088inline
3089typename vectorBase<VALUE_TYPE>::const_reverse_iterator
3090vectorBase<VALUE_TYPE>::crbegin() const BSLS_KEYWORD_NOEXCEPT
3091{
3092 return const_reverse_iterator(end());
3093}
3094
3095template <class VALUE_TYPE>
3096inline
3097typename vectorBase<VALUE_TYPE>::const_reverse_iterator
3098vectorBase<VALUE_TYPE>::rend() const BSLS_KEYWORD_NOEXCEPT
3099{
3100 return const_reverse_iterator(begin());
3101}
3102
3103template <class VALUE_TYPE>
3104inline
3105typename vectorBase<VALUE_TYPE>::const_reverse_iterator
3106vectorBase<VALUE_TYPE>::crend() const BSLS_KEYWORD_NOEXCEPT
3107{
3108 return const_reverse_iterator(begin());
3109}
3110
3111 // *** capacity ***
3112
3113template <class VALUE_TYPE>
3114inline
3115typename vectorBase<VALUE_TYPE>::size_type
3116vectorBase<VALUE_TYPE>::size() const BSLS_KEYWORD_NOEXCEPT
3117{
3118 return d_dataEnd_p - d_dataBegin_p;
3119}
3120
3121template <class VALUE_TYPE>
3122inline
3123typename vectorBase<VALUE_TYPE>::size_type
3124vectorBase<VALUE_TYPE>::capacity() const BSLS_KEYWORD_NOEXCEPT
3125{
3126 return d_capacity;
3127}
3128
3129template <class VALUE_TYPE>
3130inline
3131bool vectorBase<VALUE_TYPE>::empty() const BSLS_KEYWORD_NOEXCEPT
3132{
3133 return d_dataEnd_p == d_dataBegin_p;
3134}
3135
3136 // *** element access ***
3137template <class VALUE_TYPE>
3138inline
3139typename vectorBase<VALUE_TYPE>::const_reference
3140vectorBase<VALUE_TYPE>::operator[](size_type position) const
3141{
3142 BSLS_ASSERT_SAFE(size() > position);
3143
3144 return d_dataBegin_p[position];
3145}
3146
3147template <class VALUE_TYPE>
3148typename vectorBase<VALUE_TYPE>::const_reference
3149vectorBase<VALUE_TYPE>::at(size_type position) const
3150{
3151 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(position >= size())) {
3153 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(
3154 "const vector<...>::at(position): invalid position");
3155 }
3156 return d_dataBegin_p[position];
3157}
3158
3159template <class VALUE_TYPE>
3160inline
3161typename vectorBase<VALUE_TYPE>::const_reference
3162vectorBase<VALUE_TYPE>::front() const
3163{
3165
3166 return *d_dataBegin_p;
3167}
3168
3169template <class VALUE_TYPE>
3170inline
3171typename vectorBase<VALUE_TYPE>::const_reference
3172vectorBase<VALUE_TYPE>::back() const
3173{
3175
3176 return *(d_dataEnd_p - 1);
3177}
3178
3179template <class VALUE_TYPE>
3180inline
3181const VALUE_TYPE *
3182vectorBase<VALUE_TYPE>::data() const BSLS_KEYWORD_NOEXCEPT
3183{
3184 return d_dataBegin_p;
3185}
3186
3187 // --------------------------------------------
3188 // class vector<VALUE_TYPE, ALLOCATOR>::Proctor
3189 // --------------------------------------------
3190
3191// CREATORS
3192template <class VALUE_TYPE, class ALLOCATOR>
3194vector<VALUE_TYPE, ALLOCATOR>::Proctor::Proctor(VALUE_TYPE *data,
3195 std::size_t capacity,
3196 ContainerBase *container)
3197: d_data_p(data)
3198, d_capacity(capacity)
3199, d_container_p(container)
3200{
3201}
3202
3203template <class VALUE_TYPE, class ALLOCATOR>
3205vector<VALUE_TYPE, ALLOCATOR>::Proctor::~Proctor()
3206{
3207 using BloombergLP::bslma::AllocatorUtil;
3208
3209 if (d_data_p) {
3210 AllocatorUtil::deallocateObject(d_container_p->allocatorRef(),
3211 d_data_p, d_capacity);
3212 }
3213}
3214
3215// MANIPULATORS
3216template <class VALUE_TYPE, class ALLOCATOR>
3218void vector<VALUE_TYPE, ALLOCATOR>::Proctor::release()
3219{
3220 d_data_p = 0;
3221}
3222
3223 // ------------
3224 // class vector
3225 // ------------
3226
3227// PRIVATE MANIPULATORS
3228template <class VALUE_TYPE, class ALLOCATOR>
3229template <class FWD_ITER>
3230void vector<VALUE_TYPE, ALLOCATOR>::constructFromRange(
3231 FWD_ITER first,
3232 FWD_ITER last,
3233 std::forward_iterator_tag)
3234{
3235 // Specialization for all iterators except input iterators: 'size' can be
3236 // computed in advance.
3237 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
3238
3239 const size_type maxSize = max_size();
3240 const size_type newSize = bsl::distance(first, last);
3241
3242 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(newSize > maxSize)) {
3244 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3245 "vector<...>::(range-constructor): input too long");
3246 }
3247
3248 size_type newCapacity = Vector_Util::computeNewCapacity(newSize,
3249 0,
3250 maxSize);
3251 this->privateReserveEmpty(newCapacity);
3252 Proctor proctor(this->d_dataBegin_p,
3253 this->d_capacity,
3254 static_cast<ContainerBase *>(this));
3255
3256 ArrayPrimitives::copyConstruct(this->d_dataEnd_p,
3257 first,
3258 last,
3259 this->allocatorRef());
3260 proctor.release();
3261 this->d_dataEnd_p += newSize;
3262}
3263
3264template <class VALUE_TYPE, class ALLOCATOR>
3265template <class INPUT_ITER>
3266void vector<VALUE_TYPE, ALLOCATOR>::constructFromRange(
3267 INPUT_ITER first,
3268 INPUT_ITER last,
3269 std::input_iterator_tag)
3270{
3271 // IMPLEMENTATION NOTES: construct this vector by iterated 'push_back',
3272 // which may reallocate memory multiple times, but unfortunately is
3273 // required because we can't compute the size in advance (as with
3274 // 'forward_iterator_tag') because input iterators can be traversed only
3275 // once. A temporary vector is populated and then swapped to ensure that
3276 // all memory is reclaimed if @ref emplace_back throws, as the destructor will
3277 // not run when this method is called from a constructor.
3278
3279 vector temp(this->get_allocator());
3280 while (first != last) {
3281 temp.emplace_back(*first);
3282 ++first;
3283 }
3284 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3285}
3286
3287template <class VALUE_TYPE, class ALLOCATOR>
3288template <class INTEGRAL>
3289void vector<VALUE_TYPE, ALLOCATOR>::constructFromRange(
3290 INTEGRAL initialSize,
3291 INTEGRAL value,
3292 BloombergLP::bslmf::Nil)
3293{
3294 // IMPLEMENTATION NOTES: this constructor is trying to construct a range of
3295 // 'initialSize' elements having the specified integral 'value'. Without
3296 // this extra overload, such calls would match an attempt to construct from
3297 // a range specified by two iterators. Note that as 'VALUE_TYPE' must be
3298 // a (trivial) integral type, a proctor is almost certainly not needed.
3299 // The only risk of a throw is for user-defined allocators doing strange
3300 // extra (potentially throwing) work in their 'construct' call.
3301
3303 static_cast<size_type>(initialSize) > max_size())) {
3305 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3306 "vector<...>::(repeated-value constructor): input too long");
3307 }
3308
3309 if (initialSize > 0) {
3310 privateReserveEmpty(initialSize);
3311 Proctor proctor(this->d_dataBegin_p,
3312 this->d_capacity,
3313 static_cast<ContainerBase *>(this));
3314
3315 ArrayPrimitives::uninitializedFillN(this->d_dataBegin_p,
3316 initialSize,
3317 static_cast<VALUE_TYPE>(value),
3318 this->allocatorRef());
3319
3320 proctor.release();
3321 this->d_dataEnd_p += initialSize;
3322 }
3323}
3324
3325template <class VALUE_TYPE, class ALLOCATOR>
3326template <class INPUT_ITER>
3327inline
3328void vector<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
3329 const_iterator position,
3330 INPUT_ITER count,
3331 INPUT_ITER value,
3332 BloombergLP::bslmf::MatchArithmeticType ,
3333 BloombergLP::bslmf::Nil )
3334{
3335 // 'count' and 'value' are integral types that just happen to be the same.
3336 // They are not iterators, so we call 'insert(position, count, value)'.
3337
3338 this->insert(position,
3339 static_cast<size_type>(count),
3340 static_cast<VALUE_TYPE>(value));
3341}
3342
3343template <class VALUE_TYPE, class ALLOCATOR>
3344template <class INPUT_ITER>
3345inline
3346void vector<VALUE_TYPE, ALLOCATOR>::privateInsertDispatch(
3347 const_iterator position,
3348 INPUT_ITER first,
3349 INPUT_ITER last,
3350 BloombergLP::bslmf::MatchAnyType ,
3351 BloombergLP::bslmf::MatchAnyType )
3352{
3353 // Dispatch based on iterator category.
3354 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
3355
3356 typedef typename iterator_traits<INPUT_ITER>::iterator_category Tag;
3357 this->privateInsert(position, first, last, Tag());
3358}
3359
3360template <class VALUE_TYPE, class ALLOCATOR>
3361template <class INPUT_ITER>
3362void vector<VALUE_TYPE, ALLOCATOR>::privateInsert(
3363 const_iterator position,
3364 INPUT_ITER first,
3365 INPUT_ITER last,
3366 const std::input_iterator_tag&)
3367{
3368 // IMPLEMENTATION NOTES: We can't compute the size in advance. Append onto
3369 // the back of the current vector while capacity remains. This honors the
3370 // idea of not allocating unnecessarily for the temporary vector, and so
3371 // saves important cycles from a sequential allocator. We then need to
3372 // shuffle the data back into the correct position. If capacity must grow,
3373 // then create a new vector and move just the newly inserted elements into
3374 // place, moving the original vector elements only in the event that all
3375 // iterated elements are correctly inserted.
3376
3377 // Short-circuit if there is nothing to do, do not allocate for an empty
3378 // 'vector' as that would invalidate 'begin'.
3379
3380 if (first == last) {
3381 return; // RETURN
3382 }
3383
3384 if (!this->capacity()) {
3385 privateReserveEmpty(size_type(1));
3386 position = this->d_dataBegin_p; // 'position' must have been null
3387 }
3388
3389 size_type insertOffset = position - this->d_dataBegin_p;
3390 size_type initialEnd = this->size();
3391 size_type tailLength = this->end() - position;
3392
3393 VALUE_TYPE *emplaceBegin = this->d_dataEnd_p;
3394 VALUE_TYPE *emplaceEnd = this->d_dataBegin_p + this->d_capacity;
3395 VALUE_TYPE *emplacePosition = emplaceBegin;
3396
3397 allocator_type alloc(this->get_allocator()); // need non-'const' lvalue
3398
3399 // This vector is not used if sufficient capacity can be found in the
3400 // current vector for all the insertions. However, it must have a
3401 // lifetime longer than the destructor guard below, in order to ensure
3402 // that the guarded elements are destroyed before the allocated storage
3403 // that holds them if an exception is thrown.
3404 vector resultState(alloc); // vector that will build the final state
3405
3406 // TBD: We really need an allocator-aware 'AutoDestructor' that will call
3407 // 'allocator_traits<ALLOC>::destroy(allocator, pointer)' rather than
3408 // invoke the destructor directly. 'bslalg::AutoArrayDestructor' is close,
3409 // but lacks 'reset'.
3410 BloombergLP::bslma::AutoDestructor<VALUE_TYPE> insertProctor(
3411 emplacePosition);
3412 while (emplacePosition != emplaceEnd) {
3413 AllocatorTraits::construct(alloc, emplacePosition, *first);
3414 ++insertProctor;
3415 ++emplacePosition;
3416 if (++first == last) {
3417 this->d_dataEnd_p = emplacePosition;
3418 insertProctor.release();
3419
3420 ArrayPrimitives::rotate(this->d_dataBegin_p + insertOffset,
3421 this->d_dataBegin_p + initialEnd,
3422 this->d_dataEnd_p);
3423 return; // RETURN
3424 }
3425 }
3426
3427 // Now we need to grow a buffer and destructive-move only the new elements.
3428 // This needs to be handled in a loop that can allow for multiple growth
3429 // spurts.
3430
3431 resultState.reserve(this->d_capacity*2);
3432 emplacePosition = resultState.d_dataBegin_p + insertOffset;
3433 ArrayPrimitives::destructiveMove(emplacePosition,
3434 emplaceBegin,
3435 emplaceEnd,
3436 alloc);
3437
3438 size_type emplaceOffset = (emplaceEnd - emplaceBegin);
3439 insertProctor.reset(emplacePosition);
3440 emplaceBegin = emplacePosition;
3441 emplaceEnd = resultState.d_dataBegin_p + resultState.d_capacity
3442 - tailLength;
3443 emplacePosition += emplaceOffset;
3444
3445 while (first != last) {
3446 if (emplacePosition == emplaceEnd) {
3447 // need to grow again
3448 vector nextResult(alloc);
3449 nextResult.reserve(resultState.d_capacity*2);
3450 emplacePosition = nextResult.d_dataBegin_p + insertOffset;
3451 ArrayPrimitives::destructiveMove(emplacePosition,
3452 emplaceBegin,
3453 emplaceEnd,
3454 alloc);
3455
3456 insertProctor.reset(emplacePosition);
3457 emplaceOffset = (emplaceEnd - emplaceBegin);
3458 emplaceBegin = emplacePosition;
3459 emplaceEnd = nextResult.d_dataBegin_p + nextResult.d_capacity
3460 - tailLength;
3461 emplacePosition += emplaceOffset;
3462
3463 Vector_Util::swap(&nextResult.d_dataBegin_p,
3464 &resultState.d_dataBegin_p);
3465 }
3466
3467 AllocatorTraits::construct(alloc, emplacePosition, *first);
3468 ++insertProctor;
3469 ++emplacePosition;
3470 ++first;
3471 }
3472
3473 // move tail
3474 ArrayPrimitives::destructiveMove(emplacePosition,
3475 this->d_dataBegin_p + insertOffset,
3476 this->d_dataBegin_p + initialEnd,
3477 alloc);
3478
3479 // reset 'end' in case a throw follows:
3480 this->d_dataEnd_p = this->d_dataBegin_p + insertOffset;
3481 emplacePosition += (initialEnd - insertOffset);
3482 insertProctor.setLength(
3483 insertProctor.length() + static_cast<int>(initialEnd - insertOffset));
3484
3485 // move prefix
3486 ArrayPrimitives::destructiveMove(resultState.d_dataBegin_p,
3487 this->d_dataBegin_p,
3488 this->d_dataBegin_p + insertOffset,
3489 alloc);
3490
3491 // Nothing after this point can throw.
3492
3493 // 'resultState' adopts ownership of all elements
3494 resultState.d_dataEnd_p = emplacePosition;
3495
3496 // We no longer own any data to protect
3497 insertProctor.release();
3498 this->d_dataEnd_p = this->d_dataBegin_p;
3499
3500 // Finally, swap states
3501 Vector_Util::swap(&this->d_dataBegin_p, &resultState.d_dataBegin_p);
3502}
3503
3504template <class VALUE_TYPE, class ALLOCATOR>
3505template <class FWD_ITER>
3506void vector<VALUE_TYPE, ALLOCATOR>::privateInsert(
3507 const_iterator position,
3508 FWD_ITER first,
3509 FWD_ITER last,
3510 const std::forward_iterator_tag&)
3511{
3512 // Specialization for all iterators except input iterators: 'size' can be
3513 // computed in advance.
3514 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
3515
3516 const iterator& pos = const_cast<iterator>(position);
3517
3518 const size_type maxSize = max_size();
3519 const size_type n = bsl::distance(first, last);
3520
3521 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(n > maxSize - this->size())) {
3523 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3524 "vector<...>::insert(pos,first,last): vector too long");
3525 }
3526
3527 const size_type newSize = this->size() + n;
3528 if (newSize > this->d_capacity) {
3529 size_type newCapacity = Vector_Util::computeNewCapacity(
3530 newSize,
3531 this->d_capacity,
3532 maxSize);
3533
3534 vector temp(this->get_allocator());
3535 temp.privateReserveEmpty(newCapacity);
3536
3537 ArrayPrimitives::destructiveMoveAndInsert(temp.d_dataBegin_p,
3538 &this->d_dataEnd_p,
3539 this->d_dataBegin_p,
3540 pos,
3541 this->d_dataEnd_p,
3542 first,
3543 last,
3544 n,
3545 this->allocatorRef());
3546 temp.d_dataEnd_p += newSize;
3547 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3548 }
3549 else {
3550 ArrayPrimitives::insert(pos,
3551 this->end(),
3552 first,
3553 last,
3554 n,
3555 this->allocatorRef());
3556 this->d_dataEnd_p += n;
3557 }
3558}
3559
3560template <class VALUE_TYPE, class ALLOCATOR>
3561void vector<VALUE_TYPE, ALLOCATOR>::privateMoveInsert(
3562 vector *fromVector,
3563 const_iterator position)
3564{
3565 const iterator& pos = const_cast<const iterator&>(position);
3566
3567 const size_type maxSize = max_size();
3568 const size_type n = fromVector->size();
3569 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(n > maxSize - this->size())) {
3571 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3572 "vector<...>::insert(pos,first,last): vector too long");
3573 }
3574
3575 const size_type newSize = this->size() + n;
3576 if (newSize > this->d_capacity) {
3577 const size_type newCapacity = Vector_Util::computeNewCapacity(
3578 newSize,
3579 this->d_capacity,
3580 maxSize);
3581
3582 vector temp(this->get_allocator());
3583 temp.privateReserveEmpty(newCapacity);
3584
3585 ArrayPrimitives::destructiveMoveAndMoveInsert(
3586 temp.d_dataBegin_p,
3587 &this->d_dataEnd_p,
3588 &fromVector->d_dataEnd_p,
3589 this->d_dataBegin_p,
3590 pos,
3591 this->d_dataEnd_p,
3592 fromVector->d_dataBegin_p,
3593 fromVector->d_dataEnd_p,
3594 n,
3595 this->allocatorRef());
3596 temp.d_dataEnd_p += newSize;
3597 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3598 }
3599 else {
3600 ArrayPrimitives::moveInsert(pos,
3601 this->end(),
3602 &fromVector->d_dataEnd_p,
3603 fromVector->d_dataBegin_p,
3604 fromVector->d_dataEnd_p,
3605 n,
3606 this->allocatorRef());
3607 this->d_dataEnd_p += n;
3608 }
3609}
3610
3611template <class VALUE_TYPE, class ALLOCATOR>
3612inline
3613void vector<VALUE_TYPE, ALLOCATOR>::privateReserveEmpty(size_type numElements)
3614{
3615 BSLS_ASSERT_SAFE(this->empty());
3616 BSLS_ASSERT_SAFE(0 == this->capacity());
3617
3618 this->d_dataBegin_p = this->d_dataEnd_p =
3619 AllocatorUtil::allocateObject<VALUE_TYPE>(this->allocatorRef(),
3620 numElements);
3621
3622 this->d_capacity = numElements;
3623}
3624
3625#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3626// {{{ BEGIN GENERATED CODE
3627// Command line: sim_cpp11_features.pl bslstl_vector.h
3628#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT
3629#define BSLSTL_VECTOR_VARIADIC_LIMIT 10
3630#endif
3631#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT_D
3632#define BSLSTL_VECTOR_VARIADIC_LIMIT_D BSLSTL_VECTOR_VARIADIC_LIMIT
3633#endif
3634#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 0
3635template <class VALUE_TYPE, class ALLOCATOR>
3636void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3637 )
3638{
3639 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3641 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3642 "vector<...>:emplace_back(args...): vector too long");
3643 }
3644
3645 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3646 this->d_capacity,
3647 this->max_size());
3648 vector temp(this->get_allocator());
3649 temp.privateReserveEmpty(newCapacity);
3650
3651 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3652 AllocatorTraits::construct(
3653 this->allocatorRef(),
3654 pos);
3655
3656 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3657 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3658 this->d_dataBegin_p,
3659 this->d_dataEnd_p,
3660 this->allocatorRef());
3661 guard.release();
3662
3663 this->d_dataEnd_p = this->d_dataBegin_p;
3664 temp.d_dataEnd_p = ++pos;
3665 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3666}
3667#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 0
3668
3669#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 1
3670template <class VALUE_TYPE, class ALLOCATOR>
3671template <class Args_01>
3672void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3673 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
3674{
3675 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3677 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3678 "vector<...>:emplace_back(args...): vector too long");
3679 }
3680
3681 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3682 this->d_capacity,
3683 this->max_size());
3684 vector temp(this->get_allocator());
3685 temp.privateReserveEmpty(newCapacity);
3686
3687 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3688 AllocatorTraits::construct(
3689 this->allocatorRef(),
3690 pos,
3691 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
3692
3693 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3694 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3695 this->d_dataBegin_p,
3696 this->d_dataEnd_p,
3697 this->allocatorRef());
3698 guard.release();
3699
3700 this->d_dataEnd_p = this->d_dataBegin_p;
3701 temp.d_dataEnd_p = ++pos;
3702 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3703}
3704#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 1
3705
3706#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 2
3707template <class VALUE_TYPE, class ALLOCATOR>
3708template <class Args_01,
3709 class Args_02>
3710void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3711 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3712 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
3713{
3714 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3716 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3717 "vector<...>:emplace_back(args...): vector too long");
3718 }
3719
3720 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3721 this->d_capacity,
3722 this->max_size());
3723 vector temp(this->get_allocator());
3724 temp.privateReserveEmpty(newCapacity);
3725
3726 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3727 AllocatorTraits::construct(
3728 this->allocatorRef(),
3729 pos,
3730 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3731 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
3732
3733 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3734 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3735 this->d_dataBegin_p,
3736 this->d_dataEnd_p,
3737 this->allocatorRef());
3738 guard.release();
3739
3740 this->d_dataEnd_p = this->d_dataBegin_p;
3741 temp.d_dataEnd_p = ++pos;
3742 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3743}
3744#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 2
3745
3746#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 3
3747template <class VALUE_TYPE, class ALLOCATOR>
3748template <class Args_01,
3749 class Args_02,
3750 class Args_03>
3751void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3752 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3753 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3754 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
3755{
3756 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3758 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3759 "vector<...>:emplace_back(args...): vector too long");
3760 }
3761
3762 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3763 this->d_capacity,
3764 this->max_size());
3765 vector temp(this->get_allocator());
3766 temp.privateReserveEmpty(newCapacity);
3767
3768 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3769 AllocatorTraits::construct(
3770 this->allocatorRef(),
3771 pos,
3772 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3773 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3774 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
3775
3776 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3777 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3778 this->d_dataBegin_p,
3779 this->d_dataEnd_p,
3780 this->allocatorRef());
3781 guard.release();
3782
3783 this->d_dataEnd_p = this->d_dataBegin_p;
3784 temp.d_dataEnd_p = ++pos;
3785 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3786}
3787#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 3
3788
3789#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 4
3790template <class VALUE_TYPE, class ALLOCATOR>
3791template <class Args_01,
3792 class Args_02,
3793 class Args_03,
3794 class Args_04>
3795void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3796 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3797 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3798 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3799 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
3800{
3801 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3803 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3804 "vector<...>:emplace_back(args...): vector too long");
3805 }
3806
3807 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3808 this->d_capacity,
3809 this->max_size());
3810 vector temp(this->get_allocator());
3811 temp.privateReserveEmpty(newCapacity);
3812
3813 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3814 AllocatorTraits::construct(
3815 this->allocatorRef(),
3816 pos,
3817 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3818 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3819 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3820 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
3821
3822 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3823 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3824 this->d_dataBegin_p,
3825 this->d_dataEnd_p,
3826 this->allocatorRef());
3827 guard.release();
3828
3829 this->d_dataEnd_p = this->d_dataBegin_p;
3830 temp.d_dataEnd_p = ++pos;
3831 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3832}
3833#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 4
3834
3835#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 5
3836template <class VALUE_TYPE, class ALLOCATOR>
3837template <class Args_01,
3838 class Args_02,
3839 class Args_03,
3840 class Args_04,
3841 class Args_05>
3842void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3843 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3844 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3845 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3846 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
3847 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
3848{
3849 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3851 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3852 "vector<...>:emplace_back(args...): vector too long");
3853 }
3854
3855 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3856 this->d_capacity,
3857 this->max_size());
3858 vector temp(this->get_allocator());
3859 temp.privateReserveEmpty(newCapacity);
3860
3861 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3862 AllocatorTraits::construct(
3863 this->allocatorRef(),
3864 pos,
3865 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3866 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3867 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3868 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
3869 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
3870
3871 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3872 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3873 this->d_dataBegin_p,
3874 this->d_dataEnd_p,
3875 this->allocatorRef());
3876 guard.release();
3877
3878 this->d_dataEnd_p = this->d_dataBegin_p;
3879 temp.d_dataEnd_p = ++pos;
3880 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3881}
3882#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 5
3883
3884#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 6
3885template <class VALUE_TYPE, class ALLOCATOR>
3886template <class Args_01,
3887 class Args_02,
3888 class Args_03,
3889 class Args_04,
3890 class Args_05,
3891 class Args_06>
3892void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3893 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3894 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3895 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3896 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
3897 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
3898 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
3899{
3900 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3902 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3903 "vector<...>:emplace_back(args...): vector too long");
3904 }
3905
3906 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3907 this->d_capacity,
3908 this->max_size());
3909 vector temp(this->get_allocator());
3910 temp.privateReserveEmpty(newCapacity);
3911
3912 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3913 AllocatorTraits::construct(
3914 this->allocatorRef(),
3915 pos,
3916 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3917 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3918 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3919 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
3920 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
3921 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
3922
3923 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3924 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3925 this->d_dataBegin_p,
3926 this->d_dataEnd_p,
3927 this->allocatorRef());
3928 guard.release();
3929
3930 this->d_dataEnd_p = this->d_dataBegin_p;
3931 temp.d_dataEnd_p = ++pos;
3932 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3933}
3934#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 6
3935
3936#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 7
3937template <class VALUE_TYPE, class ALLOCATOR>
3938template <class Args_01,
3939 class Args_02,
3940 class Args_03,
3941 class Args_04,
3942 class Args_05,
3943 class Args_06,
3944 class Args_07>
3945void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
3946 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
3947 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
3948 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
3949 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
3950 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
3951 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
3952 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
3953{
3954 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
3956 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
3957 "vector<...>:emplace_back(args...): vector too long");
3958 }
3959
3960 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
3961 this->d_capacity,
3962 this->max_size());
3963 vector temp(this->get_allocator());
3964 temp.privateReserveEmpty(newCapacity);
3965
3966 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
3967 AllocatorTraits::construct(
3968 this->allocatorRef(),
3969 pos,
3970 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
3971 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
3972 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
3973 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
3974 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
3975 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
3976 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
3977
3978 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
3979 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
3980 this->d_dataBegin_p,
3981 this->d_dataEnd_p,
3982 this->allocatorRef());
3983 guard.release();
3984
3985 this->d_dataEnd_p = this->d_dataBegin_p;
3986 temp.d_dataEnd_p = ++pos;
3987 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
3988}
3989#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 7
3990
3991#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 8
3992template <class VALUE_TYPE, class ALLOCATOR>
3993template <class Args_01,
3994 class Args_02,
3995 class Args_03,
3996 class Args_04,
3997 class Args_05,
3998 class Args_06,
3999 class Args_07,
4000 class Args_08>
4001void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
4002 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4003 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4004 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4005 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4006 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4007 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4008 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4009 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
4010{
4011 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4013 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4014 "vector<...>:emplace_back(args...): vector too long");
4015 }
4016
4017 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4018 this->d_capacity,
4019 this->max_size());
4020 vector temp(this->get_allocator());
4021 temp.privateReserveEmpty(newCapacity);
4022
4023 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4024 AllocatorTraits::construct(
4025 this->allocatorRef(),
4026 pos,
4027 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4028 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4029 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4030 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4031 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4032 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4033 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4034 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
4035
4036 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4037 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4038 this->d_dataBegin_p,
4039 this->d_dataEnd_p,
4040 this->allocatorRef());
4041 guard.release();
4042
4043 this->d_dataEnd_p = this->d_dataBegin_p;
4044 temp.d_dataEnd_p = ++pos;
4045 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4046}
4047#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 8
4048
4049#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 9
4050template <class VALUE_TYPE, class ALLOCATOR>
4051template <class Args_01,
4052 class Args_02,
4053 class Args_03,
4054 class Args_04,
4055 class Args_05,
4056 class Args_06,
4057 class Args_07,
4058 class Args_08,
4059 class Args_09>
4060void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
4061 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4062 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4063 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4064 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4065 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4066 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4067 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4068 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4069 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
4070{
4071 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4073 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4074 "vector<...>:emplace_back(args...): vector too long");
4075 }
4076
4077 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4078 this->d_capacity,
4079 this->max_size());
4080 vector temp(this->get_allocator());
4081 temp.privateReserveEmpty(newCapacity);
4082
4083 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4084 AllocatorTraits::construct(
4085 this->allocatorRef(),
4086 pos,
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 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4094 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4095 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
4096
4097 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4098 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4099 this->d_dataBegin_p,
4100 this->d_dataEnd_p,
4101 this->allocatorRef());
4102 guard.release();
4103
4104 this->d_dataEnd_p = this->d_dataBegin_p;
4105 temp.d_dataEnd_p = ++pos;
4106 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4107}
4108#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 9
4109
4110#if BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 10
4111template <class VALUE_TYPE, class ALLOCATOR>
4112template <class Args_01,
4113 class Args_02,
4114 class Args_03,
4115 class Args_04,
4116 class Args_05,
4117 class Args_06,
4118 class Args_07,
4119 class Args_08,
4120 class Args_09,
4121 class Args_10>
4122void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
4123 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4124 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4125 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4126 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4127 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4128 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4129 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
4130 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
4131 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
4132 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
4133{
4134 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4136 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4137 "vector<...>:emplace_back(args...): vector too long");
4138 }
4139
4140 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4141 this->d_capacity,
4142 this->max_size());
4143 vector temp(this->get_allocator());
4144 temp.privateReserveEmpty(newCapacity);
4145
4146 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4147 AllocatorTraits::construct(
4148 this->allocatorRef(),
4149 pos,
4150 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4151 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4152 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4153 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4154 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4155 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4156 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
4157 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
4158 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
4159 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
4160
4161 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4162 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4163 this->d_dataBegin_p,
4164 this->d_dataEnd_p,
4165 this->allocatorRef());
4166 guard.release();
4167
4168 this->d_dataEnd_p = this->d_dataBegin_p;
4169 temp.d_dataEnd_p = ++pos;
4170 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4171}
4172#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_D >= 10
4173
4174#else
4175// The generated code below is a workaround for the absence of perfect
4176// forwarding in some compilers.
4177template <class VALUE_TYPE, class ALLOCATOR>
4178template <class... Args>
4179void vector<VALUE_TYPE, ALLOCATOR>::privateEmplaceBackWithAllocation(
4180 BSLS_COMPILERFEATURES_FORWARD_REF(Args)...arguments)
4181{
4182 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4184 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4185 "vector<...>:emplace_back(args...): vector too long");
4186 }
4187
4188 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4189 this->d_capacity,
4190 this->max_size());
4191 vector temp(this->get_allocator());
4192 temp.privateReserveEmpty(newCapacity);
4193
4194 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4195 AllocatorTraits::construct(
4196 this->allocatorRef(),
4197 pos,
4198 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
4199
4200 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4201 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4202 this->d_dataBegin_p,
4203 this->d_dataEnd_p,
4204 this->allocatorRef());
4205 guard.release();
4206
4207 this->d_dataEnd_p = this->d_dataBegin_p;
4208 temp.d_dataEnd_p = ++pos;
4209 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4210}
4211// }}} END GENERATED CODE
4212#endif
4213
4214template <class VALUE_TYPE, class ALLOCATOR>
4215void vector<VALUE_TYPE, ALLOCATOR>::privatePushBackWithAllocation(
4216 const VALUE_TYPE& value)
4217{
4218 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4220 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4221 "vector<...>:push_back(lvalue): vector too long");
4222 }
4223
4224 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4225 this->d_capacity,
4226 this->max_size());
4227
4228 vector temp(this->get_allocator());
4229 temp.privateReserveEmpty(newCapacity);
4230
4231 // Construct before we risk invalidating the reference
4232 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4233 AllocatorTraits::construct(this->allocatorRef(), pos, value);
4234
4235 // Nothing else should throw, but probably worth guarding the above
4236 // 'construct' call for types with potentially-throwing destructive moves.
4237 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4238 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4239 this->d_dataBegin_p,
4240 this->d_dataEnd_p,
4241 this->allocatorRef());
4242 guard.release(); // Nothing after this can throw
4243
4244 this->d_dataEnd_p = this->d_dataBegin_p;
4245 temp.d_dataEnd_p = ++pos;
4246 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4247}
4248
4249template <class VALUE_TYPE, class ALLOCATOR>
4250void vector<VALUE_TYPE, ALLOCATOR>::privatePushBackWithAllocation(
4251 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value)
4252{
4253 VALUE_TYPE& lvalue = value;
4254 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(max_size() == this->size())) {
4256 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4257 "vector<...>:push_back(rvalue): vector too long");
4258 }
4259
4260 size_type newCapacity = Vector_Util::computeNewCapacity(this->size() + 1,
4261 this->d_capacity,
4262 this->max_size());
4263
4264 vector temp(this->get_allocator());
4265 temp.privateReserveEmpty(newCapacity);
4266
4267 // Construct before we risk invalidating the reference
4268 VALUE_TYPE *pos = temp.d_dataBegin_p + this->size();
4269 AllocatorTraits::construct(this->allocatorRef(),
4270 pos,
4271 MoveUtil::move(lvalue));
4272
4273 // Nothing else should throw, but probably worth guarding the above
4274 // 'construct' call for types with potentially-throwing destructive moves.
4275 Vector_PushProctor<VALUE_TYPE, ALLOCATOR> guard(pos, this->allocatorRef());
4276 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4277 this->d_dataBegin_p,
4278 this->d_dataEnd_p,
4279 this->allocatorRef());
4280 guard.release(); // Nothing after this can throw
4281
4282 this->d_dataEnd_p = this->d_dataBegin_p;
4283 temp.d_dataEnd_p = ++pos;
4284 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4285}
4286
4287// CREATORS
4288
4289 // *** construct/copy/destroy ***
4290
4291template <class VALUE_TYPE, class ALLOCATOR>
4292inline
4293vector<VALUE_TYPE, ALLOCATOR>::vector() BSLS_KEYWORD_NOEXCEPT
4294: vectorBase<VALUE_TYPE>()
4295, ContainerBase(ALLOCATOR())
4296{
4297}
4298
4299template <class VALUE_TYPE, class ALLOCATOR>
4300inline
4301vector<VALUE_TYPE, ALLOCATOR>::vector(const ALLOCATOR& basicAllocator)
4303: vectorBase<VALUE_TYPE>()
4304, ContainerBase(basicAllocator)
4305{
4306}
4307
4308template <class VALUE_TYPE, class ALLOCATOR>
4309vector<VALUE_TYPE, ALLOCATOR>::vector(size_type initialSize,
4310 const ALLOCATOR& basicAllocator)
4311: vectorBase<VALUE_TYPE>()
4312, ContainerBase(basicAllocator)
4313{
4314 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(initialSize > max_size())) {
4316 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4317 "vector<...>::vector(n,v): vector too long");
4318 }
4319 if (initialSize > 0) {
4320 privateReserveEmpty(initialSize);
4321 Proctor proctor(this->d_dataBegin_p,
4322 this->d_capacity,
4323 static_cast<ContainerBase *>(this));
4324
4325 ArrayPrimitives::defaultConstruct(this->d_dataBegin_p,
4326 initialSize,
4327 this->allocatorRef());
4328
4329 proctor.release();
4330 this->d_dataEnd_p += initialSize;
4331 }
4332}
4333
4334template <class VALUE_TYPE, class ALLOCATOR>
4335vector<VALUE_TYPE, ALLOCATOR>::vector(size_type initialSize,
4336 const VALUE_TYPE& value,
4337 const ALLOCATOR& basicAllocator)
4338: vectorBase<VALUE_TYPE>()
4339, ContainerBase(basicAllocator)
4340{
4341 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(initialSize > max_size())) {
4343 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4344 "vector<...>::vector(n,v): vector too long");
4345 }
4346 if (initialSize > 0) {
4347 privateReserveEmpty(initialSize);
4348 Proctor proctor(this->d_dataBegin_p,
4349 this->d_capacity,
4350 static_cast<ContainerBase *>(this));
4351
4352 ArrayPrimitives::uninitializedFillN(this->d_dataBegin_p,
4353 initialSize,
4354 value,
4355 this->allocatorRef());
4356
4357 proctor.release();
4358 this->d_dataEnd_p += initialSize;
4359 }
4360}
4361
4362template <class VALUE_TYPE, class ALLOCATOR>
4363template <class INPUT_ITER>
4365vector<VALUE_TYPE, ALLOCATOR>::vector(INPUT_ITER first,
4366 INPUT_ITER last,
4367 const ALLOCATOR& basicAllocator)
4368: vectorBase<VALUE_TYPE>()
4369, ContainerBase(basicAllocator)
4370{
4371 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
4372
4373 typedef typename Vector_DeduceIteratorCategory<INPUT_ITER>::type Tag;
4374
4375 if (is_same<Tag, BloombergLP::bslmf::Nil>::value || first != last) {
4376 // Range-check avoids allocating on an empty sequence.
4377 constructFromRange(first, last, Tag());
4378 }
4379}
4380
4381template <class VALUE_TYPE, class ALLOCATOR>
4382vector<VALUE_TYPE, ALLOCATOR>::vector(const vector& original)
4383: vectorBase<VALUE_TYPE>()
4384, ContainerBase(AllocatorTraits::select_on_container_copy_construction(
4385 original.get_allocator()))
4386{
4387 if (original.size() > 0) {
4388 privateReserveEmpty(original.size());
4389 Proctor proctor(this->d_dataBegin_p,
4390 this->d_capacity,
4391 static_cast<ContainerBase *>(this));
4392
4393 ArrayPrimitives::copyConstruct(this->d_dataBegin_p,
4394 original.begin(),
4395 original.end(),
4396 this->allocatorRef());
4397
4398 proctor.release();
4399 this->d_dataEnd_p += original.size();
4400 }
4401}
4402
4403template <class VALUE_TYPE, class ALLOCATOR>
4404vector<VALUE_TYPE, ALLOCATOR>::
4405vector(const vector& original,
4406 const typename type_identity<ALLOCATOR>::type& basicAllocator)
4407: vectorBase<VALUE_TYPE>()
4408, ContainerBase(basicAllocator)
4409{
4410 if (original.size() > 0) {
4411 privateReserveEmpty(original.size());
4412 Proctor proctor(this->d_dataBegin_p,
4413 this->d_capacity,
4414 static_cast<ContainerBase *>(this));
4415
4416 ArrayPrimitives::copyConstruct(this->d_dataBegin_p,
4417 original.begin(),
4418 original.end(),
4419 this->allocatorRef());
4420
4421 proctor.release();
4422 this->d_dataEnd_p += original.size();
4423 }
4424}
4425
4426template <class VALUE_TYPE, class ALLOCATOR>
4427vector<VALUE_TYPE, ALLOCATOR>::vector(
4428 BloombergLP::bslmf::MovableRef<vector> original)
4430: vectorBase<VALUE_TYPE>()
4431, ContainerBase(MoveUtil::access(original).get_allocator())
4432{
4433 vector& lvalue = original;
4434 ImpBase::adopt(MoveUtil::move(static_cast<ImpBase&>(lvalue)));
4435}
4436
4437template <class VALUE_TYPE, class ALLOCATOR>
4438vector<VALUE_TYPE, ALLOCATOR>::vector(
4439 BloombergLP::bslmf::MovableRef<vector> original,
4440 const typename type_identity<ALLOCATOR>::type& basicAllocator)
4441: vectorBase<VALUE_TYPE>()
4442, ContainerBase(basicAllocator)
4443{
4444 vector& lvalue = original;
4445
4446 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(get_allocator() ==
4447 lvalue.get_allocator())) {
4448 ImpBase::adopt(MoveUtil::move(static_cast<ImpBase&>(lvalue)));
4449 }
4450 else {
4451 if (lvalue.size() > 0) {
4452 privateReserveEmpty(lvalue.size());
4453 Proctor proctor(this->d_dataBegin_p,
4454 this->d_capacity,
4455 static_cast<ContainerBase *>(this));
4456
4457 ArrayPrimitives::moveConstruct(this->d_dataBegin_p,
4458 lvalue.begin(),
4459 lvalue.end(),
4460 this->allocatorRef());
4461
4462 proctor.release();
4463 this->d_dataEnd_p += lvalue.size();
4464 }
4465 }
4466}
4467
4468#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4469template <class VALUE_TYPE, class ALLOCATOR>
4470inline
4471vector<VALUE_TYPE, ALLOCATOR>::vector(
4472 std::initializer_list<VALUE_TYPE> values,
4473 const ALLOCATOR& basicAllocator)
4474: vectorBase<VALUE_TYPE>()
4475, ContainerBase(basicAllocator)
4476{
4477 if (values.begin() != values.end()) {
4478 constructFromRange(values.begin(),
4479 values.end(),
4480 std::random_access_iterator_tag());
4481 }
4482}
4483
4484#endif
4485
4486
4487template <class VALUE_TYPE, class ALLOCATOR>
4489vector<VALUE_TYPE, ALLOCATOR>::~vector()
4490{
4491 using BloombergLP::bslalg::ArrayDestructionPrimitives;
4492
4493 // suppress buggy warning in GCC 12 and later (DRQS 174259807)
4494#ifdef BSLS_PLATFORM_CMP_GNU
4495#pragma GCC diagnostic push
4496#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
4497#endif
4498 if (this->d_dataBegin_p) {
4499 ArrayDestructionPrimitives::destroy(this->d_dataBegin_p,
4500 this->d_dataEnd_p,
4501 this->allocatorRef());
4502 AllocatorUtil::deallocateObject(this->allocatorRef(),
4503 this->d_dataBegin_p, this->d_capacity);
4504 }
4505#ifdef BSLS_PLATFORM_CMP_GNU
4506#pragma GCC diagnostic pop
4507#endif
4508}
4509
4510// MANIPULATORS
4511template <class VALUE_TYPE, class ALLOCATOR>
4512vector<VALUE_TYPE, ALLOCATOR>&
4513vector<VALUE_TYPE, ALLOCATOR>::operator=(const vector& rhs)
4514{
4515 typedef typename
4516 AllocatorTraits::propagate_on_container_copy_assignment Propagate;
4517
4518 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this != &rhs)) {
4519 if (Propagate::value) {
4520 vector other(rhs, rhs.get_allocator());
4521 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
4522 AllocatorUtil::swap(&this->allocatorRef(),
4523 &other.allocatorRef(),
4524 Propagate());
4525 }
4526 else {
4527 // Invoke 'erase' only if the current vector is not empty.
4528 if (!this->empty()) {
4529 erase(this->begin(), this->end());
4530 }
4531 insert(this->begin(), rhs.begin(), rhs.end());
4532 }
4533 }
4534 return *this;
4535}
4536
4537template <class VALUE_TYPE, class ALLOCATOR>
4538vector<VALUE_TYPE, ALLOCATOR>& vector<VALUE_TYPE, ALLOCATOR>::operator=(
4539 BloombergLP::bslmf::MovableRef<vector<VALUE_TYPE, ALLOCATOR> > rhs)
4541 AllocatorTraits::propagate_on_container_move_assignment::value ||
4542 AllocatorTraits::is_always_equal::value)
4543{
4544 typedef typename
4545 AllocatorTraits::propagate_on_container_move_assignment Propagate;
4546
4547 vector& lvalue = rhs;
4548 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this != &lvalue)) {
4549 if (get_allocator() == lvalue.get_allocator()) {
4550 vector other(MoveUtil::move(lvalue));
4551 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
4552 }
4553 else if (Propagate::value) {
4554 vector other(MoveUtil::move(lvalue));
4555 AllocatorUtil::swap(&this->allocatorRef(),
4556 &other.allocatorRef(),
4557 Propagate());
4558 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
4559 }
4560 else {
4561 vector other(MoveUtil::move(lvalue), this->allocatorRef());
4562 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
4563 }
4564 }
4565 return *this;
4566}
4567
4568#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
4569template <class VALUE_TYPE, class ALLOCATOR>
4570inline
4571vector<VALUE_TYPE, ALLOCATOR>&
4572vector<VALUE_TYPE, ALLOCATOR>::operator=(
4573 std::initializer_list<VALUE_TYPE> values)
4574{
4575 this->assign(values.begin(), values.end());
4576 return *this;
4577}
4578
4579template <class VALUE_TYPE, class ALLOCATOR>
4580inline
4581void vector<VALUE_TYPE, ALLOCATOR>::assign(
4582 std::initializer_list<VALUE_TYPE> values)
4583{
4584 assign(values.begin(), values.end());
4585}
4586#endif
4587
4588template <class VALUE_TYPE, class ALLOCATOR>
4589template <class INPUT_ITER>
4590inline
4591void vector<VALUE_TYPE, ALLOCATOR>::assign(INPUT_ITER first, INPUT_ITER last)
4592{
4593 BSLS_ASSERT_SAFE(!Vector_RangeCheck::isInvalidRange(first, last));
4594
4595 if (!this->empty()) {
4596 erase(this->begin(), this->end());
4597 }
4598
4599 insert(this->begin(), first, last);
4600}
4601
4602template <class VALUE_TYPE, class ALLOCATOR>
4603inline
4604void vector<VALUE_TYPE, ALLOCATOR>::assign(size_type numElements,
4605 const VALUE_TYPE& value)
4606{
4607 if (!this->empty()) {
4608 erase(this->begin(), this->end());
4609 }
4610 insert(this->begin(), numElements, value);
4611}
4612
4613
4614 // *** capacity ***
4615
4616template <class VALUE_TYPE, class ALLOCATOR>
4617void vector<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize)
4618{
4619 // This function provides the *strong* exception guarantee (except when
4620 // the move constructor of a non-copy-insertable 'value_type' throws).
4621
4622 // Cannot use copy constructor since the only requirements on 'VALUE_TYPE'
4623 // are 'move-insertable' and 'default-constructible'.
4624
4625 if (newSize <= this->size()) {
4626 BloombergLP::bslalg::ArrayDestructionPrimitives::destroy(
4627 this->d_dataBegin_p + newSize,
4628 this->d_dataEnd_p,
4629 this->allocatorRef());
4630 this->d_dataEnd_p = this->d_dataBegin_p + newSize;
4631 }
4632 else if (0 == this->d_capacity) {
4633 // Because of {DRQS 99966534}, we check for zero capacity here and
4634 // handle it separately rather than falling into the case below.
4635 vector temp(newSize, this->get_allocator());
4636 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4637 }
4638 else if (newSize > this->d_capacity) {
4639 const size_type maxSize = max_size();
4640 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(newSize > maxSize)) {
4642 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4643 "vector<...>::resize(n): vector too long");
4644 }
4645
4646 size_type newCapacity = Vector_Util::computeNewCapacity(
4647 newSize, this->d_capacity, maxSize);
4648
4649 vector temp(this->get_allocator());
4650 temp.privateReserveEmpty(newCapacity);
4651
4652 ArrayPrimitives::destructiveMoveAndInsert(temp.d_dataBegin_p,
4653 &this->d_dataEnd_p,
4654 this->d_dataBegin_p,
4655 this->d_dataEnd_p,
4656 this->d_dataEnd_p,
4657 newSize - this->size(),
4658 this->allocatorRef());
4659
4660 temp.d_dataEnd_p += newSize;
4661 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4662 }
4663 else {
4664 ArrayPrimitives::defaultConstruct(this->d_dataEnd_p,
4665 newSize - this->size(),
4666 this->allocatorRef());
4667 this->d_dataEnd_p = this->d_dataBegin_p + newSize;
4668 }
4669}
4670
4671template <class VALUE_TYPE, class ALLOCATOR>
4672void vector<VALUE_TYPE, ALLOCATOR>::resize(size_type newSize,
4673 const VALUE_TYPE& value)
4674{
4675 // This function provides the *strong* exception guarantee (except when
4676 // the move constructor of a non-copy-insertable 'value_type' throws).
4677
4678 if (newSize <= this->size()) {
4679 BloombergLP::bslalg::ArrayDestructionPrimitives::destroy(
4680 this->d_dataBegin_p + newSize,
4681 this->d_dataEnd_p,
4682 this->allocatorRef());
4683 this->d_dataEnd_p = this->d_dataBegin_p + newSize;
4684 }
4685 else {
4686 insert(this->d_dataEnd_p, newSize - this->size(), value);
4687 }
4688}
4689
4690template <class VALUE_TYPE, class ALLOCATOR>
4691void vector<VALUE_TYPE, ALLOCATOR>::reserve(size_type newCapacity)
4692{
4693 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(newCapacity > max_size())) {
4695 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
4696 "vector<...>::reserve(newCapacity): vector too long");
4697 }
4698 if (0 == this->d_capacity && 0 != newCapacity) {
4699 privateReserveEmpty(newCapacity);
4700 }
4701 else if (this->d_capacity < newCapacity) {
4702 vector temp(this->get_allocator());
4703 temp.privateReserveEmpty(newCapacity);
4704
4705 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4706 this->d_dataBegin_p,
4707 this->d_dataEnd_p,
4708 this->allocatorRef());
4709
4710 temp.d_dataEnd_p += this->size();
4711 this->d_dataEnd_p = this->d_dataBegin_p;
4712 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4713 }
4714}
4715
4716template <class VALUE_TYPE, class ALLOCATOR>
4717void vector<VALUE_TYPE, ALLOCATOR>::shrink_to_fit()
4718{
4719 if (this->size() < this->d_capacity) {
4720 vector temp(this->get_allocator());
4721 if (this->size() > 0) {
4722 temp.privateReserveEmpty(this->size());
4723 ArrayPrimitives::destructiveMove(temp.d_dataBegin_p,
4724 this->d_dataBegin_p,
4725 this->d_dataEnd_p,
4726 this->allocatorRef());
4727
4728 temp.d_dataEnd_p += this->size();
4729 this->d_dataEnd_p = this->d_dataBegin_p;
4730 }
4731 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
4732 }
4733}
4734
4735 // *** modifiers ***
4736
4737#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4738// {{{ BEGIN GENERATED CODE
4739// Command line: sim_cpp11_features.pl bslstl_vector.h
4740#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT
4741#define BSLSTL_VECTOR_VARIADIC_LIMIT 10
4742#endif
4743#ifndef BSLSTL_VECTOR_VARIADIC_LIMIT_E
4744#define BSLSTL_VECTOR_VARIADIC_LIMIT_E BSLSTL_VECTOR_VARIADIC_LIMIT
4745#endif
4746#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 0
4747template <class VALUE_TYPE, class ALLOCATOR>
4748inline
4749VALUE_TYPE &
4750vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4751 )
4752{
4753 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4754 AllocatorTraits::construct(
4755 this->allocatorRef(),
4756 this->d_dataEnd_p);
4757 ++this->d_dataEnd_p;
4758 }
4759 else {
4760 privateEmplaceBackWithAllocation(
4761 );
4762 }
4763 return *(this->d_dataEnd_p - 1);
4764}
4765#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 0
4766
4767#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 1
4768template <class VALUE_TYPE, class ALLOCATOR>
4769template <class Args_01>
4770inline
4771VALUE_TYPE &
4772vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4773 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
4774{
4775 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4776 AllocatorTraits::construct(
4777 this->allocatorRef(),
4778 this->d_dataEnd_p,
4779 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
4780 ++this->d_dataEnd_p;
4781 }
4782 else {
4783 privateEmplaceBackWithAllocation(
4784 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01));
4785 }
4786 return *(this->d_dataEnd_p - 1);
4787}
4788#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 1
4789
4790#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 2
4791template <class VALUE_TYPE, class ALLOCATOR>
4792template <class Args_01,
4793 class Args_02>
4794inline
4795VALUE_TYPE &
4796vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4797 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4798 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
4799{
4800 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4801 AllocatorTraits::construct(
4802 this->allocatorRef(),
4803 this->d_dataEnd_p,
4804 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4805 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
4806 ++this->d_dataEnd_p;
4807 }
4808 else {
4809 privateEmplaceBackWithAllocation(
4810 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4811 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02));
4812 }
4813 return *(this->d_dataEnd_p - 1);
4814}
4815#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 2
4816
4817#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 3
4818template <class VALUE_TYPE, class ALLOCATOR>
4819template <class Args_01,
4820 class Args_02,
4821 class Args_03>
4822inline
4823VALUE_TYPE &
4824vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4825 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4826 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4827 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
4828{
4829 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4830 AllocatorTraits::construct(
4831 this->allocatorRef(),
4832 this->d_dataEnd_p,
4833 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4834 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4835 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
4836 ++this->d_dataEnd_p;
4837 }
4838 else {
4839 privateEmplaceBackWithAllocation(
4840 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4841 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4842 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03));
4843 }
4844 return *(this->d_dataEnd_p - 1);
4845}
4846#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 3
4847
4848#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 4
4849template <class VALUE_TYPE, class ALLOCATOR>
4850template <class Args_01,
4851 class Args_02,
4852 class Args_03,
4853 class Args_04>
4854inline
4855VALUE_TYPE &
4856vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4857 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4858 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4859 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4860 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
4861{
4862 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4863 AllocatorTraits::construct(
4864 this->allocatorRef(),
4865 this->d_dataEnd_p,
4866 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4867 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4868 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4869 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
4870 ++this->d_dataEnd_p;
4871 }
4872 else {
4873 privateEmplaceBackWithAllocation(
4874 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4875 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4876 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4877 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04));
4878 }
4879 return *(this->d_dataEnd_p - 1);
4880}
4881#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 4
4882
4883#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 5
4884template <class VALUE_TYPE, class ALLOCATOR>
4885template <class Args_01,
4886 class Args_02,
4887 class Args_03,
4888 class Args_04,
4889 class Args_05>
4890inline
4891VALUE_TYPE &
4892vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4893 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4894 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4895 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4896 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4897 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
4898{
4899 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4900 AllocatorTraits::construct(
4901 this->allocatorRef(),
4902 this->d_dataEnd_p,
4903 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4904 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4905 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4906 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4907 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4908 ++this->d_dataEnd_p;
4909 }
4910 else {
4911 privateEmplaceBackWithAllocation(
4912 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4913 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4914 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4915 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4916 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05));
4917 }
4918 return *(this->d_dataEnd_p - 1);
4919}
4920#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 5
4921
4922#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 6
4923template <class VALUE_TYPE, class ALLOCATOR>
4924template <class Args_01,
4925 class Args_02,
4926 class Args_03,
4927 class Args_04,
4928 class Args_05,
4929 class Args_06>
4930inline
4931VALUE_TYPE &
4932vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4933 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4934 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4935 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4936 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4937 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4938 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
4939{
4940 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4941 AllocatorTraits::construct(
4942 this->allocatorRef(),
4943 this->d_dataEnd_p,
4944 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4945 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4946 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4947 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4948 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4949 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4950 ++this->d_dataEnd_p;
4951 }
4952 else {
4953 privateEmplaceBackWithAllocation(
4954 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4955 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4956 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4957 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4958 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4959 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06));
4960 }
4961 return *(this->d_dataEnd_p - 1);
4962}
4963#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 6
4964
4965#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 7
4966template <class VALUE_TYPE, class ALLOCATOR>
4967template <class Args_01,
4968 class Args_02,
4969 class Args_03,
4970 class Args_04,
4971 class Args_05,
4972 class Args_06,
4973 class Args_07>
4974inline
4975VALUE_TYPE &
4976vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
4977 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
4978 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
4979 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
4980 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
4981 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
4982 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
4983 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
4984{
4985 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
4986 AllocatorTraits::construct(
4987 this->allocatorRef(),
4988 this->d_dataEnd_p,
4989 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
4990 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
4991 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
4992 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
4993 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
4994 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
4995 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
4996 ++this->d_dataEnd_p;
4997 }
4998 else {
4999 privateEmplaceBackWithAllocation(
5000 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5001 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5002 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5003 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5004 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5005 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5006 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07));
5007 }
5008 return *(this->d_dataEnd_p - 1);
5009}
5010#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 7
5011
5012#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 8
5013template <class VALUE_TYPE, class ALLOCATOR>
5014template <class Args_01,
5015 class Args_02,
5016 class Args_03,
5017 class Args_04,
5018 class Args_05,
5019 class Args_06,
5020 class Args_07,
5021 class Args_08>
5022inline
5023VALUE_TYPE &
5024vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
5025 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5026 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5027 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5028 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5029 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5030 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5031 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5032 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
5033{
5034 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5035 AllocatorTraits::construct(
5036 this->allocatorRef(),
5037 this->d_dataEnd_p,
5038 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5039 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5040 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5041 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5042 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5043 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5044 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5045 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5046 ++this->d_dataEnd_p;
5047 }
5048 else {
5049 privateEmplaceBackWithAllocation(
5050 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5051 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5052 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5053 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5054 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5055 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5056 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5057 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08));
5058 }
5059 return *(this->d_dataEnd_p - 1);
5060}
5061#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 8
5062
5063#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 9
5064template <class VALUE_TYPE, class ALLOCATOR>
5065template <class Args_01,
5066 class Args_02,
5067 class Args_03,
5068 class Args_04,
5069 class Args_05,
5070 class Args_06,
5071 class Args_07,
5072 class Args_08,
5073 class Args_09>
5074inline
5075VALUE_TYPE &
5076vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
5077 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5078 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5079 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5080 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5081 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5082 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5083 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5084 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
5085 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
5086{
5087 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5088 AllocatorTraits::construct(
5089 this->allocatorRef(),
5090 this->d_dataEnd_p,
5091 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5092 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5093 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5094 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5095 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5096 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5097 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5098 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5099 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5100 ++this->d_dataEnd_p;
5101 }
5102 else {
5103 privateEmplaceBackWithAllocation(
5104 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5105 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5106 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5107 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5108 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5109 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5110 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5111 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5112 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09));
5113 }
5114 return *(this->d_dataEnd_p - 1);
5115}
5116#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 9
5117
5118#if BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 10
5119template <class VALUE_TYPE, class ALLOCATOR>
5120template <class Args_01,
5121 class Args_02,
5122 class Args_03,
5123 class Args_04,
5124 class Args_05,
5125 class Args_06,
5126 class Args_07,
5127 class Args_08,
5128 class Args_09,
5129 class Args_10>
5130inline
5131VALUE_TYPE &
5132vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
5133 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
5134 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
5135 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
5136 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
5137 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
5138 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
5139 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
5140 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
5141 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
5142 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
5143{
5144 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5145 AllocatorTraits::construct(
5146 this->allocatorRef(),
5147 this->d_dataEnd_p,
5148 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5149 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5150 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5151 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5152 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5153 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5154 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5155 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5156 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
5157 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
5158 ++this->d_dataEnd_p;
5159 }
5160 else {
5161 privateEmplaceBackWithAllocation(
5162 BSLS_COMPILERFEATURES_FORWARD(Args_01, arguments_01),
5163 BSLS_COMPILERFEATURES_FORWARD(Args_02, arguments_02),
5164 BSLS_COMPILERFEATURES_FORWARD(Args_03, arguments_03),
5165 BSLS_COMPILERFEATURES_FORWARD(Args_04, arguments_04),
5166 BSLS_COMPILERFEATURES_FORWARD(Args_05, arguments_05),
5167 BSLS_COMPILERFEATURES_FORWARD(Args_06, arguments_06),
5168 BSLS_COMPILERFEATURES_FORWARD(Args_07, arguments_07),
5169 BSLS_COMPILERFEATURES_FORWARD(Args_08, arguments_08),
5170 BSLS_COMPILERFEATURES_FORWARD(Args_09, arguments_09),
5171 BSLS_COMPILERFEATURES_FORWARD(Args_10, arguments_10));
5172 }
5173 return *(this->d_dataEnd_p - 1);
5174}
5175#endif // BSLSTL_VECTOR_VARIADIC_LIMIT_E >= 10
5176
5177#else
5178// The generated code below is a workaround for the absence of perfect
5179// forwarding in some compilers.
5180template <class VALUE_TYPE, class ALLOCATOR>
5181template <class... Args>
5182inline
5183VALUE_TYPE &
5184vector<VALUE_TYPE, ALLOCATOR>::emplace_back(
5185 BSLS_COMPILERFEATURES_FORWARD_REF(Args)...arguments)
5186{
5187 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5188 AllocatorTraits::construct(
5189 this->allocatorRef(),
5190 this->d_dataEnd_p,
5191 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
5192 ++this->d_dataEnd_p;
5193 }
5194 else {
5195 privateEmplaceBackWithAllocation(
5196 BSLS_COMPILERFEATURES_FORWARD(Args, arguments)...);
5197 }
5198 return *(this->d_dataEnd_p - 1);
5199}
5200// }}} END GENERATED CODE
5201#endif
5202
5203template <class VALUE_TYPE, class ALLOCATOR>
5204inline
5205void vector<VALUE_TYPE, ALLOCATOR>::push_back(const VALUE_TYPE& value)
5206{
5207 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5208 AllocatorTraits::construct(this->allocatorRef(),
5209 this->d_dataEnd_p,
5210 value);
5211 ++this->d_dataEnd_p;
5212 }
5213 else {
5214 privatePushBackWithAllocation(value);
5215 }
5216}
5217
5218template <class VALUE_TYPE, class ALLOCATOR>
5219inline
5220void vector<VALUE_TYPE, ALLOCATOR>::push_back(
5221 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value)
5222{
5223 VALUE_TYPE& lvalue = value;
5224 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(this->d_capacity > this->size())) {
5225 AllocatorTraits::construct(this->allocatorRef(),
5226 this->d_dataEnd_p,
5227 MoveUtil::move(lvalue));
5228 ++this->d_dataEnd_p;
5229 }
5230 else {
5231 privatePushBackWithAllocation(MoveUtil::move(lvalue));
5232 }
5233}
5234
5235template <class VALUE_TYPE, class ALLOCATOR>
5236inline
5237void vector<VALUE_TYPE, ALLOCATOR>::pop_back()
5238{
5239 BSLS_ASSERT_SAFE(!this->empty());
5240
5241 AllocatorTraits::destroy(this->allocatorRef(),
5242 --this->d_dataEnd_p);
5243}
5244
5245template <class VALUE_TYPE, class ALLOCATOR>
5246inline
5247typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5248vector<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
5249 const VALUE_TYPE& value)
5250{
5251 BSLS_ASSERT_SAFE(this->begin() <= position);
5252 BSLS_ASSERT_SAFE(position <= this->end());
5253
5254 return insert(position, size_type(1), value);
5255}
5256
5257template <class VALUE_TYPE, class ALLOCATOR>
5258typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5259vector<VALUE_TYPE, ALLOCATOR>::insert(
5260 const_iterator position,
5261 BloombergLP::bslmf::MovableRef<VALUE_TYPE> value)
5262{
5263 BSLS_ASSERT_SAFE(this->begin() <= position);
5264 BSLS_ASSERT_SAFE(position <= this->end());
5265
5266 const size_type maxSize = max_size();
5267 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(1 > maxSize - this->size())) {
5269 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5270 "vector<...>::insert(pos,rv): vector too long");
5271 }
5272
5273 VALUE_TYPE& lvalue = value;
5274
5275 const size_type index = position - this->begin();
5276 const iterator& pos = const_cast<const iterator&>(position);
5277 const size_type newSize = this->size() + 1;
5278
5279 if (newSize > this->d_capacity) {
5280 size_type newCapacity = Vector_Util::computeNewCapacity(
5281 newSize,
5282 this->d_capacity,
5283 maxSize);
5284
5285 vector temp(this->get_allocator());
5286 temp.privateReserveEmpty(newCapacity);
5287
5288 ArrayPrimitives::destructiveMoveAndEmplace(temp.d_dataBegin_p,
5289 &this->d_dataEnd_p,
5290 this->d_dataBegin_p,
5291 pos,
5292 this->d_dataEnd_p,
5293 this->allocatorRef(),
5294 MoveUtil::move(lvalue));
5295
5296 temp.d_dataEnd_p += newSize;
5297 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
5298 }
5299 else {
5300 ArrayPrimitives::insert(pos,
5301 this->end(),
5302 MoveUtil::move(lvalue),
5303 this->allocatorRef());
5304 ++this->d_dataEnd_p;
5305 }
5306
5307 return this->begin() + index;
5308}
5309
5310template <class VALUE_TYPE, class ALLOCATOR>
5311typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5312vector<VALUE_TYPE, ALLOCATOR>::insert(const_iterator position,
5313 size_type numElements,
5314 const VALUE_TYPE& value)
5315{
5316 BSLS_ASSERT_SAFE(this->begin() <= position);
5317 BSLS_ASSERT_SAFE(position <= this->end());
5318
5319 const size_type maxSize = max_size();
5321 numElements > maxSize - this->size())) {
5323 BloombergLP::bslstl::StdExceptUtil::throwLengthError(
5324 "vector<...>::insert(pos,n,v): vector too long");
5325 }
5326
5327 const size_type index = position - this->begin();
5328 const iterator& pos = const_cast<const iterator&>(position);
5329 const size_type newSize = this->size() + numElements;
5330
5331 if (newSize > this->d_capacity) {
5332 size_type newCapacity = Vector_Util::computeNewCapacity(
5333 newSize,
5334 this->d_capacity,
5335 maxSize);
5336
5337 vector temp(this->get_allocator());
5338 temp.privateReserveEmpty(newCapacity);
5339
5340 ArrayPrimitives::destructiveMoveAndInsert(temp.d_dataBegin_p,
5341 &this->d_dataEnd_p,
5342 this->d_dataBegin_p,
5343 pos,
5344 this->d_dataEnd_p,
5345 value,
5346 numElements,
5347 this->allocatorRef());
5348
5349 temp.d_dataEnd_p += newSize;
5350 Vector_Util::swap(&this->d_dataBegin_p, &temp.d_dataBegin_p);
5351 }
5352 else {
5353 ArrayPrimitives::insert(pos,
5354 this->end(),
5355 value,
5356 numElements,
5357 this->allocatorRef());
5358 this->d_dataEnd_p += numElements;
5359 }
5360 return this->begin() + index;
5361}
5362
5363#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5364template <class VALUE_TYPE, class ALLOCATOR>
5365inline
5366typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5367vector<VALUE_TYPE, ALLOCATOR>::insert(
5368 const_iterator position,
5369 std::initializer_list<VALUE_TYPE> values)
5370{
5371 return insert(position, values.begin(), values.end());
5372}
5373#endif
5374
5375template <class VALUE_TYPE, class ALLOCATOR>
5376inline
5377typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5378vector<VALUE_TYPE, ALLOCATOR>::erase(const_iterator position)
5379{
5380 BSLS_ASSERT_SAFE(this->begin() <= position);
5381 BSLS_ASSERT_SAFE(position < this->end());
5382
5383 return erase(position, position + 1);
5384}
5385
5386// This should not be inlined by default due to an XLC 16 compiler bug whereby
5387// optimized code can spuriously core dump. This has been reported to IBM, see
5388// DRQS 169655225 for details.
5389template <class VALUE_TYPE, class ALLOCATOR>
5391typename vector<VALUE_TYPE, ALLOCATOR>::iterator
5392vector<VALUE_TYPE, ALLOCATOR>::erase(const_iterator first, const_iterator last)
5393{
5394 BSLS_ASSERT_SAFE(this->begin() <= first);
5395 BSLS_ASSERT_SAFE(first <= this->end());
5396 BSLS_ASSERT_SAFE(first <= last);
5397 BSLS_ASSERT_SAFE(last <= this->end());
5398
5399 const size_type n = last - first;
5400 ArrayPrimitives::erase(const_cast<VALUE_TYPE *>(first),
5401 const_cast<VALUE_TYPE *>(last),
5402 this->d_dataEnd_p,
5403 this->allocatorRef());
5404 this->d_dataEnd_p -= n;
5405 return const_cast<VALUE_TYPE *>(first);
5406}
5407
5408template <class VALUE_TYPE, class ALLOCATOR>
5409void vector<VALUE_TYPE, ALLOCATOR>::swap(vector<VALUE_TYPE, ALLOCATOR>& other)
5411 AllocatorTraits::propagate_on_container_swap::value ||
5412 AllocatorTraits::is_always_equal::value)
5413{
5414 typedef typename
5415 AllocatorTraits::propagate_on_container_swap Propagate;
5416
5417 if (Propagate::value) {
5418 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
5419 AllocatorUtil::swap(&this->allocatorRef(),
5420 &other.allocatorRef(),
5421 Propagate());
5422 }
5423 else {
5425 this->get_allocator() == other.get_allocator())) {
5426 Vector_Util::swap(&this->d_dataBegin_p, &other.d_dataBegin_p);
5427 }
5428 else {
5430
5431 vector toOtherCopy(MoveUtil::move(*this),
5432 other.get_allocator());
5433 vector toThisCopy( MoveUtil::move(other),
5434 this->get_allocator());
5435
5436 Vector_Util::swap(&toOtherCopy.d_dataBegin_p,
5437 &other.d_dataBegin_p);
5438 Vector_Util::swap(&toThisCopy. d_dataBegin_p,
5439 &this->d_dataBegin_p);
5440 }
5441 }
5442}
5443
5444template <class VALUE_TYPE, class ALLOCATOR>
5445inline
5446void vector<VALUE_TYPE, ALLOCATOR>::clear() BSLS_KEYWORD_NOEXCEPT
5447{
5449 BloombergLP::bslalg::ArrayDestructionPrimitives::destroy(
5450 this->d_dataBegin_p,
5451 this->d_dataEnd_p,
5452 this->allocatorRef());
5453 this->d_dataEnd_p = this->d_dataBegin_p;
5454 }
5455 else {
5457 }
5458}
5459
5460// ACCESSORS
5461template <class VALUE_TYPE, class ALLOCATOR>
5462inline
5463typename vector<VALUE_TYPE, ALLOCATOR>::allocator_type
5464vector<VALUE_TYPE, ALLOCATOR>::get_allocator() const BSLS_KEYWORD_NOEXCEPT
5465{
5466 return this->allocatorRef();
5467}
5468
5469 // *** capacity ***
5470
5471template <class VALUE_TYPE, class ALLOCATOR>
5472inline
5473typename vector<VALUE_TYPE, ALLOCATOR>::size_type
5474vector<VALUE_TYPE, ALLOCATOR>::max_size() const BSLS_KEYWORD_NOEXCEPT
5475{
5476 return AllocatorTraits::max_size(this->allocatorRef());
5477}
5478
5479// FREE OPERATORS
5480
5481 // *** relational operators ***
5482
5483template <class VALUE_TYPE, class ALLOCATOR>
5484inline
5485bool operator==(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5486 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5487{
5488 return BloombergLP::bslalg::RangeCompare::equal(lhs.begin(),
5489 lhs.end(),
5490 lhs.size(),
5491 rhs.begin(),
5492 rhs.end(),
5493 rhs.size());
5494}
5495
5496#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
5497template <class VALUE_TYPE, class ALLOCATOR>
5498inline
5499bool operator!=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5500 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5501{
5502 return ! (lhs == rhs);
5503}
5504#endif // BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
5505
5506#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
5507
5508template <class VALUE_TYPE, class ALLOCATOR>
5509inline
5510BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE_TYPE> operator<=>(
5511 const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5512 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5513{
5514 return lexicographical_compare_three_way(
5515 lhs.begin(),
5516 lhs.end(),
5517 rhs.begin(),
5518 rhs.end(),
5519 BloombergLP::bslalg::SynthThreeWayUtil::compare);
5520}
5521
5522#else
5523
5524template <class VALUE_TYPE, class ALLOCATOR>
5525inline
5526bool operator< (const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5527 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5528{
5529 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(lhs.begin(),
5530 lhs.end(),
5531 lhs.size(),
5532 rhs.begin(),
5533 rhs.end(),
5534 rhs.size());
5535}
5536
5537template <class VALUE_TYPE, class ALLOCATOR>
5538inline
5539bool operator> (const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5540 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5541{
5542 return rhs < lhs;
5543}
5544
5545template <class VALUE_TYPE, class ALLOCATOR>
5546inline
5547bool operator<=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5548 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5549{
5550 return !(rhs < lhs);
5551}
5552
5553template <class VALUE_TYPE, class ALLOCATOR>
5554inline
5555bool operator>=(const vector<VALUE_TYPE, ALLOCATOR>& lhs,
5556 const vector<VALUE_TYPE, ALLOCATOR>& rhs)
5557{
5558 return !(lhs < rhs);
5559}
5560
5561#endif // BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
5562
5563// FREE FUNCTIONS
5564
5565 // *** specialized algorithms ***
5566
5567template <class VALUE_TYPE, class ALLOCATOR, class BDE_OTHER_TYPE>
5568inline typename vector<VALUE_TYPE, ALLOCATOR>::size_type
5569erase(vector<VALUE_TYPE, ALLOCATOR>& vec, const BDE_OTHER_TYPE& value)
5570{
5571 typename vector<VALUE_TYPE, ALLOCATOR>::size_type oldSize = vec.size();
5572 vec.erase(bsl::remove(vec.begin(), vec.end(), value), vec.end());
5573 return oldSize - vec.size();
5574}
5575
5576template <class VALUE_TYPE, class ALLOCATOR, class PREDICATE>
5577inline typename vector<VALUE_TYPE, ALLOCATOR>::size_type
5578erase_if(vector<VALUE_TYPE, ALLOCATOR>& vec, PREDICATE predicate)
5579{
5580 typename vector<VALUE_TYPE, ALLOCATOR>::size_type oldSize = vec.size();
5581 vec.erase(bsl::remove_if(vec.begin(), vec.end(), predicate), vec.end());
5582 return oldSize - vec.size();
5583}
5584
5585template <class VALUE_TYPE, class ALLOCATOR>
5586inline
5587void swap(vector<VALUE_TYPE, ALLOCATOR>& a,
5588 vector<VALUE_TYPE, ALLOCATOR>& b)
5590 a.swap(b)))
5591{
5592 a.swap(b);
5593}
5594
5595// HASH SPECIALIZATIONS
5596template <class HASHALG, class VALUE_TYPE, class ALLOCATOR>
5597inline
5598void hashAppend(HASHALG& hashAlg, const vector<VALUE_TYPE, ALLOCATOR>& input)
5599{
5600 using ::BloombergLP::bslh::hashAppend;
5601 typedef typename vector<VALUE_TYPE, ALLOCATOR>::const_iterator ci_t;
5602 hashAppend(hashAlg, input.size());
5603 for (ci_t b = input.begin(), e = input.end(); b != e; ++b) {
5604 hashAppend(hashAlg, *b);
5605 }
5606}
5607
5608
5609 // -------------------------------------
5610 // class vector<VALUE_TYPE *, ALLOCATOR>
5611 // -------------------------------------
5612
5613 // *** construct/copy/destroy ***
5614
5615// CREATORS
5616template <class VALUE_TYPE, class ALLOCATOR>
5617inline
5618vector<VALUE_TYPE *, ALLOCATOR>::vector() BSLS_KEYWORD_NOEXCEPT
5619: d_impl()
5620{
5621}
5622
5623template <class VALUE_TYPE, class ALLOCATOR>
5624inline
5625vector<VALUE_TYPE *, ALLOCATOR>::vector(const ALLOCATOR& basicAllocator)
5627: d_impl(ImplAlloc(basicAllocator))
5628{
5629}
5630
5631template <class VALUE_TYPE, class ALLOCATOR>
5632inline
5633vector<VALUE_TYPE *, ALLOCATOR>::vector(size_type initialSize,
5634 const ALLOCATOR& basicAllocator)
5635: d_impl(initialSize, ImplAlloc(basicAllocator))
5636{
5637}
5638
5639template <class VALUE_TYPE, class ALLOCATOR>
5640inline
5641vector<VALUE_TYPE *, ALLOCATOR>::vector(size_type initialSize,
5642 VALUE_TYPE *value,
5643 const ALLOCATOR& basicAllocator)
5644: d_impl(initialSize, (UintPtr) value, ImplAlloc(basicAllocator))
5645{
5646}
5647
5648template <class VALUE_TYPE, class ALLOCATOR>
5649template <class INPUT_ITER>
5650inline
5651vector<VALUE_TYPE *, ALLOCATOR>::vector(INPUT_ITER first,
5652 INPUT_ITER last,
5653 const ALLOCATOR& basicAllocator)
5654: d_impl(typename vector_ForwardIteratorForPtrs<VALUE_TYPE, INPUT_ITER>::type(
5655 first),
5656 typename vector_ForwardIteratorForPtrs<VALUE_TYPE, INPUT_ITER>::type(
5657 last),
5658 basicAllocator)
5659{
5660}
5661
5662template <class VALUE_TYPE, class ALLOCATOR>
5663inline
5664vector<VALUE_TYPE *, ALLOCATOR>::vector(const vector& original)
5665: d_impl(original.d_impl)
5666{
5667}
5668
5669template <class VALUE_TYPE, class ALLOCATOR>
5670inline
5671vector<VALUE_TYPE *, ALLOCATOR>::vector(
5672 BloombergLP::bslmf::MovableRef<vector> original)
5674: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl))
5675{
5676}
5677
5678template <class VALUE_TYPE, class ALLOCATOR>
5679inline
5680vector<VALUE_TYPE *, ALLOCATOR>::vector(const vector& original,
5681 const typename type_identity<ALLOCATOR>::type& basicAllocator)
5682: d_impl(original.d_impl, ImplAlloc(basicAllocator))
5683{
5684}
5685
5686template <class VALUE_TYPE, class ALLOCATOR>
5687inline
5688vector<VALUE_TYPE *, ALLOCATOR>::vector(
5689 BloombergLP::bslmf::MovableRef<vector> original,
5690 const typename type_identity<ALLOCATOR>::type& basicAllocator)
5691: d_impl(MoveUtil::move(MoveUtil::access(original).d_impl),
5692 ImplAlloc(basicAllocator))
5693{
5694}
5695
5696#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5697template <class VALUE_TYPE, class ALLOCATOR>
5698inline
5699vector<VALUE_TYPE *, ALLOCATOR>::vector(
5700 std::initializer_list<VALUE_TYPE *> values,
5701 const ALLOCATOR& basicAllocator)
5702: d_impl(typename vector_ForwardIteratorForPtrs<
5703 VALUE_TYPE,
5704 typename std::initializer_list<VALUE_TYPE *>::const_iterator>::
5705 type(values.begin()),
5706 typename vector_ForwardIteratorForPtrs<
5707 VALUE_TYPE,
5708 typename std::initializer_list<VALUE_TYPE *>::const_iterator>::
5709 type(values.end()),
5710 basicAllocator)
5711{
5712}
5713#endif
5714
5715template <class VALUE_TYPE, class ALLOCATOR>
5716inline
5717vector<VALUE_TYPE *, ALLOCATOR>::~vector()
5718{
5719}
5720
5721// MANIPULATORS
5722template <class VALUE_TYPE, class ALLOCATOR>
5723inline
5724vector<VALUE_TYPE *, ALLOCATOR>& vector<VALUE_TYPE *, ALLOCATOR>::operator=(
5725 const vector& rhs)
5726{
5727 d_impl = rhs.d_impl;
5728 return *this;
5729}
5730
5731#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5732template <class VALUE_TYPE, class ALLOCATOR>
5733inline
5734vector<VALUE_TYPE *, ALLOCATOR>& vector<VALUE_TYPE *, ALLOCATOR>::operator=(
5735 std::initializer_list<VALUE_TYPE *> values)
5736{
5737 assign(values);
5738 return *this;
5739}
5740
5741template <class VALUE_TYPE, class ALLOCATOR>
5742inline
5743void vector<VALUE_TYPE *, ALLOCATOR>::assign(
5744 std::initializer_list<VALUE_TYPE *> values)
5745{
5746 typedef typename std::initializer_list<VALUE_TYPE *>::const_iterator
5747 InitIter;
5748
5749 typedef typename vector_ForwardIteratorForPtrs<VALUE_TYPE, InitIter>::type
5750 Iter;
5751
5752 d_impl.assign(Iter(values.begin()), Iter(values.end()));
5753}
5754#endif
5755
5756template <class VALUE_TYPE, class ALLOCATOR>
5757template <class INPUT_ITER>
5758inline
5759void vector<VALUE_TYPE *, ALLOCATOR>::assign(INPUT_ITER first, INPUT_ITER last)
5760{
5761 typedef typename vector_ForwardIteratorForPtrs<VALUE_TYPE,
5762 INPUT_ITER>::type Iter;
5763
5764 d_impl.assign(Iter(first), Iter(last));
5765}
5766
5767template <class VALUE_TYPE, class ALLOCATOR>
5768inline
5769void vector<VALUE_TYPE *, ALLOCATOR>::assign(size_type numElements,
5770 VALUE_TYPE *value)
5771{
5772 d_impl.assign(numElements, (UintPtr) value);
5773}
5774
5775 // *** iterators ***
5776
5777template <class VALUE_TYPE, class ALLOCATOR>
5778inline
5779typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5780vector<VALUE_TYPE *, ALLOCATOR>::begin() BSLS_KEYWORD_NOEXCEPT
5781{
5782 return (iterator) d_impl.begin();
5783}
5784
5785template <class VALUE_TYPE, class ALLOCATOR>
5786inline
5787typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5788vector<VALUE_TYPE *, ALLOCATOR>::end() BSLS_KEYWORD_NOEXCEPT
5789{
5790 return (iterator) d_impl.end();
5791}
5792
5793template <class VALUE_TYPE, class ALLOCATOR>
5794inline
5795typename vector<VALUE_TYPE *, ALLOCATOR>::reverse_iterator
5796vector<VALUE_TYPE *, ALLOCATOR>::rbegin() BSLS_KEYWORD_NOEXCEPT
5797{
5798 return reverse_iterator((iterator) d_impl.rbegin().base());
5799}
5800
5801template <class VALUE_TYPE, class ALLOCATOR>
5802inline
5803typename vector<VALUE_TYPE *, ALLOCATOR>::reverse_iterator
5804vector<VALUE_TYPE *, ALLOCATOR>::rend() BSLS_KEYWORD_NOEXCEPT
5805{
5806 return reverse_iterator((iterator) d_impl.rend().base());
5807}
5808
5809 // *** capacity ***
5810
5811template <class VALUE_TYPE, class ALLOCATOR>
5812inline
5813typename vector<VALUE_TYPE *, ALLOCATOR>::size_type
5814vector<VALUE_TYPE *, ALLOCATOR>::size() const BSLS_KEYWORD_NOEXCEPT
5815{
5816 return d_impl.size();
5817}
5818
5819template <class VALUE_TYPE, class ALLOCATOR>
5820inline
5821typename vector<VALUE_TYPE *, ALLOCATOR>::size_type
5822vector<VALUE_TYPE *, ALLOCATOR>::capacity() const BSLS_KEYWORD_NOEXCEPT
5823{
5824 return d_impl.capacity();
5825}
5826
5827template <class VALUE_TYPE, class ALLOCATOR>
5828inline
5829bool
5830vector<VALUE_TYPE *, ALLOCATOR>::empty() const BSLS_KEYWORD_NOEXCEPT
5831{
5832 return d_impl.empty();
5833}
5834
5835 // *** element access ***
5836
5837template <class VALUE_TYPE, class ALLOCATOR>
5838inline
5839typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5840vector<VALUE_TYPE *, ALLOCATOR>::operator[](size_type position)
5841{
5842 return (reference) d_impl.operator[](position);
5843}
5844
5845template <class VALUE_TYPE, class ALLOCATOR>
5846inline
5847typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5848vector<VALUE_TYPE *, ALLOCATOR>::at(size_type position)
5849{
5850 return (reference) d_impl.at(position);
5851}
5852
5853template <class VALUE_TYPE, class ALLOCATOR>
5854inline
5855typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5856vector<VALUE_TYPE *, ALLOCATOR>::front()
5857{
5858 return (reference) d_impl.front();
5859}
5860
5861template <class VALUE_TYPE, class ALLOCATOR>
5862inline
5863typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5864vector<VALUE_TYPE *, ALLOCATOR>::back()
5865{
5866 return (reference) d_impl.back();
5867}
5868
5869template <class VALUE_TYPE, class ALLOCATOR>
5870inline
5871VALUE_TYPE **vector<VALUE_TYPE *, ALLOCATOR>::data() BSLS_KEYWORD_NOEXCEPT
5872{
5873 return (VALUE_TYPE **) d_impl.data();
5874}
5875
5876 // *** capacity ***
5877
5878template <class VALUE_TYPE, class ALLOCATOR>
5879inline
5880void vector<VALUE_TYPE *, ALLOCATOR>::resize(size_type newLength)
5881{
5882 d_impl.resize(newLength);
5883}
5884
5885template <class VALUE_TYPE, class ALLOCATOR>
5886inline
5887void vector<VALUE_TYPE *, ALLOCATOR>::resize(size_type newLength,
5888 VALUE_TYPE *value)
5889{
5890 d_impl.resize(newLength, (UintPtr) value);
5891}
5892
5893template <class VALUE_TYPE, class ALLOCATOR>
5894inline
5895void vector<VALUE_TYPE *, ALLOCATOR>::reserve(size_type newCapacity)
5896{
5897 d_impl.reserve(newCapacity);
5898}
5899
5900template <class VALUE_TYPE, class ALLOCATOR>
5901inline
5902void vector<VALUE_TYPE *, ALLOCATOR>::shrink_to_fit()
5903{
5904 d_impl.shrink_to_fit();
5905}
5906
5907
5908 // *** modifiers ***
5909
5910template <class VALUE_TYPE, class ALLOCATOR>
5911inline
5912typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5913vector<VALUE_TYPE *, ALLOCATOR>::emplace_back()
5914{
5915 d_impl.emplace_back();
5916 return back();
5917}
5918
5919# if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5920template <class VALUE_TYPE, class ALLOCATOR>
5921template <class ARG>
5922inline
5923typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5924vector<VALUE_TYPE *, ALLOCATOR>::emplace_back(ARG&& arg)
5925{
5926 VALUE_TYPE *ptr(arg); // Support explicit conversion operators
5927 d_impl.emplace_back(reinterpret_cast<UintPtr>(ptr));
5928 return back();
5929}
5930# else
5931template <class VALUE_TYPE, class ALLOCATOR>
5932inline
5933typename vector<VALUE_TYPE *, ALLOCATOR>::reference
5934vector<VALUE_TYPE *, ALLOCATOR>::emplace_back(VALUE_TYPE *ptr)
5935{
5936 d_impl.emplace_back(reinterpret_cast<UintPtr>(ptr));
5937 return back();
5938}
5939# endif
5940
5941template <class VALUE_TYPE, class ALLOCATOR>
5942inline
5943void vector<VALUE_TYPE *, ALLOCATOR>::push_back(VALUE_TYPE *value)
5944{
5945 d_impl.emplace_back(reinterpret_cast<UintPtr>(value));
5946}
5947
5948template <class VALUE_TYPE, class ALLOCATOR>
5949inline
5950void vector<VALUE_TYPE *, ALLOCATOR>::pop_back()
5951{
5952 d_impl.pop_back();
5953}
5954
5955template <class VALUE_TYPE, class ALLOCATOR>
5956inline
5957typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5958vector<VALUE_TYPE *, ALLOCATOR>::emplace(const_iterator position)
5959{
5960 return (iterator) d_impl.emplace((const UintPtr*) position);
5961}
5962
5963# if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
5964template <class VALUE_TYPE, class ALLOCATOR>
5965template <class ARG>
5966inline
5967typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5968vector<VALUE_TYPE *, ALLOCATOR>::emplace(const_iterator position, ARG&& arg)
5969{
5970 VALUE_TYPE *ptr(arg); // Support explicit conversion operators
5971 return (iterator) d_impl.emplace((const UintPtr *)position,
5972 reinterpret_cast<UintPtr>(ptr));
5973}
5974# else
5975template <class VALUE_TYPE, class ALLOCATOR>
5976inline
5977typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5978vector<VALUE_TYPE *, ALLOCATOR>::emplace(const_iterator position,
5979 VALUE_TYPE *ptr)
5980{
5981 return (iterator) d_impl.emplace((const UintPtr*) position,
5982 reinterpret_cast<UintPtr>(ptr));
5983}
5984# endif
5985
5986template <class VALUE_TYPE, class ALLOCATOR>
5987inline
5988typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5989vector<VALUE_TYPE *, ALLOCATOR>::insert(const_iterator position,
5990 VALUE_TYPE *value)
5991{
5992 return (iterator) d_impl.emplace((const UintPtr*) position,
5993 reinterpret_cast<UintPtr>(value));
5994}
5995
5996template <class VALUE_TYPE, class ALLOCATOR>
5997inline
5998typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
5999vector<VALUE_TYPE *, ALLOCATOR>::insert(const_iterator position,
6000 size_type numElements,
6001 VALUE_TYPE *value)
6002{
6003 return (iterator) d_impl.insert(
6004 (const UintPtr *)position, numElements, (UintPtr)value);
6005}
6006
6007#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6008template <class VALUE_TYPE, class ALLOCATOR>
6009inline
6010typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
6011vector<VALUE_TYPE *, ALLOCATOR>::insert(
6012 const_iterator position,
6013 std::initializer_list<VALUE_TYPE *> values)
6014{
6015 typedef typename std::initializer_list<VALUE_TYPE *>::const_iterator
6016 InitIter;
6017
6018 typedef typename vector_ForwardIteratorForPtrs<VALUE_TYPE, InitIter>::type
6019 Iter;
6020
6021 return (iterator) d_impl.insert(
6022 (const UintPtr *)position, Iter(values.begin()), Iter(values.end()));
6023}
6024#endif
6025
6026template <class VALUE_TYPE, class ALLOCATOR>
6027inline
6028typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
6029vector<VALUE_TYPE *, ALLOCATOR>::erase(const_iterator position)
6030{
6031 return (iterator) d_impl.erase((const UintPtr*) position);
6032}
6033
6034template <class VALUE_TYPE, class ALLOCATOR>
6035inline
6036typename vector<VALUE_TYPE *, ALLOCATOR>::iterator
6037vector<VALUE_TYPE *, ALLOCATOR>::erase(const_iterator first,
6038 const_iterator last)
6039{
6040 return (iterator) d_impl.erase((const UintPtr*) first,
6041 (const UintPtr*) last);
6042}
6043
6044template <class VALUE_TYPE, class ALLOCATOR>
6045inline
6046void vector<VALUE_TYPE *, ALLOCATOR>::swap(
6047 vector<VALUE_TYPE *, ALLOCATOR>& other)
6049 d_impl.swap(other.d_impl)))
6050{
6051 d_impl.swap(other.d_impl);
6052}
6053
6054template <class VALUE_TYPE, class ALLOCATOR>
6055inline
6056void vector<VALUE_TYPE *, ALLOCATOR>::clear() BSLS_KEYWORD_NOEXCEPT
6057{
6058 d_impl.clear();
6059}
6060
6061// ACCESSORS
6062template <class VALUE_TYPE, class ALLOCATOR>
6063inline
6064typename vector<VALUE_TYPE *, ALLOCATOR>::allocator_type
6065vector<VALUE_TYPE *, ALLOCATOR>::get_allocator() const BSLS_KEYWORD_NOEXCEPT
6066{
6067 return ALLOCATOR(d_impl.get_allocator());
6068}
6069
6070template <class VALUE_TYPE, class ALLOCATOR>
6071inline
6072typename vector<VALUE_TYPE *, ALLOCATOR>::size_type
6073vector<VALUE_TYPE *, ALLOCATOR>::max_size() const BSLS_KEYWORD_NOEXCEPT
6074{
6075 return d_impl.max_size();
6076}
6077
6078
6079 // *** iterators ***
6080
6081template <class VALUE_TYPE, class ALLOCATOR>
6082inline
6083typename vector<VALUE_TYPE *, ALLOCATOR>::const_iterator
6084vector<VALUE_TYPE *, ALLOCATOR>::begin() const BSLS_KEYWORD_NOEXCEPT
6085{
6086 return (const_iterator) d_impl.begin();
6087}
6088
6089template <class VALUE_TYPE, class ALLOCATOR>
6090inline
6091typename vector<VALUE_TYPE *, ALLOCATOR>::const_iterator
6092vector<VALUE_TYPE *, ALLOCATOR>::cbegin() const BSLS_KEYWORD_NOEXCEPT
6093{
6094 return (const_iterator) d_impl.cbegin();
6095}
6096
6097template <class VALUE_TYPE, class ALLOCATOR>
6098inline
6099typename vector<VALUE_TYPE *, ALLOCATOR>::const_iterator
6100vector<VALUE_TYPE *, ALLOCATOR>::end() const BSLS_KEYWORD_NOEXCEPT
6101{
6102 return (const_iterator) d_impl.end();
6103}
6104
6105template <class VALUE_TYPE, class ALLOCATOR>
6106inline
6107typename vector<VALUE_TYPE *, ALLOCATOR>::const_iterator
6108vector<VALUE_TYPE *, ALLOCATOR>::cend() const BSLS_KEYWORD_NOEXCEPT
6109{
6110 return (const_iterator) d_impl.cend();
6111}
6112
6113template <class VALUE_TYPE, class ALLOCATOR>
6114inline
6115typename vector<VALUE_TYPE *, ALLOCATOR>::const_reverse_iterator
6116vector<VALUE_TYPE *, ALLOCATOR>::rbegin() const BSLS_KEYWORD_NOEXCEPT
6117{
6118 return const_reverse_iterator((const_iterator) d_impl.rbegin().base());
6119}
6120
6121template <class VALUE_TYPE, class ALLOCATOR>
6122inline
6123typename vector<VALUE_TYPE *, ALLOCATOR>::const_reverse_iterator
6124vector<VALUE_TYPE *, ALLOCATOR>::crbegin() const BSLS_KEYWORD_NOEXCEPT
6125{
6126 return const_reverse_iterator((const_iterator) d_impl.crbegin().base());
6127}
6128
6129template <class VALUE_TYPE, class ALLOCATOR>
6130inline
6131typename vector<VALUE_TYPE *, ALLOCATOR>::const_reverse_iterator
6132vector<VALUE_TYPE *, ALLOCATOR>::rend() const BSLS_KEYWORD_NOEXCEPT
6133{
6134 return const_reverse_iterator((const_iterator) d_impl.rend().base());
6135}
6136
6137template <class VALUE_TYPE, class ALLOCATOR>
6138inline
6139typename vector<VALUE_TYPE *, ALLOCATOR>::const_reverse_iterator
6140vector<VALUE_TYPE *, ALLOCATOR>::crend() const BSLS_KEYWORD_NOEXCEPT
6141{
6142 return const_reverse_iterator((const_iterator) d_impl.crend().base());
6143}
6144
6145
6146 // *** element access ***
6147
6148template <class VALUE_TYPE, class ALLOCATOR>
6149inline
6150typename vector<VALUE_TYPE *, ALLOCATOR>::const_reference
6151vector<VALUE_TYPE *, ALLOCATOR>::operator[](size_type position) const
6152{
6153 return (const_reference) d_impl.operator[](position);
6154}
6155
6156template <class VALUE_TYPE, class ALLOCATOR>
6157inline
6158typename vector<VALUE_TYPE *, ALLOCATOR>::const_reference
6159vector<VALUE_TYPE *, ALLOCATOR>::at(size_type position) const
6160{
6161 return (const_reference) d_impl.at(position);
6162}
6163
6164template <class VALUE_TYPE, class ALLOCATOR>
6165inline
6166typename vector<VALUE_TYPE *, ALLOCATOR>::const_reference
6167vector<VALUE_TYPE *, ALLOCATOR>::front() const
6168{
6169 return (const_reference) d_impl.front();
6170}
6171
6172template <class VALUE_TYPE, class ALLOCATOR>
6173inline
6174typename vector<VALUE_TYPE *, ALLOCATOR>::const_reference
6175vector<VALUE_TYPE *, ALLOCATOR>::back() const
6176{
6177 return (const_reference) d_impl.back();
6178}
6179
6180template <class VALUE_TYPE, class ALLOCATOR>
6181inline
6182VALUE_TYPE *const *vector<VALUE_TYPE *, ALLOCATOR>::data() const
6184{
6185 return (VALUE_TYPE *const *) d_impl.data();
6186}
6187
6188
6189} // close namespace bsl
6190
6191// ============================================================================
6192// TYPE TRAITS
6193// ============================================================================
6194
6195// Type traits for STL *sequence* containers:
6196//: o A sequence container defines STL iterators.
6197//: o A sequence container is bitwise movable if the allocator is bitwise
6198//: movable.
6199//: o A sequence container uses 'bslma' allocators if the (template parameter)
6200//: type 'ALLOCATOR' is convertible from 'bslma::Allocator *'.
6201
6202
6203
6204namespace bslalg {
6205
6206template <class VALUE_TYPE, class ALLOCATOR>
6207struct HasStlIterators<bsl::vector<VALUE_TYPE, ALLOCATOR> > : bsl::true_type
6208{};
6209
6210} // close namespace bslalg
6211
6212namespace bslma {
6213
6214template <class VALUE_TYPE, class ALLOCATOR>
6215struct UsesBslmaAllocator<bsl::vector<VALUE_TYPE, ALLOCATOR> >
6216 : bsl::is_convertible<Allocator *, ALLOCATOR>::type
6217{};
6218
6219} // close namespace bslma
6220
6221namespace bslmf {
6222
6223template <class VALUE_TYPE, class ALLOCATOR>
6224struct IsBitwiseMoveable<bsl::vector<VALUE_TYPE, ALLOCATOR> >
6225 : IsBitwiseMoveable<ALLOCATOR>
6226{};
6227
6228} // close namespace bslmf
6229
6230
6231
6232#ifdef BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE
6233extern template class bsl::vectorBase<bool>;
6234extern template class bsl::vectorBase<char>;
6235extern template class bsl::vectorBase<signed char>;
6236extern template class bsl::vectorBase<unsigned char>;
6237extern template class bsl::vectorBase<short>;
6238extern template class bsl::vectorBase<unsigned short>;
6239extern template class bsl::vectorBase<int>;
6240extern template class bsl::vectorBase<unsigned int>;
6241extern template class bsl::vectorBase<long>;
6242extern template class bsl::vectorBase<unsigned long>;
6243extern template class bsl::vectorBase<long long>;
6244extern template class bsl::vectorBase<unsigned long long>;
6245extern template class bsl::vectorBase<float>;
6246extern template class bsl::vectorBase<double>;
6247extern template class bsl::vectorBase<long double>;
6248extern template class bsl::vectorBase<void *>;
6249extern template class bsl::vectorBase<const char *>;
6250
6251extern template class bsl::vector<bool>;
6252extern template class bsl::vector<char>;
6253extern template class bsl::vector<signed char>;
6254extern template class bsl::vector<unsigned char>;
6255extern template class bsl::vector<short>;
6256extern template class bsl::vector<unsigned short>;
6257extern template class bsl::vector<int>;
6258extern template class bsl::vector<unsigned int>;
6259extern template class bsl::vector<long>;
6260extern template class bsl::vector<unsigned long>;
6261extern template class bsl::vector<long long>;
6262extern template class bsl::vector<unsigned long long>;
6263extern template class bsl::vector<float>;
6264extern template class bsl::vector<double>;
6265extern template class bsl::vector<long double>;
6266extern template class bsl::vector<void *>;
6267extern template class bsl::vector<const char *>;
6268#endif
6269
6270#else // if ! defined(DEFINED_BSLSTL_VECTOR_H)
6271# error Not valid except when included from bslstl_vector.h
6272#endif // ! defined(COMPILING_BSLSTL_VECTOR_H)
6273
6274#endif // ! defined(INCLUDED_BSLSTL_VECTOR_CPP03)
6275
6276// ----------------------------------------------------------------------------
6277// Copyright 2018 Bloomberg Finance L.P.
6278//
6279// Licensed under the Apache License, Version 2.0 (the "License");
6280// you may not use this file except in compliance with the License.
6281// You may obtain a copy of the License at
6282//
6283// http://www.apache.org/licenses/LICENSE-2.0
6284//
6285// Unless required by applicable law or agreed to in writing, software
6286// distributed under the License is distributed on an "AS IS" BASIS,
6287// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6288// See the License for the specific language governing permissions and
6289// limitations under the License.
6290// ----------------------------- END-OF-FILE ----------------------------------
6291
6292/** @} */
6293/** @} */
6294/** @} */
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements contained by this deque.
Definition bslstl_deque.h:2074
Definition bslma_bslallocator.h:580
Definition bslstl_vector.h:834
VALUE_TYPE const & const_reference
Definition bslstl_vector.h:852
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this vector.
Definition bslstl_vector.h:2664
std::size_t d_capacity
Definition bslstl_vector.h:846
VALUE_TYPE * d_dataEnd_p
Definition bslstl_vector.h:845
void adopt(BloombergLP::bslmf::MovableRef< vectorBase > base)
Definition bslstl_vector.h:2492
iterator begin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2511
reference back()
Definition bslstl_vector.h:2577
size_type capacity() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2672
std::ptrdiff_t difference_type
Definition bslstl_vector.h:856
VALUE_TYPE value_type
Definition bslstl_vector.h:850
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2622
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2606
VALUE_TYPE const * const_iterator
Definition bslstl_vector.h:854
std::size_t size_type
Definition bslstl_vector.h:855
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2654
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2527
vectorBase()
Create an empty base object with no capacity.
Definition bslstl_vector.h:2480
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2519
VALUE_TYPE * d_dataBegin_p
Definition bslstl_vector.h:844
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_vector.h:858
reference at(size_type position)
Definition bslstl_vector.h:2554
VALUE_TYPE & reference
Definition bslstl_vector.h:851
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_vector.h:857
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this vector has size 0, and false otherwise.
Definition bslstl_vector.h:2679
reference front()
Definition bslstl_vector.h:2567
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2535
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2638
VALUE_TYPE * iterator
Definition bslstl_vector.h:853
VALUE_TYPE * data() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_vector.h:2587
vector_UintPtrConversionIterator(ITERATOR it)
Create a proxy iterator adapting the specified it.
Definition bslstl_vector.h:2343
Definition bslstl_vector.h:1025
AllocatorTraits::size_type size_type
Definition bslstl_vector.h:1052
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:635
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
#define BSLS_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_PLATFORM_AGGRESSIVE_INLINE
Definition bsls_platform.h:836
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
bool operator<(const MetricId &lhs, const MetricId &rhs)
void resize(TYPE *array, int newSize)
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
bool operator>=(const Guid &lhs, const Guid &rhs)
FunctionOutputIterator< FUNCTION > & operator++(FunctionOutputIterator< FUNCTION > &iterator)
Do nothing and return specified iterator.
Definition bdlb_functionoutputiterator.h:405
bool operator<=(const Guid &lhs, const Guid &rhs)
bool operator>(const Guid &lhs, const Guid &rhs)
TransformIterator< FUNCTOR, ITERATOR > operator-(const TransformIterator< FUNCTOR, ITERATOR > &iterator, typename TransformIterator< FUNCTOR, ITERATOR >::difference_type offset)
Decimal32 operator*(Decimal32 lhs, Decimal32 rhs)
Definition bdlb_printmethods.h:283
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4126
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4135
BSLS_KEYWORD_CONSTEXPR CONTAINER::value_type * data(CONTAINER &container)
Definition bslstl_iterator.h:1231
BSLS_KEYWORD_CONSTEXPR bool empty(const CONTAINER &container)
Definition bslstl_iterator.h:1279
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdldfp_decimal.h:5188
bsl::iterator_traits< BSLSTL_ITERATOR >::iterator_category type
Definition bslstl_vector.h:729
static std::size_t computeNewCapacity(std::size_t newLength, std::size_t capacity, std::size_t maxSize)
static void swap(void *a, void *b)
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1165
static void destroy(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr)
Definition bslma_allocatortraits.h:1494
Definition bslmf_enableif.h:525
Definition bslmf_isconvertible.h:867
Definition bslmf_issame.h:146
ITERATOR type
Definition bslstl_vector.h:761