BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslalg_arrayprimitives_cpp03.h
Go to the documentation of this file.
1/// @file bslalg_arrayprimitives_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslalg_arrayprimitives_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLALG_ARRAYPRIMITIVES_CPP03
12#define INCLUDED_BSLALG_ARRAYPRIMITIVES_CPP03
13
14/// @defgroup bslalg_arrayprimitives_cpp03 bslalg_arrayprimitives_cpp03
15/// @brief Provide C++03 implementation for bslalg_arrayprimitives.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslalg
19/// @{
20/// @addtogroup bslalg_arrayprimitives_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslalg_arrayprimitives_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslalg_arrayprimitives_cpp03-classes"> Classes </a>
26/// * <a href="#bslalg_arrayprimitives_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslalg_arrayprimitives_cpp03-purpose}
29/// Provide C++03 implementation for bslalg_arrayprimitives.h
30///
31/// # Classes {#bslalg_arrayprimitives_cpp03-classes}
32/// See bslalg_arrayprimitives.h for list of classes
33///
34/// @see bslalg_arrayprimitives
35///
36/// # Description {#bslalg_arrayprimitives_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:00 2024
48/// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslalg
57 * @{
58 */
59/** @addtogroup bslalg_arrayprimitives_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLALG_ARRAYPRIMITIVES_H
64
65#if defined(BSLS_PLATFORM_CMP_IBM) // IBM needs specific workarounds.
66# define BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER 1
67 // xlC has problem removing pointer from function pointer types.
68
69# define BSLALG_ARRAYPRIMITIVES_NON_ZERO_NULL_VALUE_FOR_MEMBER_POINTERS 1
70 // xlC representation for a null member pointer is not all zero bits.
71#endif
72
73
74
75namespace bslalg {
76
77struct ArrayPrimitives_Imp;
78
79 // ======================
80 // struct ArrayPrimitives
81 // ======================
82
83/// This `struct` provides a namespace for a suite of independent utility
84/// functions that operate on arrays of elements of parameterized type
85/// `TARGET_TYPE`. Depending on the traits of `TARGET_TYPE`, the default
86/// and copy constructors, destructor, assignment operators, etcetera may
87/// not be invoked, optimized away by no-op or bit-wise move or copy.
88struct ArrayPrimitives {
89
90 public:
91 // TYPES
92 typedef ArrayPrimitives_Imp Imp;
93 typedef std::size_t size_type;
94 typedef std::ptrdiff_t difference_type;
95
96 // CLASS METHODS
97
98 /// Copy the elements of type `allocator_traits<ALLOCATOR>::value_type`
99 /// in the range beginning at the specified `fromBegin` location and
100 /// ending immediately before the specified `fromEnd` location into the
101 /// uninitialized array beginning at the specified `toBegin` location,
102 /// using the specified `allocator` to supply memory (if required). If
103 /// a constructor throws an exception during this operation, the output
104 /// array is left in an uninitialized state. The behavior is undefined
105 /// unless `toBegin` refers to space sufficient to hold
106 /// `fromEnd - fromBegin` elements.
107 template <class ALLOCATOR, class FWD_ITER>
108 static void
111 FWD_ITER fromBegin,
112 FWD_ITER fromEnd,
113 ALLOCATOR allocator);
114 template <class ALLOCATOR, class SOURCE_TYPE>
115 static void
118 SOURCE_TYPE *fromBegin,
119 SOURCE_TYPE *fromEnd,
120 ALLOCATOR allocator);
121
122 /// Copy into an uninitialized array of (the template parameter)
123 /// `TARGET_TYPE` beginning at the specified `toBegin` address, the
124 /// elements in the array of `TARGET_TYPE` starting at the specified
125 /// `fromBegin` address and ending immediately before the specified
126 /// `fromEnd` address. If the (template parameter) `ALLOCATOR` type is
127 /// derived from `bslma::Allocator` and `TARGET_TYPE` supports `bslma`
128 /// allocators, then the specified `allocator` is passed to each
129 /// invocation of the `TARGET_TYPE` copy constructor. If a
130 /// `TARGET_TYPE` constructor throws an exception during the operation,
131 /// then the destructor is called on any newly-constructed elements,
132 /// leaving the output array in an uninitialized state.
133 template <class TARGET_TYPE, class FWD_ITER>
134 static void copyConstruct(TARGET_TYPE *toBegin,
135 FWD_ITER fromBegin,
136 FWD_ITER fromEnd,
137 bslma::Allocator *allocator);
138 template <class TARGET_TYPE, class SOURCE_TYPE>
139 static void copyConstruct(TARGET_TYPE *toBegin,
140 SOURCE_TYPE *fromBegin,
141 SOURCE_TYPE *fromEnd,
142 bslma::Allocator *allocator);
143
144 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
145 /// in the range beginning at the specified `fromBegin` location and
146 /// ending immediately before the specified `fromEnd` location into the
147 /// uninitialized array beginning at the specified `toBegin` location,
148 /// using the specified `allocator` to supply memory (if required). The
149 /// elements in the input array are left in a valid but unspecified
150 /// state. If a constructor throws an exception during this operation,
151 /// the output array is left in an uninitialized state. The behavior is
152 /// undefined unless `toBegin` refers to space sufficient to hold
153 /// `fromEnd - fromBegin` elements.
154 template <class ALLOCATOR>
155 static void
160 ALLOCATOR allocator);
161
162 /// Move the elements of the (template parameter) `TARGET_TYPE` starting
163 /// at the specified `fromBegin` address and ending immediately before
164 /// the specified `fromEnd` address into the uninitialized array of
165 /// `TARGET_TYPE` beginning at the specified `toBegin` address, using
166 /// the specified `allocator` to supply memory (if required). The
167 /// elements in the input array are left in a valid but unspecified
168 /// state. If a constructor throws an exception during this operation,
169 /// the output array is left in an uninitialized state. The behavior is
170 /// undefined unless `toBegin` refers to space sufficient to hold
171 /// `fromEnd - fromBegin` elements.
172 template <class TARGET_TYPE>
173 static void moveConstruct(TARGET_TYPE *toBegin,
174 TARGET_TYPE *fromBegin,
175 TARGET_TYPE *fromEnd,
176 bslma::Allocator *allocator);
177
178 /// Value-inititalize the specified `numElements` objects of type
179 /// `allocator_traits<ALLOCATOR>::value_type` into the uninitialized
180 /// array beginning at the specified `begin` location, using the
181 /// specified `allocator` to supply memory (if required). If a
182 /// constructor throws an exception during this operation, then the
183 /// destructor is called on any newly constructed elements, leaving the
184 /// output array in an uninitialized state. The behavior is undefined
185 /// unless the `begin` refers to space sufficient to hold `numElements`.
186 template <class ALLOCATOR>
187 static void defaultConstruct(
189 size_type numElements,
190 ALLOCATOR allocator);
191
192 /// Construct each of the elements of an array of the specified
193 /// `numElements` of the parameterized `TARGET_TYPE` starting at the
194 /// specified `begin` address by value-initialization. If the (template
195 /// parameter) `ALLOCATOR` type is derived from `bslma::Allocator` and
196 /// `TARGET_TYPE` supports `bslma` allocators, then the specified
197 /// `allocator` is passed to each `TARGET_TYPE` default constructor
198 /// call. The behavior is undefined unless the output array contains at
199 /// least `numElements` uninitialized elements after `begin`. If a
200 /// `TARGET_TYPE` constructor throws an exception during this operation,
201 /// then the destructor is called on any newly-constructed elements,
202 /// leaving the output array in an uninitialized state.
203 template <class TARGET_TYPE>
204 static void defaultConstruct(TARGET_TYPE *begin,
205 size_type numElements,
206 bslma::Allocator *allocator);
207
208 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
209 /// in the range beginning at the specified `fromBegin` location and
210 /// ending immediately before the specified `fromEnd` location into the
211 /// uninitialized array beginning at the specified `toBegin` location,
212 /// using the specified `allocator` to supply memory (if required). On
213 /// return, the elements in the input range are invalid, i.e., their
214 /// destructors must not be called after this operation returns. If a
215 /// constructor throws an exception during this operation, the output
216 /// array is left in an uninitialized state. If a constructor other
217 /// than the move constructor of a non-copy-constructible type throws
218 /// an exception during this operation, the input array is unaffected;
219 /// otherwise, if the move constructor of a non-copy-constructible type
220 /// throws an exception during this operation, the input array is left
221 /// in a valid but unspecified state. The behavior is undefined unless
222 /// `toBegin` refers to space sufficient to hold `fromEnd - fromBegin`
223 /// elements.
224 template <class ALLOCATOR>
225 static void destructiveMove(
229 ALLOCATOR allocator);
230
231 /// Move the elements of the parameterized `TARGET_TYPE` in the array
232 /// starting at the specified `fromBegin` address and ending immediately
233 /// before the specified `fromEnd` address into an uninitialized array
234 /// of `TARGET_TYPE` beginning at the specified `toBegin` address. On
235 /// return, the elements in the input range are invalid, i.e., their
236 /// destructors must not be called after this operation returns. If the
237 /// parameterized `ALLOCATOR` type is derived from `bslma::Allocator`
238 /// and `TARGET_TYPE` supports `bslma` allocators, then the specified
239 /// `allocator` is used by the objects in their new location. If an
240 /// exception is thrown by a `TARGET_TYPE` constructor during the
241 /// operation, then the output array is left in an uninitialized state
242 /// and the input elements remain in their original state.
243 template <class TARGET_TYPE>
244 static void destructiveMove(TARGET_TYPE *toBegin,
245 TARGET_TYPE *fromBegin,
246 TARGET_TYPE *fromEnd,
247 bslma::Allocator *allocator);
248
249#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
250// {{{ BEGIN GENERATED CODE
251// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
252#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
253#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
254#endif
255#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A
256#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
257#endif
258
259#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 0
260 template <class ALLOCATOR>
261 static void destructiveMoveAndEmplace(
267 ALLOCATOR allocator);
268#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 0
269
270#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 1
271 template <class ALLOCATOR, class ARGS_01>
272 static void destructiveMoveAndEmplace(
278 ALLOCATOR allocator,
279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01);
280#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 1
281
282#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 2
283 template <class ALLOCATOR, class ARGS_01,
284 class ARGS_02>
285 static void destructiveMoveAndEmplace(
291 ALLOCATOR allocator,
292 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
293 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02);
294#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 2
295
296#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 3
297 template <class ALLOCATOR, class ARGS_01,
298 class ARGS_02,
299 class ARGS_03>
300 static void destructiveMoveAndEmplace(
306 ALLOCATOR allocator,
307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
309 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03);
310#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 3
311
312#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 4
313 template <class ALLOCATOR, class ARGS_01,
314 class ARGS_02,
315 class ARGS_03,
316 class ARGS_04>
317 static void destructiveMoveAndEmplace(
323 ALLOCATOR allocator,
324 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
325 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
326 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
327 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04);
328#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 4
329
330#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 5
331 template <class ALLOCATOR, class ARGS_01,
332 class ARGS_02,
333 class ARGS_03,
334 class ARGS_04,
335 class ARGS_05>
336 static void destructiveMoveAndEmplace(
342 ALLOCATOR allocator,
343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
347 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05);
348#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 5
349
350#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 6
351 template <class ALLOCATOR, class ARGS_01,
352 class ARGS_02,
353 class ARGS_03,
354 class ARGS_04,
355 class ARGS_05,
356 class ARGS_06>
357 static void destructiveMoveAndEmplace(
363 ALLOCATOR allocator,
364 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
365 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
366 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
367 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
368 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
369 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06);
370#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 6
371
372#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 7
373 template <class ALLOCATOR, class ARGS_01,
374 class ARGS_02,
375 class ARGS_03,
376 class ARGS_04,
377 class ARGS_05,
378 class ARGS_06,
379 class ARGS_07>
380 static void destructiveMoveAndEmplace(
386 ALLOCATOR allocator,
387 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
388 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
389 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
390 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
391 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
392 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
393 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07);
394#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 7
395
396#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 8
397 template <class ALLOCATOR, class ARGS_01,
398 class ARGS_02,
399 class ARGS_03,
400 class ARGS_04,
401 class ARGS_05,
402 class ARGS_06,
403 class ARGS_07,
404 class ARGS_08>
405 static void destructiveMoveAndEmplace(
411 ALLOCATOR allocator,
412 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
413 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
414 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
415 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
416 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
417 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
418 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
419 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08);
420#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 8
421
422#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 9
423 template <class ALLOCATOR, class ARGS_01,
424 class ARGS_02,
425 class ARGS_03,
426 class ARGS_04,
427 class ARGS_05,
428 class ARGS_06,
429 class ARGS_07,
430 class ARGS_08,
431 class ARGS_09>
432 static void destructiveMoveAndEmplace(
438 ALLOCATOR allocator,
439 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
440 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
441 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
442 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
443 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
444 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
445 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
446 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
447 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09);
448#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 9
449
450#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 10
451 template <class ALLOCATOR, class ARGS_01,
452 class ARGS_02,
453 class ARGS_03,
454 class ARGS_04,
455 class ARGS_05,
456 class ARGS_06,
457 class ARGS_07,
458 class ARGS_08,
459 class ARGS_09,
460 class ARGS_10>
461 static void destructiveMoveAndEmplace(
467 ALLOCATOR allocator,
468 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
469 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
470 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
471 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
472 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
474 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
475 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
476 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
477 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10);
478#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 10
479
480#else
481// The generated code below is a workaround for the absence of perfect
482// forwarding in some compilers.
483
484 template <class ALLOCATOR, class... ARGS>
485 static void destructiveMoveAndEmplace(
491 ALLOCATOR allocator,
492 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments);
493
494// }}} END GENERATED CODE
495#endif
496
497 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
498 /// in the range beginning at the specified `fromBegin` location and
499 /// ending immediately before the specified `fromEnd` location into the
500 /// uninitialized array beginning at the specified `toBegin` location
501 /// using the specified `allocator` to supply memory (if required),
502 /// inserting at the specified `position` (after translating from
503 /// `fromBegin` to `toBegin`) the specified `numElements` objects
504 /// initialized to default values, ensuring that the specified
505 /// `fromEndPtr` points to the first uninitialized element in
506 /// `[fromBegin .. fromEnd)` as the elements are moved from source to
507 /// destination. On return, the elements in the input range are
508 /// invalid, i.e., their destructors must not be called after this
509 /// operation returns. If a constructor throws an exception during this
510 /// operation, the output array is left in an uninitialized state. If a
511 /// default constructor throws an exception, the input array is
512 /// unaffected; otherwise, if a (copy or move) constructor throws an
513 /// exception during this operation, the input elements in the range
514 /// `[fromBegin .. *fromEndPtr)` are left in a valid but unspecified
515 /// state and the remaining portion of the input array is left in an
516 /// uninitialized state. The behavior is undefined unless 'fromBegin <=
517 /// position <= fromEnd' and `toBegin` refers to space sufficient to
518 /// hold `fromEnd - fromBegin + 1` elements.
519 template <class ALLOCATOR>
520 static void destructiveMoveAndInsert(
526 size_type numElements,
527 ALLOCATOR allocator);
528
529 /// Move the elements of the (template parameter) `TARGET_TYPE` in the
530 /// starting at the specified `fromBegin` address and ending immediately
531 /// before the specified `fromEnd` address into the uninitialized array
532 /// beginning at the specified `toBegin` location using the specified
533 /// `allocator` to supply memory (if required), inserting at the
534 /// specified `position` (after translating from `fromBegin` to
535 /// `toBegin`) `numElements` objects initialized to default values,
536 /// ensuring that the specified `fromEndPtr` points to the first
537 /// uninitialized element in `[fromBegin .. fromEnd)` as the elements
538 /// are moved from source to destination. On return, the elements in
539 /// the input range are invalid, i.e., their destructors must not be
540 /// called after this operation returns. If a constructor throws an
541 /// exception during this operation, the output array is left in an
542 /// uninitialized state. If a default constructor throws an exception,
543 /// the input array is unaffected; otherwise, if a (copy or move)
544 /// constructor throws an exception during this operation, the input
545 /// elements in the range `[fromBegin .. *fromEndPtr)` are left in a
546 /// valid but unspecified state and the remaining portion of the input
547 /// array is left in an uninitialized state. The behavior is undefined
548 /// unless `fromBegin <= position <= fromEnd` and `toBegin` refers to
549 /// space sufficient to hold `fromEnd - fromBegin + numElements`
550 /// elements.
551 template <class TARGET_TYPE>
552 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
553 TARGET_TYPE **fromEndPtr,
554 TARGET_TYPE *fromBegin,
555 TARGET_TYPE *position,
556 TARGET_TYPE *fromEnd,
557 size_type numElements,
558 bslma::Allocator *allocator);
559
560 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
561 /// in the range beginning at the specified `fromBegin` location and
562 /// ending immediately before the specified `fromEnd` location into the
563 /// uninitialized array beginning at the specified `toBegin` location
564 /// using the specified `allocator` to supply memory (if required),
565 /// inserting at the specified `position` (after translating from
566 /// `fromBegin` to `toBegin`) the specified `numElements` copies of the
567 /// specified `value`, ensuring that the specified `fromEndPtr` points
568 /// to the first uninitialized element in `[fromBegin .. fromEnd)` as
569 /// the elements are moved from source to destination. On return, the
570 /// elements in the input range are invalid, i.e., their destructors
571 /// must not be called after this operation returns. If a constructor
572 /// throws an exception during this operation, the output array is left
573 /// in an uninitialized state. If a (copy or move) constructor throws
574 /// an exception during this operation, the input elements in the range
575 /// `[fromBegin .. *fromEndPtr)` are left in a valid but unspecified
576 /// state and the remaining portion of the input array is left in an
577 /// uninitialized state. The behavior is undefined unless
578 /// `fromBegin <= position <= fromEnd` and `toBegin` refers to space
579 /// sufficient to hold `fromEnd - fromBegin + numElements` elements.
580 template <class ALLOCATOR>
581 static void destructiveMoveAndInsert(
588 size_type numElements,
589 ALLOCATOR allocator);
590
591 /// Move the elements of the parameterized `TARGET_TYPE` in the array
592 /// starting at the specified `fromBegin` address and ending immediately
593 /// before the specified `fromEnd` address into an uninitialized array
594 /// of `TARGET_TYPE` at the specified `toBegin` address, inserting at
595 /// the specified `position` (after translating from `fromBegin` to
596 /// `toBegin`) the specified `numElements` copies of the specified
597 /// `value`. Keep the pointer at the specified `fromEndPtr` address
598 /// pointing to the first uninitialized element in '[ fromBegin,
599 /// fromEnd)' as the elements are moved from source to destination. The
600 /// behavior is undefined unless `fromBegin <= position <= fromEnd` and
601 /// the destination array contains at least
602 /// `(fromEnd - fromBegin) + numElements` uninitialized elements. If a
603 /// copy constructor or assignment operator for `TARGET_TYPE` throws an
604 /// exception, then any elements created in the output array are
605 /// destroyed and the elements in the range `[ fromBegin, *fromEndPtr )`
606 /// will have unspecified but valid values.
607 template <class TARGET_TYPE>
608 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
609 TARGET_TYPE **fromEndPtr,
610 TARGET_TYPE *fromBegin,
611 TARGET_TYPE *position,
612 TARGET_TYPE *fromEnd,
613 const TARGET_TYPE& value,
614 size_type numElements,
615 bslma::Allocator *allocator);
616
617 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
618 /// in the range beginning at the specified `fromBegin` location and
619 /// ending immediately before the specified `fromEnd` location into the
620 /// uninitialized array beginning at the specified `toBegin` location
621 /// using the specified `allocator` to supply memory (if required),
622 /// inserting at the specified `position` (after translating from
623 /// `fromBegin` to `toBegin`) the specified `numElements` copies of the
624 /// non-modifiable elements from the range starting at the specified
625 /// `first` iterator of (template parameter) type `FWD_ITER` and ending
626 /// immediately before the specified `last` iterator, ensuring that the
627 /// specified `fromEndPtr` points to the first uninitialized element in
628 /// `[fromBegin .. fromEnd)` as the elements are moved from source to
629 /// destination. On return, the elements in the input range are
630 /// invalid, i.e., their destructors must not be called after this
631 /// operation returns. If a constructor throws an exception during this
632 /// operation, the output array is left in an uninitialized state. If
633 /// a constructor other than the copy or move constructor throws an
634 /// exception during this operation, the input array is unaffected;
635 /// otherwise, if a copy or move constructor throws an exception during
636 /// this operation, the input elements in the range
637 /// `[fromBegin .. *fromEndPtr)` are left in a valid but unspecified
638 /// state and the remaining portion of the input array is left in an
639 /// uninitialized state. The behavior is undefined unless
640 /// `fromBegin <= position <= fromEnd` and `toBegin` refers to space
641 /// sufficient to hold `fromEnd - fromBegin + numElements` elements.
642 template <class ALLOCATOR, class FWD_ITER>
643 static void destructiveMoveAndInsert(
649 FWD_ITER first,
650 FWD_ITER last,
651 size_type numElements,
652 ALLOCATOR allocator);
653
654 /// Move the elements of the parameterized `TARGET_TYPE` in the array
655 /// starting at the specified `fromBegin` address and ending immediately
656 /// before the specified `fromEnd` address into an uninitialized array
657 /// of `TARGET_TYPE` at the specified `toBegin` address, inserting at
658 /// the specified `position` (after translating from `fromBegin` to
659 /// `toBegin`) the specified `numElements` copies of the non-modifiable
660 /// elements from the range starting at the specified `first` iterator
661 /// of the parameterized `FWD_ITER` type and ending immediately before
662 /// the specified `last` iterator. Keep the pointer at the specified
663 /// `fromEndPtr` to point to the first uninitialized element in
664 /// `[fromBegin, fromEnd)` as the elements are moved from source to
665 /// destination. The behavior is undefined unless
666 /// `fromBegin <= position <= fromEnd`, the destination array contains
667 /// at least `(fromEnd - fromBegin) + numElements` uninitialized
668 /// elements after `toBegin`, and `numElements` is the distance from
669 /// `first` to `last`. If a copy constructor or assignment operator for
670 /// `TARGET_TYPE` throws an exception, then any elements created in the
671 /// output array are destroyed and the elements in the range
672 /// `[ fromBegin, *fromEndPtr )` will have unspecified but valid values.
673 template <class TARGET_TYPE, class FWD_ITER>
674 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
675 TARGET_TYPE **fromEndPtr,
676 TARGET_TYPE *fromBegin,
677 TARGET_TYPE *position,
678 TARGET_TYPE *fromEnd,
679 FWD_ITER first,
680 FWD_ITER last,
681 size_type numElements,
682 bslma::Allocator *allocator);
683
684 /// TBD: improve comment
685 /// Move, into an uninitialized array beginning at the specified
686 /// `toBegin` pointer, elements of type given by the `allocator_traits`
687 /// class template for (template parameter) `ALLOCATOR`, from elements
688 /// starting at the specified `fromBegin` pointer and ending immediately
689 /// before the specified `fromEnd` address, moving into the specified
690 /// `position` (after translating from `fromBegin` to `toBegin`) the
691 /// specified `numElements` elements starting at the specified `first`
692 /// pointer and ending immediately before the specified `last` pointer.
693 /// Keep the pointer at the specified `fromEndPtr` address pointing to
694 /// the first uninitialized element in `[ fromBegin, fromEnd)` as the
695 /// elements are moved from source to destination. The behavior is
696 /// undefined unless `fromBegin <= position <= fromEnd` and the
697 /// destination array contains at least
698 /// `(fromEnd - fromBegin) + numElements` uninitialized elements. If a
699 /// constructor or assignment operator for the target type throws an
700 /// exception, then any elements created in the output array are
701 /// destroyed and the elements in the range `[ fromBegin, *fromEndPtr )`
702 /// will have valid but unspecified values.
703 template <class ALLOCATOR>
713 size_type numElements,
714 ALLOCATOR allocator);
715
716 /// Move the elements of (template parameter) `TARGET_TYPE` in the array
717 /// starting at the specified `fromBegin` address and ending immediately
718 /// before the specified `fromEnd` address into an uninitialized array
719 /// of `TARGET_TYPE` at the specified `toBegin` address, moving into the
720 /// specified `position` (after translating from `fromBegin` to
721 /// `toBegin`) the specified `numElements` of the `TARGET_TYPE` from the
722 /// array starting at the specified `first` address and ending
723 /// immediately before the specified `last` address. Keep the pointer
724 /// at the specified `fromEndPtr` address pointing to the first
725 /// uninitialized element in `[fromBegin, fromEnd)`, and the pointer at
726 /// the specified `lastPtr` address pointing to the end of the moved
727 /// range as the elements from the range `[ first, last)` are moved from
728 /// source to destination. The behavior is undefined unless
729 /// `fromBegin <= position <= fromEnd`, the destination array contains
730 /// at least `(fromEnd - fromBegin) + numElements` uninitialized
731 /// elements after `toBegin`, and `numElements` is the distance from
732 /// `first` to `last`. If a copy constructor or assignment operator for
733 /// `TARGET_TYPE` throws an exception, then any elements in
734 /// `[ *lastPtr, last )` as well as in `[ toBegin, ... )` are destroyed,
735 /// and the elements in the ranges `[ first, *lastPtr )` and
736 /// `[ fromBegin, *fromEndPtr )` will have unspecified but valid values.
737 template <class TARGET_TYPE>
738 static void destructiveMoveAndMoveInsert(TARGET_TYPE *toBegin,
739 TARGET_TYPE **fromEndPtr,
740 TARGET_TYPE **lastPtr,
741 TARGET_TYPE *fromBegin,
742 TARGET_TYPE *position,
743 TARGET_TYPE *fromEnd,
744 TARGET_TYPE *first,
745 TARGET_TYPE *last,
746 size_type numElements,
747 bslma::Allocator *allocator);
748
749#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
750// {{{ BEGIN GENERATED CODE
751// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
752#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
753#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
754#endif
755#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B
756#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
757#endif
758
759#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
760 template <class ALLOCATOR>
761 static void emplace(
764 ALLOCATOR allocator);
765#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
766
767#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
768 template <class ALLOCATOR, class ARGS_01>
769 static void emplace(
772 ALLOCATOR allocator,
773 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01);
774#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
775
776#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
777 template <class ALLOCATOR, class ARGS_01,
778 class ARGS_02>
779 static void emplace(
782 ALLOCATOR allocator,
783 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
784 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02);
785#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
786
787#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
788 template <class ALLOCATOR, class ARGS_01,
789 class ARGS_02,
790 class ARGS_03>
791 static void emplace(
794 ALLOCATOR allocator,
795 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
796 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
797 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03);
798#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
799
800#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
801 template <class ALLOCATOR, class ARGS_01,
802 class ARGS_02,
803 class ARGS_03,
804 class ARGS_04>
805 static void emplace(
808 ALLOCATOR allocator,
809 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
810 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
811 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
812 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04);
813#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
814
815#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
816 template <class ALLOCATOR, class ARGS_01,
817 class ARGS_02,
818 class ARGS_03,
819 class ARGS_04,
820 class ARGS_05>
821 static void emplace(
824 ALLOCATOR allocator,
825 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
826 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
827 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
828 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
829 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05);
830#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
831
832#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
833 template <class ALLOCATOR, class ARGS_01,
834 class ARGS_02,
835 class ARGS_03,
836 class ARGS_04,
837 class ARGS_05,
838 class ARGS_06>
839 static void emplace(
842 ALLOCATOR allocator,
843 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
844 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
845 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
846 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
847 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
848 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06);
849#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
850
851#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
852 template <class ALLOCATOR, class ARGS_01,
853 class ARGS_02,
854 class ARGS_03,
855 class ARGS_04,
856 class ARGS_05,
857 class ARGS_06,
858 class ARGS_07>
859 static void emplace(
862 ALLOCATOR allocator,
863 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
864 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
865 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
866 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
867 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
868 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
869 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07);
870#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
871
872#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
873 template <class ALLOCATOR, class ARGS_01,
874 class ARGS_02,
875 class ARGS_03,
876 class ARGS_04,
877 class ARGS_05,
878 class ARGS_06,
879 class ARGS_07,
880 class ARGS_08>
881 static void emplace(
884 ALLOCATOR allocator,
885 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
886 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
887 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
888 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
889 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
890 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
891 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08);
893#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
894
895#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
896 template <class ALLOCATOR, class ARGS_01,
897 class ARGS_02,
898 class ARGS_03,
899 class ARGS_04,
900 class ARGS_05,
901 class ARGS_06,
902 class ARGS_07,
903 class ARGS_08,
904 class ARGS_09>
905 static void emplace(
908 ALLOCATOR allocator,
909 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
910 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
911 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
912 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
913 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
914 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
915 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
916 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
917 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09);
918#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
919
920#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
921 template <class ALLOCATOR, class ARGS_01,
922 class ARGS_02,
923 class ARGS_03,
924 class ARGS_04,
925 class ARGS_05,
926 class ARGS_06,
927 class ARGS_07,
928 class ARGS_08,
929 class ARGS_09,
930 class ARGS_10>
931 static void emplace(
934 ALLOCATOR allocator,
935 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
936 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
937 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
938 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
939 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
940 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
941 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
942 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
943 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
944 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10);
945#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
946
947
948#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
949 template <class TARGET_TYPE>
950 static void emplace(TARGET_TYPE *toBegin,
951 TARGET_TYPE *toEnd,
952 bslma::Allocator *allocator);
953#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
954
955#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
956 template <class TARGET_TYPE, class ARGS_01>
957 static void emplace(TARGET_TYPE *toBegin,
958 TARGET_TYPE *toEnd,
959 bslma::Allocator *allocator,
960 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
961#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
962
963#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
964 template <class TARGET_TYPE, class ARGS_01,
965 class ARGS_02>
966 static void emplace(TARGET_TYPE *toBegin,
967 TARGET_TYPE *toEnd,
968 bslma::Allocator *allocator,
969 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
970 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
971#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
972
973#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
974 template <class TARGET_TYPE, class ARGS_01,
975 class ARGS_02,
976 class ARGS_03>
977 static void emplace(TARGET_TYPE *toBegin,
978 TARGET_TYPE *toEnd,
979 bslma::Allocator *allocator,
980 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
981 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
982 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
983#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
984
985#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
986 template <class TARGET_TYPE, class ARGS_01,
987 class ARGS_02,
988 class ARGS_03,
989 class ARGS_04>
990 static void emplace(TARGET_TYPE *toBegin,
991 TARGET_TYPE *toEnd,
992 bslma::Allocator *allocator,
993 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
994 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
995 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
996 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
997#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
998
999#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
1000 template <class TARGET_TYPE, class ARGS_01,
1001 class ARGS_02,
1002 class ARGS_03,
1003 class ARGS_04,
1004 class ARGS_05>
1005 static void emplace(TARGET_TYPE *toBegin,
1006 TARGET_TYPE *toEnd,
1007 bslma::Allocator *allocator,
1008 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1009 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1010 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1011 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1012 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
1013#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
1014
1015#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
1016 template <class TARGET_TYPE, class ARGS_01,
1017 class ARGS_02,
1018 class ARGS_03,
1019 class ARGS_04,
1020 class ARGS_05,
1021 class ARGS_06>
1022 static void emplace(TARGET_TYPE *toBegin,
1023 TARGET_TYPE *toEnd,
1024 bslma::Allocator *allocator,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1027 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1028 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1029 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1030 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
1031#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
1032
1033#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
1034 template <class TARGET_TYPE, class ARGS_01,
1035 class ARGS_02,
1036 class ARGS_03,
1037 class ARGS_04,
1038 class ARGS_05,
1039 class ARGS_06,
1040 class ARGS_07>
1041 static void emplace(TARGET_TYPE *toBegin,
1042 TARGET_TYPE *toEnd,
1043 bslma::Allocator *allocator,
1044 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1045 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1046 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1047 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1048 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1049 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1050 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
1051#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
1052
1053#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
1054 template <class TARGET_TYPE, class ARGS_01,
1055 class ARGS_02,
1056 class ARGS_03,
1057 class ARGS_04,
1058 class ARGS_05,
1059 class ARGS_06,
1060 class ARGS_07,
1061 class ARGS_08>
1062 static void emplace(TARGET_TYPE *toBegin,
1063 TARGET_TYPE *toEnd,
1064 bslma::Allocator *allocator,
1065 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1066 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1067 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1068 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1069 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1070 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1071 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1072 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
1073#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
1074
1075#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
1076 template <class TARGET_TYPE, class ARGS_01,
1077 class ARGS_02,
1078 class ARGS_03,
1079 class ARGS_04,
1080 class ARGS_05,
1081 class ARGS_06,
1082 class ARGS_07,
1083 class ARGS_08,
1084 class ARGS_09>
1085 static void emplace(TARGET_TYPE *toBegin,
1086 TARGET_TYPE *toEnd,
1087 bslma::Allocator *allocator,
1088 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1089 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1090 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1091 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1092 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1093 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1094 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1095 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1096 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
1097#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
1098
1099#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
1100 template <class TARGET_TYPE, class ARGS_01,
1101 class ARGS_02,
1102 class ARGS_03,
1103 class ARGS_04,
1104 class ARGS_05,
1105 class ARGS_06,
1106 class ARGS_07,
1107 class ARGS_08,
1108 class ARGS_09,
1109 class ARGS_10>
1110 static void emplace(TARGET_TYPE *toBegin,
1111 TARGET_TYPE *toEnd,
1112 bslma::Allocator *allocator,
1113 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1114 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1115 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1116 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1117 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1118 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1119 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1120 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1121 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1122 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
1123#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
1124
1125#else
1126// The generated code below is a workaround for the absence of perfect
1127// forwarding in some compilers.
1128
1129 template <class ALLOCATOR, class... ARGS>
1130 static void emplace(
1133 ALLOCATOR allocator,
1134 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments);
1135
1136 template <class TARGET_TYPE, class... ARGS>
1137 static void emplace(TARGET_TYPE *toBegin,
1138 TARGET_TYPE *toEnd,
1139 bslma::Allocator *allocator,
1140 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
1141
1142// }}} END GENERATED CODE
1143#endif
1144
1145#if defined(BSLS_PLATFORM_CMP_MSVC) && BSLS_PLATFORM_CMP_VERSION < 1900
1146 template <class CLASS_TYPE, class MEMBER_TYPE, class... ARGS>
1147 static void emplace(MEMBER_TYPE CLASS_TYPE::* *toBegin,
1148 MEMBER_TYPE CLASS_TYPE::* *toEnd,
1149 bslma::Allocator *allocator)
1150 // Old Microsoft compilers need help value-initializing elements that
1151 // are pointer-to-member types.
1152 {
1153 emplace(toBegin, toEnd, allocator, nullptr);
1154 }
1155#endif
1156
1157 /// TBD: improve comment
1158 /// Destroy the elements of type given by the `allocator_traits` class
1159 /// template for (template parameter) `ALLOCATOR` starting at the
1160 /// specified `first` `first` pointer and ending immediately before the
1161 /// specified `middle` pointer, and move the elements in the array
1162 /// starting at `middle` and ending at the specified `last` pointer down
1163 /// to the `first` pointer. If an assignment throws an exception during
1164 /// this process, all of the elements in the range `[ first, last )`
1165 /// will have unspecified but valid values, and no elements are
1166 /// destroyed. The behavior is undefined unless
1167 /// `first <= middle <= last`.
1168 template <class ALLOCATOR>
1169 static void
1173 ALLOCATOR allocator);
1174
1175 /// Destroy the elements of the parameterized `TARGET_TYPE` in the array
1176 /// starting at the specified `first` address and ending immediately
1177 /// before the specified `middle` address, and move the elements in the
1178 /// array starting at `middle` and ending at the specified `last`
1179 /// address down to the `first` address. If an assignment throws an
1180 /// exception during this process, all of the elements in the range
1181 /// `[ first, last )` will have unspecified but valid values, and no
1182 /// elements are destroyed. The behavior is undefined unless
1183 /// `first <= middle <= last`.
1184 template <class TARGET_TYPE>
1185 static void erase(TARGET_TYPE *first,
1186 TARGET_TYPE *middle,
1187 TARGET_TYPE *last,
1188 bslma::Allocator *allocator = 0);
1189
1190 /// Insert the specified `value` into the array of
1191 /// `allocator_traits<ALLOCATOR>::value_type` objects at the specified
1192 /// `toBegin` location, shifting forward the elements from `toBegin` to
1193 /// the specified `toEnd` location by one position. `value` is left in
1194 /// a valid but unspecified state. If a (copy or move) constructor or a
1195 /// (copy or move) assignment operator throws an exception, then any
1196 /// elements created after `toEnd` are destroyed and the elements in the
1197 /// range `[toBegin .. toEnd )` are left in a valid but unspecified
1198 /// state. The behavior is undefined unless `toBegin` refers to
1199 /// sufficient space to hold at least `toEnd - toBegin + 1` elements.
1200 template <class ALLOCATOR>
1201 static void
1206 ALLOCATOR allocator);
1207
1208 /// Insert the specified `value` into the array of the (template
1209 /// parameter) type `TARGET_TYPE` at the specified `toBegin` address,
1210 /// shifting the elements from `toBegin` to the specified `toEnd`
1211 /// address by one position towards larger addresses. `value` is left
1212 /// in a valid but unspecified state. If a (copy or move) constructor
1213 /// or a (copy or move) assignment operator throws an exception, then
1214 /// any elements created after `toEnd` are destroyed and the elements in
1215 /// the range `[toBegin .. toEnd )` are left in a valid but unspecified
1216 /// state. The behavior is undefined unless `toBegin` refers to
1217 /// sufficient space to hold at least `toEnd - toBegin + 1` elements.
1218 template <class TARGET_TYPE>
1219 static void insert(TARGET_TYPE *toBegin,
1220 TARGET_TYPE *toEnd,
1222 bslma::Allocator *allocator);
1223
1224 /// Insert the specified `numElements` copies of the specified `value`
1225 /// into the array of type `allocator_traits<ALLOCATOR>::value_type`
1226 /// starting at the specified `toBegin` location, shifting forward the
1227 /// elements from `toBegin` to the specified `toEnd` location by
1228 /// `numElements` positions. If a (copy or move) constructor or a (copy
1229 /// or move) assignment operator throws an exception, any elements
1230 /// created after `toEnd` are destroyed and the elements in the range
1231 /// `[toBegin .. toEnd)` are left in a valid but unspecified state. The
1232 /// behavior is undefined unless `toBegin` refers to space sufficient to
1233 /// hold at least `toEnd - toBegin + numElements` elements.
1234 template <class ALLOCATOR>
1235 static void
1236 insert(
1240 size_type numElements,
1241 ALLOCATOR allocator);
1242
1243 /// Insert the specified `numElements` copies of the specified `value`
1244 /// into the array of (template parameter) `TARGET_TYPE` starting at the
1245 /// specified `toBegin` address and ending immediately before the
1246 /// specified `toEnd` address, shifting the elements in the array by
1247 /// `numElements` positions towards larger addresses. The behavior is
1248 /// undefined unless the destination array contains at least
1249 /// `numElements` uninitialized elements after `toEnd`. If a copy
1250 /// constructor or assignment operator for `TARGET_TYPE` throws an
1251 /// exception, then any elements created after `toEnd` are destroyed and
1252 /// the elements in the range `[ toBegin, toEnd )` will have
1253 /// unspecified, but valid, values.
1254 template <class TARGET_TYPE>
1255 static void insert(TARGET_TYPE *toBegin,
1256 TARGET_TYPE *toEnd,
1257 const TARGET_TYPE& value,
1258 size_type numElements,
1259 bslma::Allocator *allocator);
1260
1261 /// TBD: improve comment
1262 /// Insert the specified `numElements` from the range starting at the
1263 /// specified `fromBegin` and ending immediately before the specified
1264 /// `fromEnd` iterators of (template parameter) `FWD_ITER` type (or
1265 /// template parameter `SOURCE_TYPE *`), into the array of elements of
1266 /// type given by the `allocator_traits` class template for (template
1267 /// parameter) `ALLOCATOR`, starting at the specified `toBegin` address,
1268 /// shifting forward the elements in the array by `numElements`
1269 /// positions. The behavior is undefined unless the destination array
1270 /// contains `numElements` uninitialized elements after `toEnd`,
1271 /// `numElements` is the distance between `fromBegin` and `fromEnd`,
1272 /// and the input array and the destination array do not overlap. If a
1273 /// copy constructor or assignment operator throws an exception, then
1274 /// any elements created after `toEnd` are destroyed and the elements in
1275 /// the range `[ toBegin, toEnd )` will have valid but unspecified
1276 /// values.
1277 template <class ALLOCATOR, class FWD_ITER>
1278 static void
1281 FWD_ITER fromBegin,
1282 FWD_ITER fromEnd,
1283 size_type numElements,
1284 ALLOCATOR allocator);
1285 template <class ALLOCATOR, class SOURCE_TYPE>
1286 static void
1289 SOURCE_TYPE *fromBegin,
1290 SOURCE_TYPE *fromEnd,
1291 size_type numElements,
1292 ALLOCATOR allocator);
1293
1294 /// Insert, into the array at the specified `toBegin` location, the
1295 /// specified `numElements` from the range starting at the specified
1296 /// `fromBegin` and ending immediately before the specified `fromEnd`
1297 /// iterators of the (template parameter) `FWD_ITER` type (or the
1298 /// (template parameter) `SOURCE_TYPE *`), into the array of elements of
1299 /// the parameterized `TARGET_TYPE` starting at the specified `toBegin`
1300 /// address and ending immediately before the specified `toEnd` address,
1301 /// shifting the elements in the array by `numElements` positions
1302 /// towards larger addresses. The behavior is undefined unless the
1303 /// destination array contains `numElements` uninitialized elements
1304 /// after `toEnd`, `numElements` is the distance between `fromBegin` and
1305 /// `fromEnd`, and the input array and the destination array do not
1306 /// overlap. If a copy constructor or assignment operator for
1307 /// `TARGET_TYPE` throws an exception, then any elements created after
1308 /// `toEnd` are destroyed and the elements in the range
1309 /// `[ toBegin, toEnd )` will have unspecified, but valid, values.
1310 template <class TARGET_TYPE, class FWD_ITER>
1311 static void insert(TARGET_TYPE *toBegin,
1312 TARGET_TYPE *toEnd,
1313 FWD_ITER fromBegin,
1314 FWD_ITER fromEnd,
1315 size_type numElements,
1316 bslma::Allocator *allocator);
1317 template <class TARGET_TYPE, class SOURCE_TYPE>
1318 static void insert(TARGET_TYPE *toBegin,
1319 TARGET_TYPE *toEnd,
1320 SOURCE_TYPE *fromBegin,
1321 SOURCE_TYPE *fromEnd,
1322 size_type numElements,
1323 bslma::Allocator *allocator);
1324
1325 /// TBD: improve comment
1326 /// Move the elements of type given by the `allocator_traits` class
1327 /// template for (template parameter) `ALLOCATOR` in the array starting
1328 /// at the specified `toBegin` location and ending immediately before
1329 /// the specified `toEnd` location by the specified `numElements`
1330 /// positions towards larger addresses, and fill the `numElements` at
1331 /// the `toBegin` location by moving the elements from the array
1332 /// starting at the specified `fromBegin` and ending immediately before
1333 /// the specified `fromEnd` location. Keep the iterator at the
1334 /// specified `fromEndPtr` address pointing to the end of the range as
1335 /// the elements from `[ fromBegin, fromEnd )` are moved from source to
1336 /// destination. The behavior is undefined unless the destination array
1337 /// contains `numElements` uninitialized elements after `toEnd`,
1338 /// `numElements` is the distance from `fromBegin` to `fromEnd`, and the
1339 /// input and destination arrays do not overlap. If a copy constructor
1340 /// or assignment operator for `TARGET_TYPE` throws an exception, then
1341 /// any elements created after `toEnd` are destroyed, the elements in
1342 /// the ranges `[ toBegin, toEnd)` and `[ fromBegin, *fromEndPtr )` will
1343 /// have unspecified, but valid, values, and the elements in
1344 /// `[ *fromEndPtr, fromEnd )` will be destroyed.
1345 template <class ALLOCATOR>
1346 static void moveInsert(
1349 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
1352 size_type numElements,
1353 ALLOCATOR allocator);
1354
1355 /// Move the elements of the (template parameter) `TARGET_TYPE` in the
1356 /// array starting at the specified `toBegin` address and ending
1357 /// immediately before the specified `toEnd` address by the specified
1358 /// `numElements` positions towards larger addresses, and fill the
1359 /// `numElements` at the `toBegin` address by moving the elements from
1360 /// the array starting at the specified `fromBegin` and ending
1361 /// immediately before the specified `fromEnd` address. Keep the
1362 /// iterator at the specified `fromEndPtr` address pointing to the end
1363 /// of the range as the elements from `[ fromBegin, fromEnd )` are moved
1364 /// from source to destination. The behavior is undefined unless the
1365 /// destination array contains `numElements` uninitialized elements
1366 /// after `toEnd`, `numElements` is the distance from `fromBegin` to
1367 /// `fromEnd`, and the input and destination arrays do not overlap. If
1368 /// a copy constructor or assignment operator for `TARGET_TYPE` throws
1369 /// an exception, then any elements created after `toEnd` are destroyed,
1370 /// the elements in the ranges `[ toBegin, toEnd)` and
1371 /// `[ fromBegin, *fromEndPtr )` will have unspecified, but valid,
1372 /// values, and the elements in `[ *fromEndPtr, fromEnd )` will be
1373 /// destroyed.
1374 template <class TARGET_TYPE>
1375 static void moveInsert(TARGET_TYPE *toBegin,
1376 TARGET_TYPE *toEnd,
1377 TARGET_TYPE **fromEndPtr,
1378 TARGET_TYPE *fromBegin,
1379 TARGET_TYPE *fromEnd,
1380 size_type numElements,
1381 bslma::Allocator *allocator);
1382
1383 /// Move the elements of the parameterized `TARGET_TYPE` in the array
1384 /// starting at the specified `first` address and ending immediately
1385 /// before the specified `middle` address to the array of the same
1386 /// length ending at the specified `last` address (and thus starting at
1387 /// the `last - (middle - first)` address), and move the elements
1388 /// previously in the array starting at `middle` and ending at `last`
1389 /// down to the `first` address. If the assignment operator throws an
1390 /// exception during this process, all of the elements in
1391 /// `[ first, last )` will have unspecified, but valid, values. The
1392 /// behavior is undefined unless `first <= middle <= last`.
1393 template <class TARGET_TYPE>
1394 static void rotate(TARGET_TYPE *first,
1395 TARGET_TYPE *middle,
1396 TARGET_TYPE *last);
1397
1398 /// TBD: improve comment
1399 /// Construct copies of the specified `value` of type given by the
1400 /// `allocator_traits` class template for (template parameter)
1401 /// `ALLOCATOR` into the uninitialized array containing the specified
1402 /// `numElements` starting at the specified `begin` location. The
1403 /// behavior is undefined unless the output array contains at least
1404 /// `numElements` uninitialized elements after `begin`. If a
1405 /// constructor throws an exception during the operation, then the
1406 /// destructor is called on any newly-constructed elements, leaving the
1407 /// output array in an uninitialized state.
1408 template <class ALLOCATOR>
1409 static void uninitializedFillN(
1411 size_type numElements,
1413 ALLOCATOR allocator);
1414
1415 /// Construct copies of the specified `value` of the parameterized type
1416 /// `TARGET_TYPE` into the uninitialized array containing the specified
1417 /// `numElements` starting at the specified `begin` address. If the
1418 /// (template parameter) `ALLOCATOR` type is derived from
1419 /// `bslma::Allocator` and `TARGET_TYPE` supports `bslma` allocators,
1420 /// then the specified `allocator` is passed to each invocation of the
1421 /// `TARGET_TYPE` copy constructor. The behavior is undefined unless
1422 /// the output array contains at least `numElements` uninitialized
1423 /// elements after `begin`. If a `TARGET_TYPE` constructor throws an
1424 /// exception during the operation, then the destructor is called on any
1425 /// newly-constructed elements, leaving the output array in an
1426 /// uninitialized state. Note that the argument order was chosen to
1427 /// maintain compatibility with the existing `bslalg`.
1428 template <class TARGET_TYPE>
1429 static void uninitializedFillN(TARGET_TYPE *begin,
1430 size_type numElements,
1431 const TARGET_TYPE& value,
1432 bslma::Allocator *allocator);
1433};
1434
1435 // ==========================
1436 // struct ArrayPrimitives_Imp
1437 // ==========================
1438
1439/// This `struct` provides a namespace for a suite of independent utility
1440/// functions that operate on arrays of elements of a parameterized
1441/// `TARGET_TYPE`. These utility functions are only for the purpose of
1442/// implementing those in the `ArrayPrimitives` utility. For brevity, we do
1443/// not repeat the main contracts here, but instead refer to the
1444/// corresponding contract in the `ArrayPrimitives` utility.
1445struct ArrayPrimitives_Imp {
1446
1447 private:
1448 // PRIVATE METHODS
1449
1450 /// Copy-assign the specified `value` to the range starting at the
1451 /// specified `srcStart` and ending immediately before the specified
1452 /// `srcEnd`. Note that the (template parameter) `TARGET_TYPE` must be
1453 /// copy-assignable. Also note that `value` should not be an element in
1454 /// the range `[srcStart, srcEnd)`.
1455 template <class TARGET_TYPE>
1456 static void assign(TARGET_TYPE *srcStart,
1457 TARGET_TYPE *srcEnd,
1458 TARGET_TYPE& value);
1459
1460 /// Copy-assign the elements in reverse order from the range starting at
1461 /// the specified `srcStart` and ending immediately before the specified
1462 /// `srcEnd` to the range starting at the specified `dest` and ending
1463 /// immediately before `dest + (srcEnd - srcStart)`. The behavior is
1464 /// undefined unless each element is both range `[srcStart, srcEnd)` and
1465 /// range `[dest, dest + (srcEnd - srcStart))` is valid. Note that the
1466 /// (template parameter) `TARGET_TYPE` must be copy-assignable. Also
1467 /// note that this method is intended to support range assignment when
1468 /// the two ranges may be overlapped, and `srcStart <= dest`.
1469 template <class TARGET_TYPE>
1470 static void reverseAssign(TARGET_TYPE *dest,
1471 TARGET_TYPE *srcStart,
1472 TARGET_TYPE *srcEnd);
1473
1474 public:
1475 // TYPES
1478
1479 enum {
1480 // These constants are used in the overloads below, when the last
1481 // argument is of type 'bslmf::integral_constant<int,N>', indicating
1482 // that 'TARGET_TYPE' has the traits for which the enumerator equal to
1483 // 'N' is named.
1484
1491 e_NIL_TRAITS = 0
1492 };
1493
1494 enum {
1495 // Number of bytes for which a stack-allocated buffer can be
1496 // comfortably obtained to optimize bitwise moves.
1497
1499 };
1500
1501 // CLASS METHODS
1502
1503 /// Fill the specified `numBytes` in the array starting at the specified
1504 /// `begin` address, as if by bit-wise copying the specified
1505 /// `numBytesInitialized` at every offset that is a multiple of
1506 /// `numBytesInitialized` within the output array. The behavior is
1507 /// undefined unless `numBytesInitialized <= numBytes`. Note that
1508 /// `numBytes` usually is, but does not have to be, a multiple of
1509 /// `numBytesInitialized`.
1510 static void bitwiseFillN(char *begin,
1511 size_type numBytesInitialized,
1512 size_type numBytes);
1513
1514 static void uninitializedFillN(
1515 bool *begin,
1516 bool value,
1517 size_type numElements,
1518 void * = 0,
1521 static void uninitializedFillN(
1522 char *begin,
1523 char value,
1524 size_type numElements,
1525 void * = 0,
1528 static void uninitializedFillN(
1529 unsigned char *begin,
1530 unsigned char value,
1531 size_type numElements,
1532 void * = 0,
1535 static void uninitializedFillN(
1536 signed char *begin,
1537 signed char value,
1538 size_type numElements,
1539 void * = 0,
1542 static void uninitializedFillN(
1543 wchar_t *begin,
1544 wchar_t value,
1545 size_type numElements,
1546 void * = 0,
1549 static void uninitializedFillN(
1550 short *begin,
1551 short value,
1552 size_type numElements,
1553 void * = 0,
1556 static void uninitializedFillN(
1557 unsigned short *begin,
1558 unsigned short value,
1559 size_type numElements,
1560 void * = 0,
1563 static void uninitializedFillN(
1564 int *begin,
1565 int value,
1566 size_type numElements,
1567 void * = 0,
1570 static void uninitializedFillN(
1571 unsigned int *begin,
1572 unsigned int value,
1573 size_type numElements,
1574 void * = 0,
1577 static void uninitializedFillN(
1578 long *begin,
1579 long value,
1580 size_type numElements,
1581 void * = 0,
1584 static void uninitializedFillN(
1585 unsigned long *begin,
1586 unsigned long value,
1587 size_type numElements,
1588 void * = 0,
1591 static void uninitializedFillN(
1592 bsls::Types::Int64 *begin,
1593 bsls::Types::Int64 value,
1594 size_type numElements,
1595 void * = 0,
1598 static void uninitializedFillN(
1599 bsls::Types::Uint64 *begin,
1600 bsls::Types::Uint64 value,
1601 size_type numElements,
1602 void * = 0,
1605 static void uninitializedFillN(
1606 float *begin,
1607 float value,
1608 size_type numElements,
1609 void * = 0,
1612 static void uninitializedFillN(
1613 double *begin,
1614 double value,
1615 size_type numElements,
1616 void * = 0,
1619 static void uninitializedFillN(
1620 long double *begin,
1621 long double value,
1622 size_type numElements,
1623 void * = 0,
1626 static void uninitializedFillN(
1627 void **begin,
1628 void *value,
1629 size_type numElements,
1630 void * = 0,
1633 static void uninitializedFillN(
1634 const void **begin,
1635 const void *value,
1636 size_type numElements,
1637 void * = 0,
1640 static void uninitializedFillN(
1641 volatile void **begin,
1642 volatile void *value,
1643 size_type numElements,
1644 void * = 0,
1647 /// Copy the specified `value` of the parameterized `TARGET_TYPE` into
1648 /// every of the specified `numElements` in the array starting at the
1649 /// specified `begin` address. Pass the specified `allocator` to the
1650 /// copy constructor if appropriate. Note that if `TARGET_TYPE` is
1651 /// bit-wise copyable or is not based on `bslma::Allocator`, `allocator`
1652 /// is ignored. The last argument is for removing overload ambiguities
1653 /// and is not used.
1654 static void uninitializedFillN(
1655 const volatile void **begin,
1656 const volatile void *value,
1657 size_type numElements,
1658 void * = 0,
1661 template <class TARGET_TYPE>
1662 static void uninitializedFillN(
1663 TARGET_TYPE **begin,
1664 TARGET_TYPE *value,
1665 size_type numElements,
1666 void * = 0,
1669 template <class TARGET_TYPE>
1670 static void uninitializedFillN(
1671 const TARGET_TYPE **begin,
1672 const TARGET_TYPE *value,
1673 size_type numElements,
1674 void * = 0,
1677 template <class TARGET_TYPE>
1678 static void uninitializedFillN(
1679 volatile TARGET_TYPE **begin,
1680 volatile TARGET_TYPE *value,
1681 size_type numElements,
1682 void * = 0,
1685 template <class TARGET_TYPE>
1686 static void uninitializedFillN(
1687 const volatile TARGET_TYPE **begin,
1688 const volatile TARGET_TYPE *value,
1689 size_type numElements,
1690 void * = 0,
1693 template <class TARGET_TYPE, class ALLOCATOR>
1694 static void uninitializedFillN(
1695 TARGET_TYPE *begin,
1696 const TARGET_TYPE& value,
1697 size_type numElements,
1698 ALLOCATOR *allocator,
1700 template <class TARGET_TYPE, class ALLOCATOR>
1701 static void uninitializedFillN(
1702 TARGET_TYPE *begin,
1703 const TARGET_TYPE& value,
1704 size_type numElements,
1705 ALLOCATOR *allocator,
1707
1708 /// These functions follow the `copyConstruct` contract. If the
1709 /// (template parameter) `ALLOCATOR` type is based on `bslma::Allocator`
1710 /// and the `TARGET_TYPE` constructors take an allocator argument, then
1711 /// pass the specified `allocator` to the copy constructor. The
1712 /// behavior is undefined unless the output array has length at least
1713 /// the distance from the specified `fromBegin` to the specified
1714 /// `fromEnd`. Note that if `FWD_ITER` is the `TARGET_TYPE *` pointer
1715 /// type and `TARGET_TYPE` is bit-wise copyable, then this operation is
1716 /// simply `memcpy`. The last argument is for removing overload
1717 /// ambiguities and is not used.
1718 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
1719 static void copyConstruct(
1720 TARGET_TYPE *toBegin,
1721 FWD_ITER fromBegin,
1722 FWD_ITER fromEnd,
1723 ALLOCATOR allocator,
1725 template <class TARGET_TYPE, class ALLOCATOR>
1726 static void copyConstruct(
1727 TARGET_TYPE *toBegin,
1728 const TARGET_TYPE *fromBegin,
1729 const TARGET_TYPE *fromEnd,
1730 ALLOCATOR allocator,
1732 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
1733 static void copyConstruct(
1734 TARGET_TYPE *toBegin,
1735 FWD_ITER fromBegin,
1736 FWD_ITER fromEnd,
1737 ALLOCATOR allocator,
1739 template <class FWD_ITER, class ALLOCATOR>
1740 static void copyConstruct(
1741 void **toBegin,
1742 FWD_ITER fromBegin,
1743 FWD_ITER fromEnd,
1744 ALLOCATOR allocator,
1746 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
1747 static void copyConstruct(
1748 TARGET_TYPE *toBegin,
1749 FWD_ITER fromBegin,
1750 FWD_ITER fromEnd,
1751 ALLOCATOR allocator,
1753
1754 /// TBD: improve comment
1755 /// Move-insert into an uninitialized array beginning at the specified
1756 /// `toBegin` pointer, elements of type given by the `allocator_traits`
1757 /// class template for (template parameter) `ALLOCATOR` from elements
1758 /// starting at the specified `fromBegin` pointer and ending immediately
1759 /// before the specified `fromEnd` pointer. The elements in the range
1760 /// `[fromBegin...fromEnd)` are left in a valid but unspecified state.
1761 /// If a constructor throws an exception during the operation, then the
1762 /// destructor is called on any newly-constructed elements, leaving the
1763 /// output array in an uninitialized state. The behavior is undefined
1764 /// unless `toBegin` refers to space sufficient to hold
1765 /// `fromEnd - fromBegin` elements.
1766 template <class TARGET_TYPE, class ALLOCATOR>
1767 static void moveConstruct(
1768 TARGET_TYPE *toBegin,
1769 TARGET_TYPE *fromBegin,
1770 TARGET_TYPE *fromEnd,
1771 ALLOCATOR allocator,
1773 template <class TARGET_TYPE, class ALLOCATOR>
1774 static void moveConstruct(
1775 TARGET_TYPE *toBegin,
1776 TARGET_TYPE *fromBegin,
1777 TARGET_TYPE *fromEnd,
1778 ALLOCATOR allocator,
1780
1781 /// TBD: improve comment
1782 /// Either move- or copy-insert into an uninitialized array beginning at
1783 /// the specified `toBegin` pointer, elements of type given by the
1784 /// `allocator_traits` class template for (template parameter)
1785 /// `ALLOCATOR` from elements starting at the specified `fromBegin`
1786 /// pointer and ending immediately before the specified `fromEnd`
1787 /// pointer. The elements in the range `[fromBegin...fromEnd)` are left
1788 /// in a valid but unspecified state. Use the move constructor if it is
1789 /// guaranteed to not throw or if the target type does not define a copy
1790 /// constructor; otherwise use the copy constructor. If a constructor
1791 /// throws an exception during the operation, then the destructor is
1792 /// called on any newly-constructed elements, leaving the output array
1793 /// in an uninitialized state. The behavior is undefined unless
1794 /// `toBegin` refers to space sufficient to hold `fromEnd - fromBegin`
1795 /// elements.
1796 template <class TARGET_TYPE, class ALLOCATOR>
1797 static void moveIfNoexcept(
1798 TARGET_TYPE *toBegin,
1799 TARGET_TYPE *fromBegin,
1800 TARGET_TYPE *fromEnd,
1801 ALLOCATOR allocator,
1803
1804 /// Use the default constructor of the (template parameter)
1805 /// `TARGET_TYPE` (or `memset` to 0 if `TARGET_TYPE` has a trivial
1806 /// default constructor) on each element of the array starting at the
1807 /// specified `begin` address and ending immediately before the `end`
1808 /// address. Pass the specified `allocator` to the default constructor
1809 /// if appropriate. The last argument is for traits overloading
1810 /// resolution only and its value is ignored.
1811 template <class TARGET_TYPE, class ALLOCATOR>
1812 static void defaultConstruct(
1813 TARGET_TYPE *begin,
1814 size_type numElements,
1815 ALLOCATOR allocator,
1817 template <class TARGET_TYPE, class ALLOCATOR>
1818 static void defaultConstruct(
1819 TARGET_TYPE *begin,
1820 size_type numElements,
1821 ALLOCATOR allocator,
1823 template <class TARGET_TYPE, class ALLOCATOR>
1824 static void defaultConstruct(
1825 TARGET_TYPE *begin,
1826 size_type numElements,
1827 ALLOCATOR allocator,
1829
1830 /// These functions follow the `destructiveMove` contract. Note that
1831 /// both arrays cannot overlap (one contains only initialized elements
1832 /// and the other only uninitialized elements), and that if
1833 /// `TARGET_TYPE` is bit-wise moveable, then this operation is simply
1834 /// `memcpy`. The last argument is for removing overload ambiguities
1835 /// and is not used.
1836 template <class TARGET_TYPE, class ALLOCATOR>
1837 static void destructiveMove(
1838 TARGET_TYPE *toBegin,
1839 TARGET_TYPE *fromBegin,
1840 TARGET_TYPE *fromEnd,
1841 ALLOCATOR allocator,
1843 template <class TARGET_TYPE, class ALLOCATOR>
1844 static void destructiveMove(
1845 TARGET_TYPE *toBegin,
1846 TARGET_TYPE *fromBegin,
1847 TARGET_TYPE *fromEnd,
1848 ALLOCATOR allocator,
1850
1851#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1852// {{{ BEGIN GENERATED CODE
1853// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
1854#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
1855#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
1856#endif
1857#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C
1858#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
1859#endif
1860#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
1861 template <class TARGET_TYPE, class ALLOCATOR>
1862 static void emplace(
1863 TARGET_TYPE *toBegin,
1864 TARGET_TYPE *toEnd,
1865 ALLOCATOR allocator,
1867#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
1868
1869#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
1870 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
1871 static void emplace(
1872 TARGET_TYPE *toBegin,
1873 TARGET_TYPE *toEnd,
1874 ALLOCATOR allocator,
1876 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
1877#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
1878
1879#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
1880 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1881 class ARGS_02>
1882 static void emplace(
1883 TARGET_TYPE *toBegin,
1884 TARGET_TYPE *toEnd,
1885 ALLOCATOR allocator,
1887 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1888 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
1889#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
1890
1891#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
1892 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1893 class ARGS_02,
1894 class ARGS_03>
1895 static void emplace(
1896 TARGET_TYPE *toBegin,
1897 TARGET_TYPE *toEnd,
1898 ALLOCATOR allocator,
1900 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1901 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1902 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
1903#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
1904
1905#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
1906 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1907 class ARGS_02,
1908 class ARGS_03,
1909 class ARGS_04>
1910 static void emplace(
1911 TARGET_TYPE *toBegin,
1912 TARGET_TYPE *toEnd,
1913 ALLOCATOR allocator,
1915 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1916 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1917 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1918 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
1919#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
1920
1921#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
1922 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1923 class ARGS_02,
1924 class ARGS_03,
1925 class ARGS_04,
1926 class ARGS_05>
1927 static void emplace(
1928 TARGET_TYPE *toBegin,
1929 TARGET_TYPE *toEnd,
1930 ALLOCATOR allocator,
1932 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1933 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1934 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1935 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1936 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
1937#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
1938
1939#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
1940 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1941 class ARGS_02,
1942 class ARGS_03,
1943 class ARGS_04,
1944 class ARGS_05,
1945 class ARGS_06>
1946 static void emplace(
1947 TARGET_TYPE *toBegin,
1948 TARGET_TYPE *toEnd,
1949 ALLOCATOR allocator,
1951 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1952 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1953 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1954 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1955 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1956 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
1957#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
1958
1959#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
1960 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1961 class ARGS_02,
1962 class ARGS_03,
1963 class ARGS_04,
1964 class ARGS_05,
1965 class ARGS_06,
1966 class ARGS_07>
1967 static void emplace(
1968 TARGET_TYPE *toBegin,
1969 TARGET_TYPE *toEnd,
1970 ALLOCATOR allocator,
1972 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1973 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1974 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1976 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1977 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1978 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
1979#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
1980
1981#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
1982 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1983 class ARGS_02,
1984 class ARGS_03,
1985 class ARGS_04,
1986 class ARGS_05,
1987 class ARGS_06,
1988 class ARGS_07,
1989 class ARGS_08>
1990 static void emplace(
1991 TARGET_TYPE *toBegin,
1992 TARGET_TYPE *toEnd,
1993 ALLOCATOR allocator,
1995 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1996 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1997 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1998 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1999 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2000 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2001 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2002 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2003#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2004
2005#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2006 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2007 class ARGS_02,
2008 class ARGS_03,
2009 class ARGS_04,
2010 class ARGS_05,
2011 class ARGS_06,
2012 class ARGS_07,
2013 class ARGS_08,
2014 class ARGS_09>
2015 static void emplace(
2016 TARGET_TYPE *toBegin,
2017 TARGET_TYPE *toEnd,
2018 ALLOCATOR allocator,
2020 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2021 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2022 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2023 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2024 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2025 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2026 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2027 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2028 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2029#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2030
2031#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2032 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2033 class ARGS_02,
2034 class ARGS_03,
2035 class ARGS_04,
2036 class ARGS_05,
2037 class ARGS_06,
2038 class ARGS_07,
2039 class ARGS_08,
2040 class ARGS_09,
2041 class ARGS_10>
2042 static void emplace(
2043 TARGET_TYPE *toBegin,
2044 TARGET_TYPE *toEnd,
2045 ALLOCATOR allocator,
2047 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2048 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2049 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2050 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2051 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2052 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2053 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2054 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2055 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2056 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2057#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2058
2059#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2060 template <class TARGET_TYPE, class ALLOCATOR>
2061 static void emplace(
2062 TARGET_TYPE *toBegin,
2063 TARGET_TYPE *toEnd,
2064 ALLOCATOR allocator,
2066#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2067
2068#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2069 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
2070 static void emplace(
2071 TARGET_TYPE *toBegin,
2072 TARGET_TYPE *toEnd,
2073 ALLOCATOR allocator,
2075 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
2076#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2077
2078#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2079 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2080 class ARGS_02>
2081 static void emplace(
2082 TARGET_TYPE *toBegin,
2083 TARGET_TYPE *toEnd,
2084 ALLOCATOR allocator,
2086 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2087 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2088#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2089
2090#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2091 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2092 class ARGS_02,
2093 class ARGS_03>
2094 static void emplace(
2095 TARGET_TYPE *toBegin,
2096 TARGET_TYPE *toEnd,
2097 ALLOCATOR allocator,
2099 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2100 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2101 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2102#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2103
2104#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2105 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2106 class ARGS_02,
2107 class ARGS_03,
2108 class ARGS_04>
2109 static void emplace(
2110 TARGET_TYPE *toBegin,
2111 TARGET_TYPE *toEnd,
2112 ALLOCATOR allocator,
2114 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2115 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2116 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2117 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2118#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2119
2120#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2121 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2122 class ARGS_02,
2123 class ARGS_03,
2124 class ARGS_04,
2125 class ARGS_05>
2126 static void emplace(
2127 TARGET_TYPE *toBegin,
2128 TARGET_TYPE *toEnd,
2129 ALLOCATOR allocator,
2131 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2132 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2133 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2134 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2135 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2136#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2137
2138#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2139 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2140 class ARGS_02,
2141 class ARGS_03,
2142 class ARGS_04,
2143 class ARGS_05,
2144 class ARGS_06>
2145 static void emplace(
2146 TARGET_TYPE *toBegin,
2147 TARGET_TYPE *toEnd,
2148 ALLOCATOR allocator,
2150 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2151 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2152 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2153 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2154 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2156#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2157
2158#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2159 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2160 class ARGS_02,
2161 class ARGS_03,
2162 class ARGS_04,
2163 class ARGS_05,
2164 class ARGS_06,
2165 class ARGS_07>
2166 static void emplace(
2167 TARGET_TYPE *toBegin,
2168 TARGET_TYPE *toEnd,
2169 ALLOCATOR allocator,
2171 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2172 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2173 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2174 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2175 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2176 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2177 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2178#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2179
2180#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2181 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2182 class ARGS_02,
2183 class ARGS_03,
2184 class ARGS_04,
2185 class ARGS_05,
2186 class ARGS_06,
2187 class ARGS_07,
2188 class ARGS_08>
2189 static void emplace(
2190 TARGET_TYPE *toBegin,
2191 TARGET_TYPE *toEnd,
2192 ALLOCATOR allocator,
2194 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2195 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2196 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2197 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2198 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2199 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2200 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2201 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2202#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2203
2204#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2205 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2206 class ARGS_02,
2207 class ARGS_03,
2208 class ARGS_04,
2209 class ARGS_05,
2210 class ARGS_06,
2211 class ARGS_07,
2212 class ARGS_08,
2213 class ARGS_09>
2214 static void emplace(
2215 TARGET_TYPE *toBegin,
2216 TARGET_TYPE *toEnd,
2217 ALLOCATOR allocator,
2219 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2226 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2227 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2228#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2229
2230#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2231 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2232 class ARGS_02,
2233 class ARGS_03,
2234 class ARGS_04,
2235 class ARGS_05,
2236 class ARGS_06,
2237 class ARGS_07,
2238 class ARGS_08,
2239 class ARGS_09,
2240 class ARGS_10>
2241 static void emplace(
2242 TARGET_TYPE *toBegin,
2243 TARGET_TYPE *toEnd,
2244 ALLOCATOR allocator,
2246 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2247 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2248 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2249 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2250 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2251 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2252 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2253 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2254 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2255 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2256#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2257
2258#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2259 template <class TARGET_TYPE, class ALLOCATOR>
2260 static void emplace(
2261 TARGET_TYPE *toBegin,
2262 TARGET_TYPE *toEnd,
2263 ALLOCATOR allocator,
2265#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2266
2267#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2268 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
2269 static void emplace(
2270 TARGET_TYPE *toBegin,
2271 TARGET_TYPE *toEnd,
2272 ALLOCATOR allocator,
2274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
2275#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2276
2277#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2278 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2279 class ARGS_02>
2280 static void emplace(
2281 TARGET_TYPE *toBegin,
2282 TARGET_TYPE *toEnd,
2283 ALLOCATOR allocator,
2285 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2286 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2287#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2288
2289#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2290 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2291 class ARGS_02,
2292 class ARGS_03>
2293 static void emplace(
2294 TARGET_TYPE *toBegin,
2295 TARGET_TYPE *toEnd,
2296 ALLOCATOR allocator,
2298 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2299 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2300 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2301#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2302
2303#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2304 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2305 class ARGS_02,
2306 class ARGS_03,
2307 class ARGS_04>
2308 static void emplace(
2309 TARGET_TYPE *toBegin,
2310 TARGET_TYPE *toEnd,
2311 ALLOCATOR allocator,
2313 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2314 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2315 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2316 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2317#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2318
2319#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2320 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2321 class ARGS_02,
2322 class ARGS_03,
2323 class ARGS_04,
2324 class ARGS_05>
2325 static void emplace(
2326 TARGET_TYPE *toBegin,
2327 TARGET_TYPE *toEnd,
2328 ALLOCATOR allocator,
2330 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2331 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2332 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2333 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2334 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2335#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2336
2337#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2338 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2339 class ARGS_02,
2340 class ARGS_03,
2341 class ARGS_04,
2342 class ARGS_05,
2343 class ARGS_06>
2344 static void emplace(
2345 TARGET_TYPE *toBegin,
2346 TARGET_TYPE *toEnd,
2347 ALLOCATOR allocator,
2349 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2350 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2351 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2355#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2356
2357#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2358 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2359 class ARGS_02,
2360 class ARGS_03,
2361 class ARGS_04,
2362 class ARGS_05,
2363 class ARGS_06,
2364 class ARGS_07>
2365 static void emplace(
2366 TARGET_TYPE *toBegin,
2367 TARGET_TYPE *toEnd,
2368 ALLOCATOR allocator,
2370 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2371 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2374 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2375 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2376 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2377#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2378
2379#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2380 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2381 class ARGS_02,
2382 class ARGS_03,
2383 class ARGS_04,
2384 class ARGS_05,
2385 class ARGS_06,
2386 class ARGS_07,
2387 class ARGS_08>
2388 static void emplace(
2389 TARGET_TYPE *toBegin,
2390 TARGET_TYPE *toEnd,
2391 ALLOCATOR allocator,
2393 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2394 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2395 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2396 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2397 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2398 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2401#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2402
2403#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2404 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2405 class ARGS_02,
2406 class ARGS_03,
2407 class ARGS_04,
2408 class ARGS_05,
2409 class ARGS_06,
2410 class ARGS_07,
2411 class ARGS_08,
2412 class ARGS_09>
2413 static void emplace(
2414 TARGET_TYPE *toBegin,
2415 TARGET_TYPE *toEnd,
2416 ALLOCATOR allocator,
2418 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2419 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2420 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2421 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2422 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2423 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2424 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2425 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2426 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2427#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2428
2429#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2430 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2431 class ARGS_02,
2432 class ARGS_03,
2433 class ARGS_04,
2434 class ARGS_05,
2435 class ARGS_06,
2436 class ARGS_07,
2437 class ARGS_08,
2438 class ARGS_09,
2439 class ARGS_10>
2440 static void emplace(
2441 TARGET_TYPE *toBegin,
2442 TARGET_TYPE *toEnd,
2443 ALLOCATOR allocator,
2445 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2446 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2447 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2448 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2449 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2450 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2451 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2452 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2453 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2454 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2455#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2456
2457#else
2458// The generated code below is a workaround for the absence of perfect
2459// forwarding in some compilers.
2460 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2461 static void emplace(
2462 TARGET_TYPE *toBegin,
2463 TARGET_TYPE *toEnd,
2464 ALLOCATOR allocator,
2466 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2467 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2468 static void emplace(
2469 TARGET_TYPE *toBegin,
2470 TARGET_TYPE *toEnd,
2471 ALLOCATOR allocator,
2473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2474 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2475 static void emplace(
2476 TARGET_TYPE *toBegin,
2477 TARGET_TYPE *toEnd,
2478 ALLOCATOR allocator,
2480 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2481// }}} END GENERATED CODE
2482#endif
2483
2484 /// These functions follow the `erase` contract. Note that if (template
2485 /// parameter) `TARGET_TYPE` is bit-wise moveable, then this operation
2486 /// can be implemented by first bit-wise moving the elements in
2487 /// `[middle, last)` towards first, and destroying
2488 /// `[ last - (middle - first), last)`; note that this cannot throw
2489 /// exceptions.
2490 template <class TARGET_TYPE, class ALLOCATOR>
2491 static void erase(
2492 TARGET_TYPE *first,
2493 TARGET_TYPE *middle,
2494 TARGET_TYPE *last,
2495 ALLOCATOR allocator,
2497 template <class TARGET_TYPE, class ALLOCATOR>
2498 static void erase(
2499 TARGET_TYPE *first,
2500 TARGET_TYPE *middle,
2501 TARGET_TYPE *last,
2502 ALLOCATOR allocator,
2504
2505 /// These functions follow the `insert` contract. Note that if
2506 /// `TARGET_TYPE` is bit-wise copyable, then this operation is simply
2507 /// `memmove` followed by `bitwiseFillN`. If `TARGET_TYPE` is bit-wise
2508 /// moveable, then this operation can still be optimized using `memmove`
2509 /// followed by repeated assignments, but a guard needs to be set up.
2510 /// The last argument is for removing overload ambiguities and is not
2511 /// used.
2512 template <class TARGET_TYPE, class ALLOCATOR>
2513 static void insert(
2514 TARGET_TYPE *toBegin,
2515 TARGET_TYPE *toEnd,
2516 const TARGET_TYPE& value,
2517 size_type numElements,
2518 ALLOCATOR allocator,
2520 template <class TARGET_TYPE, class ALLOCATOR>
2521 static void insert(
2522 TARGET_TYPE *toBegin,
2523 TARGET_TYPE *toEnd,
2524 const TARGET_TYPE& value,
2525 size_type numElements,
2526 ALLOCATOR allocator,
2528 template <class TARGET_TYPE, class ALLOCATOR>
2529 static void insert(
2530 TARGET_TYPE *toBegin,
2531 TARGET_TYPE *toEnd,
2532 const TARGET_TYPE& value,
2533 size_type numElements,
2534 ALLOCATOR allocator,
2536
2537 /// These functions follow the `insert` contract. Note that if
2538 /// `TARGET_TYPE` is bit-wise copyable and `FWD_ITER` is convertible to
2539 /// `const TARGET_TYPE *`, then this operation is simply `memmove`
2540 /// followed by `memcpy`. If `TARGET_TYPE` is bit-wise moveable and
2541 /// `FWD_ITER` is convertible to `const TARGET_TYPE *`, then this
2542 /// operation can still be optimized using `memmove` followed by
2543 /// repeated copies. The last argument is for removing overload
2544 /// ambiguities and is not used.
2545 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
2546 static void insert(
2547 TARGET_TYPE *toBegin,
2548 TARGET_TYPE *toEnd,
2549 FWD_ITER fromBegin,
2550 FWD_ITER fromEnd,
2551 size_type numElements,
2552 ALLOCATOR allocator,
2554 template <class TARGET_TYPE, class ALLOCATOR>
2555 static void insert(
2556 TARGET_TYPE *toBegin,
2557 TARGET_TYPE *toEnd,
2558 const TARGET_TYPE *fromBegin,
2559 const TARGET_TYPE *fromEnd,
2560 size_type numElements,
2561 ALLOCATOR allocator,
2563 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
2564 static void insert(
2565 TARGET_TYPE *toBegin,
2566 TARGET_TYPE *toEnd,
2567 FWD_ITER fromBegin,
2568 FWD_ITER fromEnd,
2569 size_type numElements,
2570 ALLOCATOR allocator,
2572 template <class FWD_ITER, class ALLOCATOR>
2573 static void insert(
2574 void **toBegin,
2575 void **toEnd,
2576 FWD_ITER fromBegin,
2577 FWD_ITER fromEnd,
2578 size_type numElements,
2579 ALLOCATOR allocator,
2581 template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
2582 static void insert(
2583 TARGET_TYPE *toBegin,
2584 TARGET_TYPE *toEnd,
2585 FWD_ITER fromBegin,
2586 FWD_ITER fromEnd,
2587 size_type numElements,
2588 ALLOCATOR allocator,
2590
2591 /// These functions follow the `moveInsert` contract. Note that if
2592 /// `TARGET_TYPE` is at least bit-wise moveable, then this operation is
2593 /// simply `memmove` followed by `memcpy`.
2594 template <class TARGET_TYPE, class ALLOCATOR>
2595 static void moveInsert(
2596 TARGET_TYPE *toBegin,
2597 TARGET_TYPE *toEnd,
2598 TARGET_TYPE **lastPtr,
2599 TARGET_TYPE *first,
2600 TARGET_TYPE *last,
2601 size_type numElements,
2602 ALLOCATOR allocator,
2604 template <class TARGET_TYPE, class ALLOCATOR>
2605 static void moveInsert(
2606 TARGET_TYPE *toBegin,
2607 TARGET_TYPE *toEnd,
2608 TARGET_TYPE **lastPtr,
2609 TARGET_TYPE *first,
2610 TARGET_TYPE *last,
2611 size_type numElements,
2612 ALLOCATOR allocator,
2614
2615 /// These functions follow the `rotate` contract, but the first overload
2616 /// is optimized when the parameterized `TARGET_TYPE` is bit-wise
2617 /// moveable. The last argument is for removing overload ambiguities
2618 /// and is not used. Note that if `TARGET_TYPE` is bit-wise moveable,
2619 /// the `rotate(char*, char*, char*)` can be used, enabling to take the
2620 /// whole implementation out-of-line.
2621 template <class TARGET_TYPE>
2622 static void rotate(
2623 TARGET_TYPE *begin,
2624 TARGET_TYPE *middle,
2625 TARGET_TYPE *end,
2627 template <class TARGET_TYPE>
2628 static void rotate(
2629 TARGET_TYPE *begin,
2630 TARGET_TYPE *middle,
2631 TARGET_TYPE *end,
2633
2634 /// Shift the specified `[begin, end)` sequence one position right, then
2635 /// insert the specified `value` at the position pointed by `begin`.
2636 /// The specified `allocator` is used for the element construction. The
2637 /// behavior is undefined unless the specified `[begin, end)` sequence
2638 /// contains at least one element.
2639 template <class ALLOCATOR>
2640 static void shiftAndInsert(
2645 ALLOCATOR allocator,
2647 template <class ALLOCATOR>
2648 static void shiftAndInsert(
2653 ALLOCATOR allocator,
2655 template <class ALLOCATOR>
2656 static void shiftAndInsert(
2661 ALLOCATOR allocator,
2663
2664 // 'bitwise' METHODS
2665
2666 /// This function follows the `rotate` contract, but by using bit-wise
2667 /// moves on the underlying `char` array.
2668 static void bitwiseRotate(char *begin, char *middle, char *end);
2669
2670 /// Move the characters in the array starting at the specified `first`
2671 /// address and ending immediately before the specified `middle` address
2672 /// to the array of the same length ending at the specified `last`
2673 /// address (and thus starting at the `last - (middle - first)`
2674 /// address), and move the elements previously in the array starting at
2675 /// `middle` and ending at `last` down to the `first` address. The
2676 /// behavior is undefined unless
2677 /// `middle - begin <= k_INPLACE_BUFFER_SIZE`.
2678 static void bitwiseRotateBackward(char *begin, char *middle, char *end);
2679
2680 /// Move the characters in the array starting at the specified `first`
2681 /// address and ending immediately before the specified `middle` address
2682 /// to the array of the same length ending at the specified `last`
2683 /// address (and thus starting at the `last - (middle - first)`
2684 /// address), and move the elements previously in the array starting at
2685 /// `middle` and ending at `last` down to the `first` address. The
2686 /// behavior is undefined unless
2687 /// `end - middle <= k_INPLACE_BUFFER_SIZE`.
2688 static void bitwiseRotateForward(char *begin, char *middle, char *end);
2689
2690 /// Swap the characters in the array starting at the specified `first`
2691 /// address and ending immediately before the specified `middle` address
2692 /// with the array of the same length starting at the `middle` address
2693 /// and ending at the specified `last` address. The behavior is
2694 /// undefined unless `middle - begin == end - middle`.
2695 static void bitwiseSwapRanges(char *begin, char *middle, char *end);
2696
2697 /// Return `true` if the specified `begin` and the specified `end`
2698 /// provably do not form a valid semi-open range, `[begin, end)`, and
2699 /// `false` otherwise. Note that `begin == null == end` produces a
2700 /// valid range, and any other use of the null pointer value will return
2701 /// `true`. Also note that this function is intended to support
2702 /// testing, primarily through assertions, so will return `false` unless
2703 /// it can *prove* that the passed range is invalid. Currently, this
2704 /// function can prove invalid ranges only for pointers, although should
2705 /// also encompass generic random access iterators in a future update,
2706 /// where iterator tag types are levelized below `bslalg`.
2707 template <class FORWARD_ITERATOR>
2708 static bool isInvalidRange(FORWARD_ITERATOR begin, FORWARD_ITERATOR end);
2709 template <class TARGET_TYPE>
2710 static bool isInvalidRange(TARGET_TYPE *begin, TARGET_TYPE *end);
2711};
2712
2713// ============================================================================
2714// INLINE FUNCTION DEFINITIONS
2715// ============================================================================
2716// IMPLEMENTATION NOTES: Specializations of 'uninitializedFillN' for most
2717// fundamental types are not templates nor inline, and thus can be found in the
2718// '.cpp' file.
2719
2720 // =====================================
2721 // struct ArrayPrimitives_CanBitwiseCopy
2722 // =====================================
2723
2724template <class FROM_TYPE, class TO_TYPE>
2725struct ArrayPrimitives_CanBitwiseCopy
2727 bsl::is_same<
2728 typename bsl::remove_const<FROM_TYPE>::type,
2729 typename bsl::remove_const<TO_TYPE >::type>
2730 ::value
2731 && bslmf::IsBitwiseCopyable<
2732 typename bsl::remove_const<TO_TYPE >::type>
2733 ::value
2734 > {
2735};
2736
2737 // ----------------------
2738 // struct ArrayPrimitives
2739 // ----------------------
2740
2741template <class ALLOCATOR>
2742inline
2745 size_type numElements,
2747 ALLOCATOR allocator)
2748{
2749 BSLS_ASSERT_SAFE(begin || 0 == numElements);
2751
2752 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2753
2754 enum {
2755 // We provide specialized overloads of 'uninitializedFillN' for
2756 // fundamental and pointer types. However, function pointers can have
2757 // extern "C" linkage and SunPro doesn't match them properly with the
2758 // pointer template function overload in 'Imp', so we resort to the
2759 // general case for those.
2760
2761 k_IS_FUNCTION_POINTER = bslmf::IsFunctionPointer<TargetType>::value,
2762 k_IS_FUNDAMENTAL = bsl::is_fundamental<TargetType>::value,
2764
2765 k_IS_FUNDAMENTAL_OR_POINTER = k_IS_FUNDAMENTAL ||
2766 (k_IS_POINTER && !k_IS_FUNCTION_POINTER),
2767
2768 k_IS_BITWISECOPYABLE = bslmf::IsBitwiseCopyable<TargetType>::value,
2769
2770 k_VALUE =
2771 k_IS_FUNDAMENTAL_OR_POINTER ? Imp::e_IS_FUNDAMENTAL_OR_POINTER
2772 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
2773 : Imp::e_NIL_TRAITS
2774 };
2776 begin,
2777 value,
2778 numElements,
2779 &allocator,
2781}
2782
2783template <class TARGET_TYPE>
2784inline
2785void ArrayPrimitives::uninitializedFillN(TARGET_TYPE *begin,
2786 size_type numElements,
2787 const TARGET_TYPE& value,
2788 bslma::Allocator *basicAllocator)
2789{
2790 uninitializedFillN<bsl::allocator<TARGET_TYPE> >(begin,
2791 numElements,
2792 value,
2793 basicAllocator);
2794}
2795
2796template <class ALLOCATOR, class FWD_ITER>
2799 FWD_ITER fromBegin,
2800 FWD_ITER fromEnd,
2801 ALLOCATOR allocator)
2802{
2803 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
2804
2806 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2807
2808 /// Overload resolution will handle the case where `FWD_ITER` is a raw
2809 /// pointer, so we need handle only user-defined iterators. As `bslalg`
2810 /// is levelized below `bslstl` we cannot use `iterator_traits`, but
2811 /// rely on the same property as `iterator_traits` that this typedef
2812 /// must be defined for any standard-conforming iterator, unless the
2813 /// iterator explicitly specialized the `std::iterator_traits` template.
2814 /// In practice, iterators always prefer to provide the member typedef
2815 /// than specialize the traits as it is a much simpler implementation,
2816 /// so this assumption is good enough.
2817 ///
2818 /// Also note that as we know that `FWD_ITER` is not a pointer, then we
2819 /// cannot take advantage of bitwise copying as we do not have pointers
2820 /// to pass to the `memcpy` describing the whole range. It is not worth
2821 /// the effort to try to bitwise copy one element at a time.
2822 typedef typename FWD_ITER::value_type FwdTarget;
2823
2824 /// We want to detect the special case of copying function pointers to
2825 /// `void *` or `const void *` pointers.
2826 typedef typename bsl::remove_pointer<TargetType>::type RemovePtrTarget;
2827
2828 enum {
2829 k_ITER_TO_FUNC_PTRS = bslmf::IsFunctionPointer<FwdTarget>::value,
2830 k_TARGET_IS_VOID_PTR = bsl::is_pointer<TargetType>::value &&
2832
2833 k_VALUE = k_ITER_TO_FUNC_PTRS && k_TARGET_IS_VOID_PTR
2836 };
2837
2839 fromBegin,
2840 fromEnd,
2841 allocator,
2843}
2844
2845template <class TARGET_TYPE, class FWD_ITER>
2846inline
2847void ArrayPrimitives::copyConstruct(TARGET_TYPE *toBegin,
2848 FWD_ITER fromBegin,
2849 FWD_ITER fromEnd,
2850 bslma::Allocator *basicAllocator)
2851{
2852 copyConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
2853 fromBegin,
2854 fromEnd,
2855 basicAllocator);
2856}
2857
2858template <class ALLOCATOR, class SOURCE_TYPE>
2859inline
2862 SOURCE_TYPE *fromBegin,
2863 SOURCE_TYPE *fromEnd,
2864 ALLOCATOR allocator)
2865{
2866 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
2867
2868 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2869
2870 enum {
2871 k_ARE_PTRS_TO_PTRS = bsl::is_pointer<TargetType>::value &&
2873 k_IS_BITWISECOPYABLE =
2875 k_VALUE = k_ARE_PTRS_TO_PTRS ? Imp::e_IS_POINTER_TO_POINTER
2876 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
2878 };
2879
2881 fromBegin,
2882 fromEnd,
2883 allocator,
2885}
2886
2887template <class TARGET_TYPE, class SOURCE_TYPE>
2888inline
2889void ArrayPrimitives::copyConstruct(TARGET_TYPE *toBegin,
2890 SOURCE_TYPE *fromBegin,
2891 SOURCE_TYPE *fromEnd,
2892 bslma::Allocator *basicAllocator)
2893{
2894 copyConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
2895 fromBegin,
2896 fromEnd,
2897 basicAllocator);
2898}
2899
2900template <class ALLOCATOR>
2901inline
2904 size_type numElements,
2905 ALLOCATOR allocator)
2906{
2908 BSLS_ASSERT_SAFE(begin || 0 == numElements);
2909
2910 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2911
2912 enum {
2916#if !defined(BSLALG_ARRAYPRIMITIVES_NON_ZERO_NULL_VALUE_FOR_MEMBER_POINTERS)
2918#endif
2924 };
2926 begin,
2927 numElements,
2928 allocator,
2930}
2931
2932template <class TARGET_TYPE>
2933inline
2934void ArrayPrimitives::defaultConstruct(TARGET_TYPE *begin,
2935 size_type numElements,
2936 bslma::Allocator *basicAllocator)
2937{
2938 defaultConstruct<bsl::allocator<TARGET_TYPE> >(begin,
2939 numElements,
2940 basicAllocator);
2941}
2942
2943template <class ALLOCATOR>
2944inline
2949 ALLOCATOR allocator)
2950{
2951 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
2953
2954 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2955
2956 enum {
2960 };
2962 toBegin,
2963 fromBegin,
2964 fromEnd,
2965 allocator,
2967}
2968
2969template <class TARGET_TYPE>
2970inline
2971void ArrayPrimitives::destructiveMove(TARGET_TYPE *toBegin,
2972 TARGET_TYPE *fromBegin,
2973 TARGET_TYPE *fromEnd,
2974 bslma::Allocator *basicAllocator)
2975{
2976 destructiveMove<bsl::allocator<TARGET_TYPE> >(toBegin,
2977 fromBegin,
2978 fromEnd,
2979 basicAllocator);
2980}
2981
2982#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2983// {{{ BEGIN GENERATED CODE
2984// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
2985#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
2986#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
2987#endif
2988#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D
2989#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
2990#endif
2991#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 0
2992template <class ALLOCATOR>
2995 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
2999 ALLOCATOR allocator)
3000{
3001
3002 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3003
3004 *fromEndPtr = fromEnd;
3005
3006
3007 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3008
3010 allocator,
3011 toPositionBegin);
3012
3013 TargetType *toPositionEnd = toPositionBegin + 1;
3014
3015 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3016 toPositionEnd,
3017 allocator);
3018
3019
3020 destructiveMove(toPositionEnd,
3021 position,
3022 fromEnd,
3023 allocator);
3024
3025 *fromEndPtr = position;
3026 guard.moveEnd(fromEnd - position);
3027
3028
3029 destructiveMove(toBegin,
3030 fromBegin,
3031 position,
3032 allocator);
3033
3034 *fromEndPtr = fromBegin;
3035 guard.release();
3036}
3037#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 0
3038
3039#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 1
3040template <class ALLOCATOR, class ARGS_01>
3043 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3047 ALLOCATOR allocator,
3048 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01)
3049{
3050
3051 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3052
3053 *fromEndPtr = fromEnd;
3054
3055
3056 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3057
3059 allocator,
3060 toPositionBegin,
3061 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01));
3062
3063 TargetType *toPositionEnd = toPositionBegin + 1;
3064
3065 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3066 toPositionEnd,
3067 allocator);
3068
3069
3070 destructiveMove(toPositionEnd,
3071 position,
3072 fromEnd,
3073 allocator);
3074
3075 *fromEndPtr = position;
3076 guard.moveEnd(fromEnd - position);
3077
3078
3079 destructiveMove(toBegin,
3080 fromBegin,
3081 position,
3082 allocator);
3083
3084 *fromEndPtr = fromBegin;
3085 guard.release();
3086}
3087#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 1
3088
3089#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 2
3090template <class ALLOCATOR, class ARGS_01,
3091 class ARGS_02>
3094 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3098 ALLOCATOR allocator,
3099 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3100 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02)
3101{
3102
3103 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3104
3105 *fromEndPtr = fromEnd;
3106
3107
3108 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3109
3111 allocator,
3112 toPositionBegin,
3113 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3114 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02));
3115
3116 TargetType *toPositionEnd = toPositionBegin + 1;
3117
3118 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3119 toPositionEnd,
3120 allocator);
3121
3122
3123 destructiveMove(toPositionEnd,
3124 position,
3125 fromEnd,
3126 allocator);
3127
3128 *fromEndPtr = position;
3129 guard.moveEnd(fromEnd - position);
3130
3131
3132 destructiveMove(toBegin,
3133 fromBegin,
3134 position,
3135 allocator);
3136
3137 *fromEndPtr = fromBegin;
3138 guard.release();
3139}
3140#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 2
3141
3142#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 3
3143template <class ALLOCATOR, class ARGS_01,
3144 class ARGS_02,
3145 class ARGS_03>
3148 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3152 ALLOCATOR allocator,
3153 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3154 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03)
3156{
3157
3158 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3159
3160 *fromEndPtr = fromEnd;
3161
3162
3163 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3164
3166 allocator,
3167 toPositionBegin,
3168 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3169 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3170 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03));
3171
3172 TargetType *toPositionEnd = toPositionBegin + 1;
3173
3174 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3175 toPositionEnd,
3176 allocator);
3177
3178
3179 destructiveMove(toPositionEnd,
3180 position,
3181 fromEnd,
3182 allocator);
3183
3184 *fromEndPtr = position;
3185 guard.moveEnd(fromEnd - position);
3186
3187
3188 destructiveMove(toBegin,
3189 fromBegin,
3190 position,
3191 allocator);
3192
3193 *fromEndPtr = fromBegin;
3194 guard.release();
3195}
3196#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 3
3197
3198#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 4
3199template <class ALLOCATOR, class ARGS_01,
3200 class ARGS_02,
3201 class ARGS_03,
3202 class ARGS_04>
3205 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3209 ALLOCATOR allocator,
3210 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3211 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3212 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3213 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04)
3214{
3215
3216 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3217
3218 *fromEndPtr = fromEnd;
3219
3220
3221 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3222
3224 allocator,
3225 toPositionBegin,
3226 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3227 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3228 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3229 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04));
3230
3231 TargetType *toPositionEnd = toPositionBegin + 1;
3232
3233 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3234 toPositionEnd,
3235 allocator);
3236
3237
3238 destructiveMove(toPositionEnd,
3239 position,
3240 fromEnd,
3241 allocator);
3242
3243 *fromEndPtr = position;
3244 guard.moveEnd(fromEnd - position);
3245
3246
3247 destructiveMove(toBegin,
3248 fromBegin,
3249 position,
3250 allocator);
3251
3252 *fromEndPtr = fromBegin;
3253 guard.release();
3254}
3255#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 4
3256
3257#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 5
3258template <class ALLOCATOR, class ARGS_01,
3259 class ARGS_02,
3260 class ARGS_03,
3261 class ARGS_04,
3262 class ARGS_05>
3265 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3269 ALLOCATOR allocator,
3270 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3271 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3272 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3273 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05)
3275{
3276
3277 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3278
3279 *fromEndPtr = fromEnd;
3280
3281
3282 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3283
3285 allocator,
3286 toPositionBegin,
3287 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3288 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3289 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3290 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3291 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05));
3292
3293 TargetType *toPositionEnd = toPositionBegin + 1;
3294
3295 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3296 toPositionEnd,
3297 allocator);
3298
3299
3300 destructiveMove(toPositionEnd,
3301 position,
3302 fromEnd,
3303 allocator);
3304
3305 *fromEndPtr = position;
3306 guard.moveEnd(fromEnd - position);
3307
3308
3309 destructiveMove(toBegin,
3310 fromBegin,
3311 position,
3312 allocator);
3313
3314 *fromEndPtr = fromBegin;
3315 guard.release();
3316}
3317#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 5
3318
3319#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 6
3320template <class ALLOCATOR, class ARGS_01,
3321 class ARGS_02,
3322 class ARGS_03,
3323 class ARGS_04,
3324 class ARGS_05,
3325 class ARGS_06>
3328 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3332 ALLOCATOR allocator,
3333 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3334 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3335 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3336 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3337 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3338 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06)
3339{
3340
3341 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3342
3343 *fromEndPtr = fromEnd;
3344
3345
3346 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3347
3349 allocator,
3350 toPositionBegin,
3351 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3352 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3353 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3354 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3355 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3356 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06));
3357
3358 TargetType *toPositionEnd = toPositionBegin + 1;
3359
3360 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3361 toPositionEnd,
3362 allocator);
3363
3364
3365 destructiveMove(toPositionEnd,
3366 position,
3367 fromEnd,
3368 allocator);
3369
3370 *fromEndPtr = position;
3371 guard.moveEnd(fromEnd - position);
3372
3373
3374 destructiveMove(toBegin,
3375 fromBegin,
3376 position,
3377 allocator);
3378
3379 *fromEndPtr = fromBegin;
3380 guard.release();
3381}
3382#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 6
3383
3384#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 7
3385template <class ALLOCATOR, class ARGS_01,
3386 class ARGS_02,
3387 class ARGS_03,
3388 class ARGS_04,
3389 class ARGS_05,
3390 class ARGS_06,
3391 class ARGS_07>
3394 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3398 ALLOCATOR allocator,
3399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3401 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3402 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3404 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3405 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07)
3406{
3407
3408 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3409
3410 *fromEndPtr = fromEnd;
3411
3412
3413 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3414
3416 allocator,
3417 toPositionBegin,
3418 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3419 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3420 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3421 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3422 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3423 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3424 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07));
3425
3426 TargetType *toPositionEnd = toPositionBegin + 1;
3427
3428 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3429 toPositionEnd,
3430 allocator);
3431
3432
3433 destructiveMove(toPositionEnd,
3434 position,
3435 fromEnd,
3436 allocator);
3437
3438 *fromEndPtr = position;
3439 guard.moveEnd(fromEnd - position);
3440
3441
3442 destructiveMove(toBegin,
3443 fromBegin,
3444 position,
3445 allocator);
3446
3447 *fromEndPtr = fromBegin;
3448 guard.release();
3449}
3450#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 7
3451
3452#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 8
3453template <class ALLOCATOR, class ARGS_01,
3454 class ARGS_02,
3455 class ARGS_03,
3456 class ARGS_04,
3457 class ARGS_05,
3458 class ARGS_06,
3459 class ARGS_07,
3460 class ARGS_08>
3463 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3467 ALLOCATOR allocator,
3468 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3469 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3470 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3471 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3472 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3473 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3474 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3475 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08)
3476{
3477
3478 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3479
3480 *fromEndPtr = fromEnd;
3481
3482
3483 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3484
3486 allocator,
3487 toPositionBegin,
3488 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3489 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3490 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3491 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3492 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3493 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3494 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3495 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08));
3496
3497 TargetType *toPositionEnd = toPositionBegin + 1;
3498
3499 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3500 toPositionEnd,
3501 allocator);
3502
3503
3504 destructiveMove(toPositionEnd,
3505 position,
3506 fromEnd,
3507 allocator);
3508
3509 *fromEndPtr = position;
3510 guard.moveEnd(fromEnd - position);
3511
3512
3513 destructiveMove(toBegin,
3514 fromBegin,
3515 position,
3516 allocator);
3517
3518 *fromEndPtr = fromBegin;
3519 guard.release();
3520}
3521#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 8
3522
3523#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 9
3524template <class ALLOCATOR, class ARGS_01,
3525 class ARGS_02,
3526 class ARGS_03,
3527 class ARGS_04,
3528 class ARGS_05,
3529 class ARGS_06,
3530 class ARGS_07,
3531 class ARGS_08,
3532 class ARGS_09>
3535 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3539 ALLOCATOR allocator,
3540 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3541 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3542 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3543 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3544 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3545 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3546 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3547 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
3548 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09)
3549{
3550
3551 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3552
3553 *fromEndPtr = fromEnd;
3554
3555
3556 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3557
3559 allocator,
3560 toPositionBegin,
3561 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3562 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3563 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3564 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3565 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3566 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3567 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3568 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08),
3569 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,arguments_09));
3570
3571 TargetType *toPositionEnd = toPositionBegin + 1;
3572
3573 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3574 toPositionEnd,
3575 allocator);
3576
3577
3578 destructiveMove(toPositionEnd,
3579 position,
3580 fromEnd,
3581 allocator);
3582
3583 *fromEndPtr = position;
3584 guard.moveEnd(fromEnd - position);
3585
3586
3587 destructiveMove(toBegin,
3588 fromBegin,
3589 position,
3590 allocator);
3591
3592 *fromEndPtr = fromBegin;
3593 guard.release();
3594}
3595#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 9
3596
3597#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 10
3598template <class ALLOCATOR, class ARGS_01,
3599 class ARGS_02,
3600 class ARGS_03,
3601 class ARGS_04,
3602 class ARGS_05,
3603 class ARGS_06,
3604 class ARGS_07,
3605 class ARGS_08,
3606 class ARGS_09,
3607 class ARGS_10>
3610 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3614 ALLOCATOR allocator,
3615 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3616 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3617 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3618 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3619 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3620 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3621 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3622 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
3623 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
3624 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10)
3625{
3626
3627 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3628
3629 *fromEndPtr = fromEnd;
3630
3631
3632 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3633
3635 allocator,
3636 toPositionBegin,
3637 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3638 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3639 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3640 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3641 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3642 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3643 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3644 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08),
3645 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,arguments_09),
3646 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,arguments_10));
3647
3648 TargetType *toPositionEnd = toPositionBegin + 1;
3649
3650 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3651 toPositionEnd,
3652 allocator);
3653
3654
3655 destructiveMove(toPositionEnd,
3656 position,
3657 fromEnd,
3658 allocator);
3659
3660 *fromEndPtr = position;
3661 guard.moveEnd(fromEnd - position);
3662
3663
3664 destructiveMove(toBegin,
3665 fromBegin,
3666 position,
3667 allocator);
3668
3669 *fromEndPtr = fromBegin;
3670 guard.release();
3671}
3672#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 10
3673
3674#else
3675// The generated code below is a workaround for the absence of perfect
3676// forwarding in some compilers.
3677template <class ALLOCATOR, class... ARGS>
3680 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3684 ALLOCATOR allocator,
3685 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments)
3686{
3687
3688 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3689
3690 *fromEndPtr = fromEnd;
3691
3692
3693 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3694
3696 allocator,
3697 toPositionBegin,
3698 BSLS_COMPILERFEATURES_FORWARD(ARGS,arguments)...);
3699
3700 TargetType *toPositionEnd = toPositionBegin + 1;
3701
3702 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3703 toPositionEnd,
3704 allocator);
3705
3706
3707 destructiveMove(toPositionEnd,
3708 position,
3709 fromEnd,
3710 allocator);
3711
3712 *fromEndPtr = position;
3713 guard.moveEnd(fromEnd - position);
3714
3715
3716 destructiveMove(toBegin,
3717 fromBegin,
3718 position,
3719 allocator);
3720
3721 *fromEndPtr = fromBegin;
3722 guard.release();
3723}
3724// }}} END GENERATED CODE
3725#endif
3726
3727template <class ALLOCATOR>
3730 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3734 size_type numElements,
3735 ALLOCATOR allocator)
3736{
3737 // Key to the transformation diagrams:
3738 //..
3739 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3740 // v...v default-constructed values ("input")
3741 // ; ... contents of '[toBegin, toEnd)' ("destination")
3742 // ..:.. position of 'fromEndPtr' in the input
3743 // _____ uninitialized array elements
3744 // [...] part of array protected by an exception guard object
3745 //..
3746
3747 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3748
3749 *fromEndPtr = fromEnd;
3750
3751 // Note: Construct default values.
3752 //..
3753 // Transformation: ABCDEFGH: ; _____________[]
3754 // => ABCDEFGH: ; ____[vvvvv]____
3755 //..
3756
3757 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3758 defaultConstruct(toPositionBegin, numElements, allocator);
3759
3760 TargetType *toPositionEnd = toPositionBegin + numElements;
3761
3762 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3763 toPositionEnd,
3764 allocator);
3765
3766 //..
3767 // Transformation: ABCDEFGH: ; ____[vvvvv]____
3768 // => ABCD:____ ; ____[vvvvvEFGH]
3769 //..
3770
3771 destructiveMove(toPositionEnd,
3772 position,
3773 fromEnd,
3774 allocator);
3775
3776 *fromEndPtr = position; // shorten input range after partial destruction
3777 guard.moveEnd(fromEnd - position); // toEnd
3778
3779 //..
3780 // Transformation: ABCD:____ ; ____[vvvvvEFGH]
3781 // => :________ ; ABCDvvvvvEFGH[]
3782 //..
3783
3784 destructiveMove(toBegin,
3785 fromBegin,
3786 position,
3787 allocator);
3788
3789 *fromEndPtr = fromBegin; // empty input range after final destruction
3790 guard.release();
3791}
3792
3793template <class TARGET_TYPE>
3794inline
3796 TARGET_TYPE *toBegin,
3797 TARGET_TYPE **fromEndPtr,
3798 TARGET_TYPE *fromBegin,
3799 TARGET_TYPE *position,
3800 TARGET_TYPE *fromEnd,
3801 size_type numElements,
3802 bslma::Allocator *basicAllocator)
3803{
3804 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
3805 fromEndPtr,
3806 fromBegin,
3807 position,
3808 fromEnd,
3809 numElements,
3810 basicAllocator);
3811}
3812
3813template <class ALLOCATOR>
3816 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3821 size_type numElements,
3822 ALLOCATOR allocator)
3823{
3824 // Key to the transformation diagrams:
3825 //..
3826 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3827 // v...v copies of 'value' ("input")
3828 // ; ... contents of '[toBegin, toEnd)' ("destination")
3829 // ..:.. position of 'fromEndPtr' in the input
3830 // _____ uninitialized array elements
3831 // [...] part of array protected by an exception guard object
3832 //..
3833
3834 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3835
3836 *fromEndPtr = fromEnd;
3837
3838 // Note: Construct copies of 'value' first in case 'value' is a reference
3839 // in the input range, which would be invalidated by any of the following
3840 // moves.
3841 //
3842 //..
3843 // Transformation: ABCDEFGH: ; _____________[]
3844 // => ABCDEFGH: ; ____[vvvvv]____
3845 //..
3846
3847 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3848 uninitializedFillN(toPositionBegin, numElements, value, allocator);
3849
3850 TargetType *toPositionEnd = toPositionBegin + numElements;
3851
3852 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3853 toPositionEnd,
3854 allocator);
3855
3856 //..
3857 // Transformation: ABCDEFGH: ; ____[vvvvv]____
3858 // => ABCD:____ ; ____[vvvvvEFGH]
3859 //..
3860
3861 destructiveMove(toPositionEnd,
3862 position,
3863 fromEnd,
3864 allocator);
3865
3866 *fromEndPtr = position; // shorten input range after partial destruction
3867 guard.moveEnd(fromEnd - position); // toEnd
3868
3869 //..
3870 // Transformation: ABCD:____ ; ____[vvvvvEFGH]
3871 // => :________ ; ABCDvvvvvEFGH[]
3872 //..
3873
3874 destructiveMove(toBegin,
3875 fromBegin,
3876 position,
3877 allocator);
3878
3879 *fromEndPtr = fromBegin; // empty input range after final destruction
3880 guard.release();
3881}
3882
3883template <class TARGET_TYPE>
3885 TARGET_TYPE *toBegin,
3886 TARGET_TYPE **fromEndPtr,
3887 TARGET_TYPE *fromBegin,
3888 TARGET_TYPE *position,
3889 TARGET_TYPE *fromEnd,
3890 const TARGET_TYPE& value,
3891 size_type numElements,
3892 bslma::Allocator *basicAllocator)
3893{
3894 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
3895 fromEndPtr,
3896 fromBegin,
3897 position,
3898 fromEnd,
3899 value,
3900 numElements,
3901 basicAllocator);
3902}
3903
3904template <class ALLOCATOR, class FWD_ITER>
3907 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3911 FWD_ITER first,
3912 FWD_ITER last,
3913 size_type numElements,
3914 ALLOCATOR allocator)
3915{
3916 // Key to the transformation diagrams:
3917 //..
3918 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3919 // t...z original contents of '[first, last)' ("input")
3920 // ; ... contents of '[toBegin, toEnd)' ("destination")
3921 // ..:.. position of 'fromEndPtr' in the input
3922 // _____ uninitialized array elements
3923 // [...] part of array protected by an exception guard object
3924 //..
3925
3926 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3927
3928 *fromEndPtr = fromEnd;
3929
3930 // Note: Construct copies of 'value' first in case 'value' is a reference
3931 // in the input range, which would be invalidated by any of the following
3932 // moves:
3933 //..
3934 // Transformation: ABCDEFGH: ; _________[]____
3935 // => ABCDEFGH: ; ____[tuvxy]____
3936 //..
3937
3938 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3939 copyConstruct(toPositionBegin, first, last, allocator);
3940
3941 TargetType *toPositionEnd = toPositionBegin + numElements;
3942
3943 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3944 toPositionEnd,
3945 allocator);
3946
3947 //..
3948 // Transformation: ABCDEFGH: ; ____[tuvxy]____
3949 // => ABCD:____ ; ____[tuvxyEFGH]
3950 //..
3951
3952 destructiveMove(toPositionEnd,
3953 position,
3954 fromEnd,
3955 allocator);
3956
3957 *fromEndPtr = position; // shorten input range after partial destruction
3958 guard.moveEnd(fromEnd - position); // toEnd
3959
3960 //..
3961 // Transformation: ABCD:____ ; ____[tuvxyEFGH]
3962 // => :________ ; ABCDtuvxyEFGH[]
3963 //..
3964
3965 destructiveMove(toBegin,
3966 fromBegin,
3967 position,
3968 allocator);
3969
3970 *fromEndPtr = fromBegin; // empty input range after final destruction
3971 guard.release();
3972}
3973
3974template <class TARGET_TYPE, class FWD_ITER>
3975inline
3977 TARGET_TYPE *toBegin,
3978 TARGET_TYPE **fromEndPtr,
3979 TARGET_TYPE *fromBegin,
3980 TARGET_TYPE *position,
3981 TARGET_TYPE *fromEnd,
3982 FWD_ITER first,
3983 FWD_ITER last,
3984 size_type numElements,
3985 bslma::Allocator *basicAllocator)
3986{
3987 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
3988 fromEndPtr,
3989 fromBegin,
3990 position,
3991 fromEnd,
3992 first,
3993 last,
3994 numElements,
3995 basicAllocator);
3996}
3997
3998template <class ALLOCATOR>
4001 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
4008 size_type numElements,
4009 ALLOCATOR allocator)
4010{
4011 // Key to the transformation diagrams:
4012 //..
4013 // A...H original contents of '[fromBegin, fromEnd)' ("source")
4014 // t...z original contents of '[first, last)' ("input")
4015 // ; ... contents of '[toBegin, toEnd)' ("destination")
4016 // ..:.. position of 'fromEndPtr' in the input
4017 // _____ uninitialized array elements
4018 // [...] part of array protected by an exception guard object
4019 //..
4020
4021 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4022
4023 *lastPtr = last;
4024 *fromEndPtr = fromEnd;
4025
4026 //..
4027 // Transformation: ABCDEFGH: ; _____________[]
4028 // => ABCD:____ ; _________[EFGH]
4029 //..
4030
4031 TargetType *toPositionBegin = toBegin + (position - fromBegin);
4032 TargetType *toPositionEnd = toPositionBegin + numElements;
4033
4034 destructiveMove(toPositionEnd,
4035 position,
4036 fromEnd,
4037 allocator);
4038
4039 *fromEndPtr = position; // shorten input range after partial destruction
4040
4041 AutoArrayDestructor<TargetType, ALLOCATOR>
4042 guard(toPositionEnd,
4043 toPositionEnd + (fromEnd - position),
4044 allocator);
4045
4046 //..
4047 // Transformation: ABCD:____ ; _________[EFGH]
4048 // => ABCD:____ ; _____[tuvwEFGH]
4049 //..
4050
4051 destructiveMove(toPositionBegin,
4052 first,
4053 last,
4054 allocator);
4055
4056 *lastPtr = first;
4057 guard.moveBegin(-static_cast<difference_type>(numElements));
4058
4059 //..
4060 // Transformation: ABCD:____ ; ____[tuvwEFGH]
4061 // => :________ ; ABCDtuvwEFGH[]
4062 //..
4063
4064 destructiveMove(toBegin,
4065 fromBegin,
4066 position,
4067 allocator);
4068
4069 *fromEndPtr = fromBegin; // empty input range after final destruction
4070 guard.release();
4071}
4072
4073template <class TARGET_TYPE>
4074inline
4076 TARGET_TYPE *toBegin,
4077 TARGET_TYPE **fromEndPtr,
4078 TARGET_TYPE **lastPtr,
4079 TARGET_TYPE *fromBegin,
4080 TARGET_TYPE *position,
4081 TARGET_TYPE *fromEnd,
4082 TARGET_TYPE *first,
4083 TARGET_TYPE *last,
4084 size_type numElements,
4085 bslma::Allocator *basicAllocator)
4086{
4087 destructiveMoveAndMoveInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
4088 fromEndPtr,
4089 lastPtr,
4090 fromBegin,
4091 position,
4092 fromEnd,
4093 first,
4094 last,
4095 numElements,
4096 basicAllocator);
4097}
4098
4099#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4100// {{{ BEGIN GENERATED CODE
4101// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
4102#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
4103#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
4104#endif
4105#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E
4106#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
4107#endif
4108#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4109template <class ALLOCATOR>
4110inline
4114 ALLOCATOR allocator)
4115{
4117 toEnd));
4119
4120 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4121
4122 enum {
4128 };
4129
4131 toBegin,
4132 toEnd,
4133 allocator,
4135}
4136#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4137
4138#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4139template <class ALLOCATOR, class ARGS_01>
4140inline
4144 ALLOCATOR allocator,
4145 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
4146{
4148 toEnd));
4150
4151 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4152
4153 enum {
4159 };
4160
4162 toBegin,
4163 toEnd,
4164 allocator,
4166 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
4167}
4168#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4169
4170#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4171template <class ALLOCATOR, class ARGS_01,
4172 class ARGS_02>
4173inline
4177 ALLOCATOR allocator,
4178 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4179 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
4180{
4182 toEnd));
4184
4185 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4186
4187 enum {
4193 };
4194
4196 toBegin,
4197 toEnd,
4198 allocator,
4200 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4201 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
4202}
4203#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4204
4205#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4206template <class ALLOCATOR, class ARGS_01,
4207 class ARGS_02,
4208 class ARGS_03>
4209inline
4213 ALLOCATOR allocator,
4214 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4215 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4216 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
4217{
4219 toEnd));
4221
4222 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4223
4224 enum {
4230 };
4231
4233 toBegin,
4234 toEnd,
4235 allocator,
4237 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4238 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4239 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
4240}
4241#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4242
4243#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4244template <class ALLOCATOR, class ARGS_01,
4245 class ARGS_02,
4246 class ARGS_03,
4247 class ARGS_04>
4248inline
4252 ALLOCATOR allocator,
4253 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4254 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4255 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4256 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
4257{
4259 toEnd));
4261
4262 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4263
4264 enum {
4270 };
4271
4273 toBegin,
4274 toEnd,
4275 allocator,
4277 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4278 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4279 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4280 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
4281}
4282#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4283
4284#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4285template <class ALLOCATOR, class ARGS_01,
4286 class ARGS_02,
4287 class ARGS_03,
4288 class ARGS_04,
4289 class ARGS_05>
4290inline
4294 ALLOCATOR allocator,
4295 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4296 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4297 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4298 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4299 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
4300{
4302 toEnd));
4304
4305 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4306
4307 enum {
4313 };
4314
4316 toBegin,
4317 toEnd,
4318 allocator,
4320 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4321 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4322 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4323 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4324 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
4325}
4326#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4327
4328#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4329template <class ALLOCATOR, class ARGS_01,
4330 class ARGS_02,
4331 class ARGS_03,
4332 class ARGS_04,
4333 class ARGS_05,
4334 class ARGS_06>
4335inline
4339 ALLOCATOR allocator,
4340 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4341 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4342 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4343 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4344 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
4346{
4348 toEnd));
4350
4351 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4352
4353 enum {
4359 };
4360
4362 toBegin,
4363 toEnd,
4364 allocator,
4366 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4367 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4368 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4369 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4370 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4371 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
4372}
4373#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4374
4375#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4376template <class ALLOCATOR, class ARGS_01,
4377 class ARGS_02,
4378 class ARGS_03,
4379 class ARGS_04,
4380 class ARGS_05,
4381 class ARGS_06,
4382 class ARGS_07>
4383inline
4387 ALLOCATOR allocator,
4388 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4389 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4390 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4391 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4392 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4393 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4394 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
4395{
4397 toEnd));
4399
4400 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4401
4402 enum {
4408 };
4409
4411 toBegin,
4412 toEnd,
4413 allocator,
4415 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4416 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4417 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4418 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4419 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4420 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4421 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
4422}
4423#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4424
4425#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4426template <class ALLOCATOR, class ARGS_01,
4427 class ARGS_02,
4428 class ARGS_03,
4429 class ARGS_04,
4430 class ARGS_05,
4431 class ARGS_06,
4432 class ARGS_07,
4433 class ARGS_08>
4434inline
4438 ALLOCATOR allocator,
4439 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4440 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4441 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4442 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4443 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4444 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4445 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4446 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
4447{
4449 toEnd));
4451
4452 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4453
4454 enum {
4460 };
4461
4463 toBegin,
4464 toEnd,
4465 allocator,
4467 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4468 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4469 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4470 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4471 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4472 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4473 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4474 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
4475}
4476#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4477
4478#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4479template <class ALLOCATOR, class ARGS_01,
4480 class ARGS_02,
4481 class ARGS_03,
4482 class ARGS_04,
4483 class ARGS_05,
4484 class ARGS_06,
4485 class ARGS_07,
4486 class ARGS_08,
4487 class ARGS_09>
4488inline
4492 ALLOCATOR allocator,
4493 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4494 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4495 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4496 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4497 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4498 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4499 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4500 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4501 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
4502{
4504 toEnd));
4506
4507 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4508
4509 enum {
4515 };
4516
4518 toBegin,
4519 toEnd,
4520 allocator,
4522 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4523 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4524 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4525 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4526 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4527 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4528 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4529 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4530 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
4531}
4532#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4533
4534#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4535template <class ALLOCATOR, class ARGS_01,
4536 class ARGS_02,
4537 class ARGS_03,
4538 class ARGS_04,
4539 class ARGS_05,
4540 class ARGS_06,
4541 class ARGS_07,
4542 class ARGS_08,
4543 class ARGS_09,
4544 class ARGS_10>
4545inline
4549 ALLOCATOR allocator,
4550 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4551 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4552 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4553 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4554 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4555 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4556 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4557 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4558 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
4559 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
4560{
4562 toEnd));
4564
4565 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4566
4567 enum {
4573 };
4574
4576 toBegin,
4577 toEnd,
4578 allocator,
4580 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4581 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4582 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4583 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4584 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4585 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4586 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4587 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4588 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
4589 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
4590}
4591#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4592
4593
4594#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4595template <class TARGET_TYPE>
4596inline
4597void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4598 TARGET_TYPE *toEnd,
4599 bslma::Allocator *basicAllocator)
4600{
4601 emplace<bsl::allocator<TARGET_TYPE> >(
4602 toBegin,
4603 toEnd,
4604 basicAllocator);
4605}
4606#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4607
4608#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4609template <class TARGET_TYPE, class ARGS_01>
4610inline
4611void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4612 TARGET_TYPE *toEnd,
4613 bslma::Allocator *basicAllocator,
4614 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
4615{
4616 emplace<bsl::allocator<TARGET_TYPE> >(
4617 toBegin,
4618 toEnd,
4619 basicAllocator,
4620 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
4621}
4622#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4623
4624#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4625template <class TARGET_TYPE, class ARGS_01,
4626 class ARGS_02>
4627inline
4628void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4629 TARGET_TYPE *toEnd,
4630 bslma::Allocator *basicAllocator,
4631 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4632 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
4633{
4634 emplace<bsl::allocator<TARGET_TYPE> >(
4635 toBegin,
4636 toEnd,
4637 basicAllocator,
4638 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4639 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
4640}
4641#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4642
4643#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4644template <class TARGET_TYPE, class ARGS_01,
4645 class ARGS_02,
4646 class ARGS_03>
4647inline
4648void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4649 TARGET_TYPE *toEnd,
4650 bslma::Allocator *basicAllocator,
4651 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4652 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4653 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
4654{
4655 emplace<bsl::allocator<TARGET_TYPE> >(
4656 toBegin,
4657 toEnd,
4658 basicAllocator,
4659 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4660 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4661 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
4662}
4663#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4664
4665#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4666template <class TARGET_TYPE, class ARGS_01,
4667 class ARGS_02,
4668 class ARGS_03,
4669 class ARGS_04>
4670inline
4671void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4672 TARGET_TYPE *toEnd,
4673 bslma::Allocator *basicAllocator,
4674 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4675 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4676 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4677 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
4678{
4679 emplace<bsl::allocator<TARGET_TYPE> >(
4680 toBegin,
4681 toEnd,
4682 basicAllocator,
4683 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4684 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4685 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4686 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
4687}
4688#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4689
4690#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4691template <class TARGET_TYPE, class ARGS_01,
4692 class ARGS_02,
4693 class ARGS_03,
4694 class ARGS_04,
4695 class ARGS_05>
4696inline
4697void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4698 TARGET_TYPE *toEnd,
4699 bslma::Allocator *basicAllocator,
4700 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4701 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4702 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4703 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4704 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
4705{
4706 emplace<bsl::allocator<TARGET_TYPE> >(
4707 toBegin,
4708 toEnd,
4709 basicAllocator,
4710 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4711 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4712 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4713 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4714 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
4715}
4716#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4717
4718#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4719template <class TARGET_TYPE, class ARGS_01,
4720 class ARGS_02,
4721 class ARGS_03,
4722 class ARGS_04,
4723 class ARGS_05,
4724 class ARGS_06>
4725inline
4726void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4727 TARGET_TYPE *toEnd,
4728 bslma::Allocator *basicAllocator,
4729 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4730 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4731 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4732 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4733 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4734 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
4735{
4736 emplace<bsl::allocator<TARGET_TYPE> >(
4737 toBegin,
4738 toEnd,
4739 basicAllocator,
4740 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4741 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4742 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4743 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4744 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4745 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
4746}
4747#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4748
4749#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4750template <class TARGET_TYPE, class ARGS_01,
4751 class ARGS_02,
4752 class ARGS_03,
4753 class ARGS_04,
4754 class ARGS_05,
4755 class ARGS_06,
4756 class ARGS_07>
4757inline
4758void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4759 TARGET_TYPE *toEnd,
4760 bslma::Allocator *basicAllocator,
4761 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4762 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4763 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4764 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4765 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4766 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4767 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
4768{
4769 emplace<bsl::allocator<TARGET_TYPE> >(
4770 toBegin,
4771 toEnd,
4772 basicAllocator,
4773 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4774 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4775 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4776 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4777 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4778 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4779 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
4780}
4781#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4782
4783#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4784template <class TARGET_TYPE, class ARGS_01,
4785 class ARGS_02,
4786 class ARGS_03,
4787 class ARGS_04,
4788 class ARGS_05,
4789 class ARGS_06,
4790 class ARGS_07,
4791 class ARGS_08>
4792inline
4793void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4794 TARGET_TYPE *toEnd,
4795 bslma::Allocator *basicAllocator,
4796 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4797 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4798 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4799 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4800 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4801 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4802 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4803 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
4804{
4805 emplace<bsl::allocator<TARGET_TYPE> >(
4806 toBegin,
4807 toEnd,
4808 basicAllocator,
4809 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4810 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4811 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4812 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4813 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4814 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4815 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4816 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
4817}
4818#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4819
4820#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4821template <class TARGET_TYPE, class ARGS_01,
4822 class ARGS_02,
4823 class ARGS_03,
4824 class ARGS_04,
4825 class ARGS_05,
4826 class ARGS_06,
4827 class ARGS_07,
4828 class ARGS_08,
4829 class ARGS_09>
4830inline
4831void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4832 TARGET_TYPE *toEnd,
4833 bslma::Allocator *basicAllocator,
4834 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4835 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4836 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4837 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4838 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4839 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4840 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4841 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4842 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
4843{
4844 emplace<bsl::allocator<TARGET_TYPE> >(
4845 toBegin,
4846 toEnd,
4847 basicAllocator,
4848 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4849 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4850 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4851 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4852 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4853 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4854 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4855 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4856 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
4857}
4858#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4859
4860#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4861template <class TARGET_TYPE, class ARGS_01,
4862 class ARGS_02,
4863 class ARGS_03,
4864 class ARGS_04,
4865 class ARGS_05,
4866 class ARGS_06,
4867 class ARGS_07,
4868 class ARGS_08,
4869 class ARGS_09,
4870 class ARGS_10>
4871inline
4872void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4873 TARGET_TYPE *toEnd,
4874 bslma::Allocator *basicAllocator,
4875 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4876 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4877 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4878 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4879 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4880 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4881 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4882 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4883 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
4884 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
4885{
4886 emplace<bsl::allocator<TARGET_TYPE> >(
4887 toBegin,
4888 toEnd,
4889 basicAllocator,
4890 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4891 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4892 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4893 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4894 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4895 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4896 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4897 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4898 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
4899 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
4900}
4901#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4902
4903#else
4904// The generated code below is a workaround for the absence of perfect
4905// forwarding in some compilers.
4906template <class ALLOCATOR, class... ARGS>
4907inline
4911 ALLOCATOR allocator,
4913{
4915 toEnd));
4917
4918 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4919
4920 enum {
4926 };
4927
4929 toBegin,
4930 toEnd,
4931 allocator,
4933 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
4934}
4935
4936template <class TARGET_TYPE, class... ARGS>
4937inline
4938void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4939 TARGET_TYPE *toEnd,
4940 bslma::Allocator *basicAllocator,
4942{
4943 emplace<bsl::allocator<TARGET_TYPE> >(
4944 toBegin,
4945 toEnd,
4946 basicAllocator,
4947 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
4948}
4949
4950// }}} END GENERATED CODE
4951#endif
4952
4953template <class ALLOCATOR>
4954inline
4959 ALLOCATOR allocator)
4960{
4963
4964 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4965
4966 if (first == middle) { // erasing empty range O(1) versus O(N): Do not
4967 // remove!
4968 return; // RETURN
4969 }
4970
4971 enum {
4975 };
4977 middle,
4978 last,
4979 allocator,
4981}
4982
4983template <class TARGET_TYPE>
4984inline
4985void ArrayPrimitives::erase(TARGET_TYPE *first,
4986 TARGET_TYPE *middle,
4987 TARGET_TYPE *last,
4988 bslma::Allocator *basicAllocator)
4989{
4990 erase<bsl::allocator<TARGET_TYPE> >(first,
4991 middle,
4992 last,
4993 basicAllocator);
4994}
4995
4996template <class ALLOCATOR>
4997inline
5003 ALLOCATOR allocator)
5004{
5007
5008 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5009
5010 if (toBegin != toEnd) {
5011 // Insert in the middle. Note that there is no strong exception
5012 // guarantee if copy constructor, move constructor, or assignment
5013 // operator throw.
5014
5015 enum {
5021 };
5022
5024 toBegin,
5025 toEnd,
5027 allocator,
5029 }
5030 else { // toBegin == toEnd
5032 allocator, toBegin, bslmf::MovableRefUtil::move(value));
5033 }
5034}
5035
5036template <class TARGET_TYPE>
5037inline
5038void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5039 TARGET_TYPE *toEnd,
5041 bslma::Allocator *basicAllocator)
5042{
5043 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5044 toEnd,
5046 basicAllocator);
5047}
5048
5049template <class ALLOCATOR>
5054 size_type numElements,
5055 ALLOCATOR allocator)
5056{
5059
5060 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5061
5062 if (0 == numElements) {
5063 return; // RETURN
5064 }
5065
5066 enum {
5072 };
5074 toEnd,
5075 value,
5076 numElements,
5077 allocator,
5079}
5080
5081template <class TARGET_TYPE>
5082inline
5083void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5084 TARGET_TYPE *toEnd,
5085 const TARGET_TYPE& value,
5086 size_type numElements,
5087 bslma::Allocator *basicAllocator)
5088{
5089 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5090 toEnd,
5091 value,
5092 numElements,
5093 basicAllocator);
5094}
5095
5096template <class ALLOCATOR, class FWD_ITER>
5100 FWD_ITER fromBegin,
5101 FWD_ITER fromEnd,
5102 size_type numElements,
5103 ALLOCATOR allocator)
5104{
5105 if (0 == numElements) {
5106 return; // RETURN
5107 }
5108
5109 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5110
5112
5113 /// Overload resolution will handle the case where `FWD_ITER` is a raw
5114 /// pointer, so we need handle only user-defined iterators. As `bslalg`
5115 /// is levelized below `bslstl` we cannot use `iterator_traits`, but
5116 /// rely on the same property as `iterator_traits` that this typedef
5117 /// must be defined for any standard-conforming iterator, unless the
5118 /// iterator explicitly specialized the `std::iterator_traits` template.
5119 /// In practice, iterators always prefer to provide the member typedef
5120 /// than specialize the traits as it is a much simpler implementation,
5121 /// so this assumption is good enough.
5122 ///
5123 /// Also note that as we know that `FWD_ITER` is not a pointer, then we
5124 /// cannot take advantage of bitwise copying as we do not have pointers
5125 /// to pass to the `memcpy` describing the whole range. It is not worth
5126 /// the effort to try to bitwise copy one element at a time.
5127 typedef typename FWD_ITER::value_type FwdTarget;
5128
5129 /// We want to detect the special case of copying function pointers to
5130 /// `void *` or `const void *` pointers.
5131 typedef typename bsl::remove_pointer<TargetType>::type RemovePtrTarget;
5132
5133 enum {
5134 k_ITER_TO_FUNC_PTRS = bslmf::IsFunctionPointer<FwdTarget>::value,
5135 k_TARGET_IS_VOID_PTR = bsl::is_pointer<TargetType>::value &&
5137
5138 k_VALUE = k_ITER_TO_FUNC_PTRS && k_TARGET_IS_VOID_PTR
5141 };
5143 toEnd,
5144 fromBegin,
5145 fromEnd,
5146 numElements,
5147 allocator,
5149}
5150
5151template <class TARGET_TYPE, class FWD_ITER>
5152inline
5153void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5154 TARGET_TYPE *toEnd,
5155 FWD_ITER fromBegin,
5156 FWD_ITER fromEnd,
5157 size_type numElements,
5158 bslma::Allocator *basicAllocator)
5159{
5160 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5161 toEnd,
5162 fromBegin,
5163 fromEnd,
5164 numElements,
5165 basicAllocator);
5166}
5167
5168template <class ALLOCATOR, class SOURCE_TYPE>
5172 SOURCE_TYPE *fromBegin,
5173 SOURCE_TYPE *fromEnd,
5174 size_type numElements,
5175 ALLOCATOR allocator)
5176{
5177 if (0 == numElements) {
5178 return; // RETURN
5179 }
5180
5181 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5182
5183 enum {
5184 k_ARE_PTRS_TO_PTRS = bsl::is_pointer<TargetType>::value &&
5186 k_IS_BITWISEMOVEABLE = bslmf::IsBitwiseMoveable<TargetType>::value,
5187 k_IS_BITWISECOPYABLE =
5189 k_VALUE = k_ARE_PTRS_TO_PTRS ? Imp::e_IS_POINTER_TO_POINTER
5190 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
5191 : k_IS_BITWISEMOVEABLE ? Imp::e_BITWISE_MOVEABLE_TRAITS
5193 };
5195 toEnd,
5196 fromBegin,
5197 fromEnd,
5198 numElements,
5199 allocator,
5201}
5202
5203template <class TARGET_TYPE, class SOURCE_TYPE>
5204inline
5205void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5206 TARGET_TYPE *toEnd,
5207 SOURCE_TYPE *fromBegin,
5208 SOURCE_TYPE *fromEnd,
5209 size_type numElements,
5210 bslma::Allocator *basicAllocator)
5211{
5212 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5213 toEnd,
5214 fromBegin,
5215 fromEnd,
5216 numElements,
5217 basicAllocator);
5218}
5219
5220template <class ALLOCATOR>
5221inline
5226 ALLOCATOR allocator)
5227{
5228 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5229
5230 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5231
5232 enum {
5236 };
5237
5239 fromBegin,
5240 fromEnd,
5241 allocator,
5243}
5244
5245template <class TARGET_TYPE>
5246inline
5247void ArrayPrimitives::moveConstruct(TARGET_TYPE *toBegin,
5248 TARGET_TYPE *fromBegin,
5249 TARGET_TYPE *fromEnd,
5250 bslma::Allocator *basicAllocator)
5251{
5252 moveConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
5253 fromBegin,
5254 fromEnd,
5255 basicAllocator);
5256}
5257
5258template <class ALLOCATOR>
5259inline
5263 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
5266 size_type numElements,
5267 ALLOCATOR allocator)
5268{
5269 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5270
5271 enum {
5275 };
5277 toEnd,
5278 fromEndPtr,
5279 fromBegin,
5280 fromEnd,
5281 numElements,
5282 allocator,
5284}
5285
5286template <class TARGET_TYPE>
5287inline
5288void ArrayPrimitives::moveInsert(TARGET_TYPE *toBegin,
5289 TARGET_TYPE *toEnd,
5290 TARGET_TYPE **fromEndPtr,
5291 TARGET_TYPE *fromBegin,
5292 TARGET_TYPE *fromEnd,
5293 size_type numElements,
5294 bslma::Allocator *basicAllocator)
5295{
5296 moveInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
5297 toEnd,
5298 fromEndPtr,
5299 fromBegin,
5300 fromEnd,
5301 numElements,
5302 basicAllocator);
5303}
5304
5305template <class TARGET_TYPE>
5306inline
5307void ArrayPrimitives::rotate(TARGET_TYPE *first,
5308 TARGET_TYPE *middle,
5309 TARGET_TYPE *last)
5310{
5312 middle));
5314 last));
5315
5316 enum {
5320 };
5322 middle,
5323 last,
5325}
5326
5327 // --------------------------
5328 // struct ArrayPrimitives_Imp
5329 // --------------------------
5330
5331// CLASS METHODS
5332template <class TARGET_TYPE>
5333inline
5334void ArrayPrimitives_Imp::assign(TARGET_TYPE *srcStart,
5335 TARGET_TYPE *srcEnd,
5336 TARGET_TYPE& value)
5337{
5338 for ( ; srcStart != srcEnd; ++srcStart) {
5339 *srcStart = value;
5340 }
5341}
5342
5343template <class FORWARD_ITERATOR>
5344inline
5345bool ArrayPrimitives_Imp::isInvalidRange(FORWARD_ITERATOR,
5346 FORWARD_ITERATOR)
5347{
5348 // Ideally would dispatch on random_access_iterator_tag to support
5349 // generalized random access iterators, but we are constrained by 'bsl'
5350 // levelization to not depend on 'bsl_iterator.h'. As the intent is to
5351 // detect invalid ranges in assertions, the conservative choice is to
5352 // return 'false' always. Note that this differs from the pointers case
5353 // below, which also disallows empty ranges.
5354
5355 return false;
5356}
5357
5358template <class TARGET_TYPE>
5359inline
5360bool ArrayPrimitives_Imp::isInvalidRange(TARGET_TYPE *begin,
5361 TARGET_TYPE *end)
5362{
5363 return !begin != !end || begin > end;
5364}
5365
5366template <class TARGET_TYPE>
5367inline
5368void ArrayPrimitives_Imp::reverseAssign(TARGET_TYPE *dest,
5369 TARGET_TYPE *srcStart,
5370 TARGET_TYPE *srcEnd)
5371{
5372 TARGET_TYPE *destEnd = srcEnd - srcStart + dest;
5373 while (srcStart != srcEnd) {
5374 *--destEnd = *--srcEnd;
5375 }
5376}
5377
5378
5379 // *** 'uninitializedFillN' overloads: ***
5380
5381inline
5383 bool *begin,
5384 bool value,
5385 size_type numElements,
5386 void *,
5388{
5389 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5391 BSLMF_ASSERT(sizeof(bool) == 1);
5392
5393 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5394 std::memset(reinterpret_cast<char *>(begin), // odd, why not 'void *'?
5395 static_cast<char>(value),
5396 numElements);
5397 }
5398}
5399
5400inline
5402 char *begin,
5403 char value,
5404 size_type numElements,
5405 void *,
5407{
5408 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5410
5411 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5412 std::memset(begin, value, numElements);
5413 }
5414}
5415
5416inline
5418 unsigned char *begin,
5419 unsigned char value,
5420 size_type numElements,
5421 void *,
5423{
5424 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5426
5427 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5428 std::memset(begin, value, numElements);
5429 }
5430}
5431
5432inline
5434 signed char *begin,
5435 signed char value,
5436 size_type numElements,
5437 void *,
5439{
5440 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5442
5443 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5444 std::memset(begin, value, numElements);
5445 }
5446}
5447
5448inline
5450 wchar_t *begin,
5451 wchar_t value,
5452 size_type numElements,
5453 void *,
5455{
5456 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5458
5459 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5460 std::wmemset(begin, value, numElements);
5461 }
5462}
5463
5464inline
5466 unsigned short *begin,
5467 unsigned short value,
5468 size_type numElements,
5469 void *,
5471{
5472 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5474
5476 reinterpret_cast<short *>(begin),
5477 static_cast<short>(value),
5478 numElements,
5479 (void *)0,
5481}
5482
5483inline
5485 unsigned int *begin,
5486 unsigned int value,
5487 size_type numElements,
5488 void *,
5490{
5491 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5493
5495 reinterpret_cast<int *>(begin),
5496 static_cast<int>(value),
5497 numElements,
5498 (void *)0,
5500}
5501
5502inline
5504 long *begin,
5505 long value,
5506 size_type numElements,
5507 void *,
5509{
5510 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5512
5513#if defined(BSLS_PLATFORM_CPU_64_BIT) && !defined(BSLS_PLATFORM_OS_WINDOWS)
5514 uninitializedFillN(reinterpret_cast<bsls::Types::Int64 *>(begin),
5515 static_cast<bsls::Types::Int64>(value),
5516 numElements);
5517#else
5519 reinterpret_cast<int *>(begin),
5520 static_cast<int>(value),
5521 numElements,
5522 (void *)0,
5524#endif
5525}
5526
5527inline
5529 unsigned long *begin,
5530 unsigned long value,
5531 size_type numElements,
5532 void *,
5534{
5535 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5537
5538#if defined(BSLS_PLATFORM_CPU_64_BIT) && !defined(BSLS_PLATFORM_OS_WINDOWS)
5540 reinterpret_cast<bsls::Types::Int64 *>(begin),
5541 static_cast<bsls::Types::Int64>(value),
5542 numElements,
5543 (void *)0,
5545#else
5547 reinterpret_cast<int *>(begin),
5548 static_cast<int>(value),
5549 numElements,
5550 (void *)0,
5552#endif
5553}
5554
5555inline
5557 bsls::Types::Uint64 *begin,
5558 bsls::Types::Uint64 value,
5559 size_type numElements,
5560 void *,
5562{
5563 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5565
5567 reinterpret_cast<bsls::Types::Int64 *>(begin),
5568 value,
5569 numElements,
5570 (void *)0,
5572}
5573
5574template <class TARGET_TYPE>
5575inline
5577 TARGET_TYPE **begin,
5578 TARGET_TYPE *value,
5579 size_type numElements,
5580 void *,
5582{
5583 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5585
5586 // Note: 'const'-correctness is respected because the next overload picks
5587 // up the 'const TARGET_TYPE' and will be a better match. Note that we
5588 // cannot cast to 'const void **' (one would have to add 'const' at every
5589 // level, not just the innermost; i.e., 'const void *const *' would be
5590 // correct, 'const void **' is not [C++ Standard, 4.4 Qualification
5591 // conversions]).
5592
5594 reinterpret_cast<void **>(begin),
5595 static_cast<void *>(value),
5596 numElements,
5597 (void *)0,
5599}
5600
5601template <class TARGET_TYPE>
5602inline
5604 const TARGET_TYPE **begin,
5605 const TARGET_TYPE *value,
5606 size_type numElements,
5607 void *,
5609{
5610 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5612
5613 // While it seems that this overload is subsumed by the previous template,
5614 // SunPro does not detect it.
5615
5617 reinterpret_cast<const void **>(begin),
5618 static_cast<const void *>(value),
5619 numElements,
5620 (void *)0,
5622}
5623
5624template <class TARGET_TYPE>
5625inline
5627 volatile TARGET_TYPE **begin,
5628 volatile TARGET_TYPE *value,
5629 size_type numElements,
5630 void *,
5632{
5633 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5635
5636 // While it seems that this overload is subsumed by the previous template,
5637 // SunPro does not detect it.
5638
5640 reinterpret_cast<volatile void **>(begin),
5641 static_cast<volatile void *>(value),
5642 numElements,
5643 (void *)0,
5645}
5646
5647template <class TARGET_TYPE>
5648inline
5650 const volatile TARGET_TYPE **begin,
5651 const volatile TARGET_TYPE *value,
5652 size_type numElements,
5653 void *,
5655{
5656 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5658
5659 // While it seems that this overload is subsumed by the previous template,
5660 // SunPro does not detect it.
5661
5663 reinterpret_cast<const volatile void **>(begin),
5664 static_cast<const volatile void *>(value),
5665 numElements,
5666 (void *)0,
5668}
5669
5670template <class TARGET_TYPE, class ALLOCATOR>
5672 TARGET_TYPE *begin,
5673 const TARGET_TYPE& value,
5674 size_type numElements,
5675 ALLOCATOR *,
5677{
5678 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5680
5681 if (0 == numElements) {
5682 return; // RETURN
5683 }
5684
5685 const char *valueBuffer =
5686 reinterpret_cast<const char *>(BSLS_UTIL_ADDRESSOF(value));
5687
5688 std::memcpy((void *)begin, valueBuffer, sizeof(TARGET_TYPE));
5689 bitwiseFillN(reinterpret_cast<char *>(begin),
5690 sizeof(TARGET_TYPE),
5691 sizeof(TARGET_TYPE) * numElements);
5692}
5693
5694template <class TARGET_TYPE, class ALLOCATOR>
5696 TARGET_TYPE *begin,
5697 const TARGET_TYPE& value,
5698 size_type numElements,
5699 ALLOCATOR *allocator,
5701{
5702 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5704 BSLS_ASSERT_SAFE(allocator);
5705
5706 if (0 == numElements) {
5707 return; // RETURN
5708 }
5709 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(begin,
5710 begin,
5711 *allocator);
5712
5713 TARGET_TYPE *end = begin + numElements;
5714 do {
5715 bsl::allocator_traits<ALLOCATOR>::construct(*allocator, begin, value);
5716 begin = guard.moveEnd(1);
5717 } while (begin != end);
5718 guard.release();
5719}
5720
5721 // *** 'copyConstruct' overloads: ***
5722
5723template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
5724inline
5726 TARGET_TYPE *toBegin,
5727 FWD_ITER fromBegin,
5728 FWD_ITER fromEnd,
5729 ALLOCATOR allocator,
5731{
5732 // We may be casting a function pointer to a 'void *' here, so this won't
5733 // work if we port to an architecture where the two are of different sizes.
5734
5735 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
5736
5737 typedef typename bsl::remove_cv<
5738 typename bsl::remove_pointer<TARGET_TYPE>::type>::type NcPtrType;
5739
5740 typedef typename bsl::remove_cv<
5741 typename bsl::remove_pointer<
5742 typename bsl::remove_pointer<FWD_ITER>::type>::type>::type NcIter;
5743
5744#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
5745 // fall back on traditional C-style casts.
5746 copyConstruct((void * *)toBegin,
5747 (void * const *)fromBegin,
5748 (void * const *)fromEnd,
5749 allocator,
5751#else
5753 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toBegin)),
5754 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromBegin)),
5755 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromEnd)),
5756 allocator,
5758#endif
5759}
5760
5761template <class FWD_ITER, class ALLOCATOR>
5763 void **toBegin,
5764 FWD_ITER fromBegin,
5765 FWD_ITER fromEnd,
5766 ALLOCATOR,
5768{
5769 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
5770 // We will be casting a function pointer to a 'void *', so this won't
5771 // work if we port to an architecture where the two are of different
5772 // sizes.
5773
5774 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5776
5777 while (fromBegin != fromEnd) {
5778 // 'fromBegin' iterates over pointers to functions, which must be
5779 // @ref reinterpret_cast to 'void *'.
5780
5781 *toBegin = reinterpret_cast<void *>(*fromBegin);
5782 ++fromBegin;
5783 ++toBegin;
5784 }
5785}
5786
5787template <class TARGET_TYPE, class ALLOCATOR>
5788inline
5790 TARGET_TYPE *toBegin,
5791 const TARGET_TYPE *fromBegin,
5792 const TARGET_TYPE *fromEnd,
5793 ALLOCATOR,
5795{
5796 BSLS_ASSERT_SAFE(toBegin);
5798 fromEnd));
5799
5800 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
5801 - reinterpret_cast<const char*>(fromBegin);
5802 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
5803 std::memcpy((void *)toBegin, fromBegin, numBytes);
5804 }
5805}
5806
5807template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
5809 TARGET_TYPE *toBegin,
5810 FWD_ITER fromBegin,
5811 FWD_ITER fromEnd,
5812 ALLOCATOR allocator,
5814{
5815 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5817 fromEnd));
5818
5819 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5820 allocator);
5821
5822 while (fromBegin != fromEnd) {
5823 // Note: We are not sure the value type of 'FWD_ITER' is convertible to
5824 // 'TARGET_TYPE'. Use 'construct' instead.
5825
5827 toBegin,
5828 *fromBegin);
5829 ++fromBegin;
5830 toBegin = guard.moveEnd(1);
5831 }
5832 guard.release();
5833}
5834
5835 // *** 'moveConstruct' overloads: ***
5836template <class TARGET_TYPE, class ALLOCATOR>
5837inline
5839 TARGET_TYPE *toBegin,
5840 TARGET_TYPE *fromBegin,
5841 TARGET_TYPE *fromEnd,
5842 ALLOCATOR,
5844{
5845 BSLS_ASSERT_SAFE(toBegin);
5847 fromEnd));
5848
5849 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
5850 - reinterpret_cast<const char*>(fromBegin);
5851 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
5852 std::memcpy((void *)toBegin, fromBegin, numBytes);
5853 }
5854}
5855
5856template <class TARGET_TYPE, class ALLOCATOR>
5858 TARGET_TYPE *toBegin,
5859 TARGET_TYPE *fromBegin,
5860 TARGET_TYPE *fromEnd,
5861 ALLOCATOR allocator,
5863{
5864 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5866 fromEnd));
5867
5868 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5869 allocator);
5870
5871 while (fromBegin != fromEnd) {
5873 allocator,
5874 toBegin,
5875 bslmf::MovableRefUtil::move(*fromBegin));
5876 ++fromBegin;
5877 toBegin = guard.moveEnd(1);
5878 }
5879 guard.release();
5880}
5881
5882template <class TARGET_TYPE, class ALLOCATOR>
5884 TARGET_TYPE *toBegin,
5885 TARGET_TYPE *fromBegin,
5886 TARGET_TYPE *fromEnd,
5887 ALLOCATOR allocator,
5889{
5890 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5892 fromEnd));
5893
5894 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5895 allocator);
5896
5897 while (fromBegin != fromEnd) {
5899 allocator,
5900 toBegin,
5902 ++fromBegin;
5903 toBegin = guard.moveEnd(1);
5904 }
5905 guard.release();
5906}
5907
5908
5909 // *** 'defaultConstruct' overloads: ***
5910
5911template <class TARGET_TYPE, class ALLOCATOR>
5912inline
5914 TARGET_TYPE *begin,
5915 size_type numElements,
5916 ALLOCATOR,
5918{
5919 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5921
5922 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5923 std::memset(static_cast<void *>(begin),
5924 0,
5925 sizeof(TARGET_TYPE) * numElements);
5926 }
5927}
5928
5929template <class TARGET_TYPE, class ALLOCATOR>
5930inline
5932 TARGET_TYPE *begin,
5933 size_type numElements,
5934 ALLOCATOR allocator,
5936{
5937 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5939
5940 if (0 < numElements) {
5942 bitwiseFillN(reinterpret_cast<char *>(begin),
5943 sizeof(TARGET_TYPE),
5944 numElements * sizeof(TARGET_TYPE));
5945 }
5946}
5947
5948template <class TARGET_TYPE, class ALLOCATOR>
5950 TARGET_TYPE *begin,
5951 size_type numElements,
5952 ALLOCATOR allocator,
5954{
5955 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5957
5958 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(begin, begin, allocator);
5959
5960 const TARGET_TYPE *end = begin + numElements;
5961 while (begin != end) {
5963 begin = guard.moveEnd(1);
5964 }
5965 guard.release();
5966}
5967
5968 // *** 'destructiveMove' overloads: ***
5969
5970template <class TARGET_TYPE, class ALLOCATOR>
5971inline
5973 TARGET_TYPE *toBegin,
5974 TARGET_TYPE *fromBegin,
5975 TARGET_TYPE *fromEnd,
5976 ALLOCATOR,
5978{
5979 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5981 fromEnd));
5982
5983 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
5984 - reinterpret_cast<const char*>(fromBegin);
5985 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
5986 std::memcpy((void *)toBegin, fromBegin, numBytes);
5987 }
5988}
5989
5990template <class TARGET_TYPE, class ALLOCATOR>
5991inline
5993 TARGET_TYPE *toBegin,
5994 TARGET_TYPE *fromBegin,
5995 TARGET_TYPE *fromEnd,
5996 ALLOCATOR allocator,
5998{
5999 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
6001 fromEnd));
6002
6003 // 'TARGET_TYPE' certainly cannot be bit-wise copyable, so we can save the
6004 // compiler some work.
6005
6006 moveIfNoexcept(toBegin, fromBegin, fromEnd, allocator,
6008 ArrayDestructionPrimitives::destroy(fromBegin, fromEnd, allocator);
6009}
6010
6011 // *** 'emplace' with 'args' overloads: ***
6012
6013#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
6014// {{{ BEGIN GENERATED CODE
6015// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
6016#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
6017#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
6018#endif
6019#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F
6020#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
6021#endif
6022#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6023template <class TARGET_TYPE, class ALLOCATOR>
6024inline
6026 TARGET_TYPE *toBegin,
6027 TARGET_TYPE *toEnd,
6028 ALLOCATOR allocator,
6030{
6031
6033 toBegin,
6034 toEnd,
6035 allocator,
6037}
6038#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6039
6040#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6041template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
6042inline
6044 TARGET_TYPE *toBegin,
6045 TARGET_TYPE *toEnd,
6046 ALLOCATOR allocator,
6048 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
6049{
6050
6052 toBegin,
6053 toEnd,
6054 allocator,
6056 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
6057}
6058#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6059
6060#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6061template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6062 class ARGS_02>
6063inline
6065 TARGET_TYPE *toBegin,
6066 TARGET_TYPE *toEnd,
6067 ALLOCATOR allocator,
6069 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6070 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
6071{
6072
6074 toBegin,
6075 toEnd,
6076 allocator,
6078 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6079 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
6080}
6081#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6082
6083#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6084template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6085 class ARGS_02,
6086 class ARGS_03>
6087inline
6089 TARGET_TYPE *toBegin,
6090 TARGET_TYPE *toEnd,
6091 ALLOCATOR allocator,
6093 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6094 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6095 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
6096{
6097
6099 toBegin,
6100 toEnd,
6101 allocator,
6103 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6104 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6105 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
6106}
6107#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6108
6109#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6110template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6111 class ARGS_02,
6112 class ARGS_03,
6113 class ARGS_04>
6114inline
6116 TARGET_TYPE *toBegin,
6117 TARGET_TYPE *toEnd,
6118 ALLOCATOR allocator,
6120 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6121 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6122 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6123 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
6124{
6125
6127 toBegin,
6128 toEnd,
6129 allocator,
6131 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6132 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6133 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6134 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
6135}
6136#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6137
6138#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6139template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6140 class ARGS_02,
6141 class ARGS_03,
6142 class ARGS_04,
6143 class ARGS_05>
6144inline
6146 TARGET_TYPE *toBegin,
6147 TARGET_TYPE *toEnd,
6148 ALLOCATOR allocator,
6150 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6151 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6152 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6153 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6154 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
6155{
6156
6158 toBegin,
6159 toEnd,
6160 allocator,
6162 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6163 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6164 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6165 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6166 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
6167}
6168#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6169
6170#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6171template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6172 class ARGS_02,
6173 class ARGS_03,
6174 class ARGS_04,
6175 class ARGS_05,
6176 class ARGS_06>
6177inline
6179 TARGET_TYPE *toBegin,
6180 TARGET_TYPE *toEnd,
6181 ALLOCATOR allocator,
6183 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6184 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6185 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6186 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6187 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6188 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
6189{
6190
6192 toBegin,
6193 toEnd,
6194 allocator,
6196 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6197 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6198 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6199 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6200 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6201 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
6202}
6203#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6204
6205#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6206template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6207 class ARGS_02,
6208 class ARGS_03,
6209 class ARGS_04,
6210 class ARGS_05,
6211 class ARGS_06,
6212 class ARGS_07>
6213inline
6215 TARGET_TYPE *toBegin,
6216 TARGET_TYPE *toEnd,
6217 ALLOCATOR allocator,
6219 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
6226{
6227
6229 toBegin,
6230 toEnd,
6231 allocator,
6233 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6234 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6235 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6236 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6237 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6238 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6239 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
6240}
6241#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6242
6243#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
6244template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6245 class ARGS_02,
6246 class ARGS_03,
6247 class ARGS_04,
6248 class ARGS_05,
6249 class ARGS_06,
6250 class ARGS_07,
6251 class ARGS_08>
6252inline
6254 TARGET_TYPE *toBegin,
6255 TARGET_TYPE *toEnd,
6256 ALLOCATOR allocator,
6258 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6259 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6260 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6261 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6262 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6263 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6264 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6265 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
6266{
6267
6269 toBegin,
6270 toEnd,
6271 allocator,
6273 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6274 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6275 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6276 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6277 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6278 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6279 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6280 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
6281}
6282#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
6283
6284#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
6285template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6286 class ARGS_02,
6287 class ARGS_03,
6288 class ARGS_04,
6289 class ARGS_05,
6290 class ARGS_06,
6291 class ARGS_07,
6292 class ARGS_08,
6293 class ARGS_09>
6294inline
6296 TARGET_TYPE *toBegin,
6297 TARGET_TYPE *toEnd,
6298 ALLOCATOR allocator,
6300 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6301 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6302 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6303 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6304 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6305 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6306 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6307 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
6308 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
6309{
6310
6312 toBegin,
6313 toEnd,
6314 allocator,
6316 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6317 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6318 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6319 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6320 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6321 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6322 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6323 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
6324 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
6325}
6326#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
6327
6328#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
6329template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6330 class ARGS_02,
6331 class ARGS_03,
6332 class ARGS_04,
6333 class ARGS_05,
6334 class ARGS_06,
6335 class ARGS_07,
6336 class ARGS_08,
6337 class ARGS_09,
6338 class ARGS_10>
6339inline
6341 TARGET_TYPE *toBegin,
6342 TARGET_TYPE *toEnd,
6343 ALLOCATOR allocator,
6345 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6346 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6347 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6348 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6349 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6350 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6351 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
6353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
6354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
6355{
6356
6358 toBegin,
6359 toEnd,
6360 allocator,
6362 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6363 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6364 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6365 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6366 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6367 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6368 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6369 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
6370 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
6371 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
6372}
6373#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
6374
6375
6376#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6377template <class TARGET_TYPE, class ALLOCATOR>
6379 TARGET_TYPE *toBegin,
6380 TARGET_TYPE *toEnd,
6381 ALLOCATOR allocator,
6383{
6385 toEnd));
6387
6388 size_type numElements = 1;
6389
6390
6391 size_type tailLen = toEnd - toBegin;
6392 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6393
6394
6395 TARGET_TYPE *destBegin = toBegin + numElements;
6396 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6397 std::memmove((void *)destBegin,
6398 toBegin,
6399 tailLen * sizeof(TARGET_TYPE));
6400 }
6401
6402
6403 TARGET_TYPE *destEnd = toEnd + numElements;
6404
6405 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6406 destEnd - numGuarded,
6407 destEnd - numGuarded,
6408 destEnd,
6409 allocator);
6410
6411 while (guard.middle() != guard.end()) {
6413 guard.destination());
6414 guard.advance();
6415 }
6416
6417
6418 if (tailLen < numElements) {
6419
6420 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6421 destEnd,
6422 allocator);
6423
6424
6425 while (toEnd != destBegin) {
6427 --destBegin);
6428
6429 endGuard.moveBegin(-1);
6430 }
6431 endGuard.release();
6432 }
6433}
6434#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6435
6436#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6437template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
6439 TARGET_TYPE *toBegin,
6440 TARGET_TYPE *toEnd,
6441 ALLOCATOR allocator,
6443 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
6444{
6446 toEnd));
6448
6449 size_type numElements = 1;
6450
6451
6452 size_type tailLen = toEnd - toBegin;
6453 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6454
6455
6456 TARGET_TYPE *destBegin = toBegin + numElements;
6457 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6458 std::memmove((void *)destBegin,
6459 toBegin,
6460 tailLen * sizeof(TARGET_TYPE));
6461 }
6462
6463
6464 TARGET_TYPE *destEnd = toEnd + numElements;
6465
6466 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6467 destEnd - numGuarded,
6468 destEnd - numGuarded,
6469 destEnd,
6470 allocator);
6471
6472 while (guard.middle() != guard.end()) {
6474 guard.destination(),
6475 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
6476 guard.advance();
6477 }
6478
6479
6480 if (tailLen < numElements) {
6481
6482 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6483 destEnd,
6484 allocator);
6485
6486
6487 while (toEnd != destBegin) {
6489 --destBegin,
6490 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01));
6491
6492 endGuard.moveBegin(-1);
6493 }
6494 endGuard.release();
6495 }
6496}
6497#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6498
6499#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6500template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6501 class ARGS_02>
6503 TARGET_TYPE *toBegin,
6504 TARGET_TYPE *toEnd,
6505 ALLOCATOR allocator,
6507 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6508 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
6509{
6511 toEnd));
6513
6514 size_type numElements = 1;
6515
6516
6517 size_type tailLen = toEnd - toBegin;
6518 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6519
6520
6521 TARGET_TYPE *destBegin = toBegin + numElements;
6522 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6523 std::memmove((void *)destBegin,
6524 toBegin,
6525 tailLen * sizeof(TARGET_TYPE));
6526 }
6527
6528
6529 TARGET_TYPE *destEnd = toEnd + numElements;
6530
6531 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6532 destEnd - numGuarded,
6533 destEnd - numGuarded,
6534 destEnd,
6535 allocator);
6536
6537 while (guard.middle() != guard.end()) {
6539 guard.destination(),
6540 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6541 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
6542 guard.advance();
6543 }
6544
6545
6546 if (tailLen < numElements) {
6547
6548 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6549 destEnd,
6550 allocator);
6551
6552
6553 while (toEnd != destBegin) {
6555 --destBegin,
6556 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6557 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02));
6558
6559 endGuard.moveBegin(-1);
6560 }
6561 endGuard.release();
6562 }
6563}
6564#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6565
6566#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6567template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6568 class ARGS_02,
6569 class ARGS_03>
6571 TARGET_TYPE *toBegin,
6572 TARGET_TYPE *toEnd,
6573 ALLOCATOR allocator,
6575 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6576 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6577 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
6578{
6580 toEnd));
6582
6583 size_type numElements = 1;
6584
6585
6586 size_type tailLen = toEnd - toBegin;
6587 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6588
6589
6590 TARGET_TYPE *destBegin = toBegin + numElements;
6591 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6592 std::memmove((void *)destBegin,
6593 toBegin,
6594 tailLen * sizeof(TARGET_TYPE));
6595 }
6596
6597
6598 TARGET_TYPE *destEnd = toEnd + numElements;
6599
6600 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6601 destEnd - numGuarded,
6602 destEnd - numGuarded,
6603 destEnd,
6604 allocator);
6605
6606 while (guard.middle() != guard.end()) {
6608 guard.destination(),
6609 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6610 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6611 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
6612 guard.advance();
6613 }
6614
6615
6616 if (tailLen < numElements) {
6617
6618 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6619 destEnd,
6620 allocator);
6621
6622
6623 while (toEnd != destBegin) {
6625 --destBegin,
6626 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6627 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6628 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03));
6629
6630 endGuard.moveBegin(-1);
6631 }
6632 endGuard.release();
6633 }
6634}
6635#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6636
6637#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6638template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6639 class ARGS_02,
6640 class ARGS_03,
6641 class ARGS_04>
6643 TARGET_TYPE *toBegin,
6644 TARGET_TYPE *toEnd,
6645 ALLOCATOR allocator,
6647 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6648 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6649 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6650 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
6651{
6653 toEnd));
6655
6656 size_type numElements = 1;
6657
6658
6659 size_type tailLen = toEnd - toBegin;
6660 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6661
6662
6663 TARGET_TYPE *destBegin = toBegin + numElements;
6664 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6665 std::memmove((void *)destBegin,
6666 toBegin,
6667 tailLen * sizeof(TARGET_TYPE));
6668 }
6669
6670
6671 TARGET_TYPE *destEnd = toEnd + numElements;
6672
6673 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6674 destEnd - numGuarded,
6675 destEnd - numGuarded,
6676 destEnd,
6677 allocator);
6678
6679 while (guard.middle() != guard.end()) {
6681 guard.destination(),
6682 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6683 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6684 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6685 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
6686 guard.advance();
6687 }
6688
6689
6690 if (tailLen < numElements) {
6691
6692 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6693 destEnd,
6694 allocator);
6695
6696
6697 while (toEnd != destBegin) {
6699 --destBegin,
6700 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6701 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6702 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6703 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04));
6704
6705 endGuard.moveBegin(-1);
6706 }
6707 endGuard.release();
6708 }
6709}
6710#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6711
6712#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6713template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6714 class ARGS_02,
6715 class ARGS_03,
6716 class ARGS_04,
6717 class ARGS_05>
6719 TARGET_TYPE *toBegin,
6720 TARGET_TYPE *toEnd,
6721 ALLOCATOR allocator,
6723 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6724 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6725 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6726 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6727 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
6728{
6730 toEnd));
6732
6733 size_type numElements = 1;
6734
6735
6736 size_type tailLen = toEnd - toBegin;
6737 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6738
6739
6740 TARGET_TYPE *destBegin = toBegin + numElements;
6741 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6742 std::memmove((void *)destBegin,
6743 toBegin,
6744 tailLen * sizeof(TARGET_TYPE));
6745 }
6746
6747
6748 TARGET_TYPE *destEnd = toEnd + numElements;
6749
6750 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6751 destEnd - numGuarded,
6752 destEnd - numGuarded,
6753 destEnd,
6754 allocator);
6755
6756 while (guard.middle() != guard.end()) {
6758 guard.destination(),
6759 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6760 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6761 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6762 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6763 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
6764 guard.advance();
6765 }
6766
6767
6768 if (tailLen < numElements) {
6769
6770 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6771 destEnd,
6772 allocator);
6773
6774
6775 while (toEnd != destBegin) {
6777 --destBegin,
6778 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6779 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6780 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6781 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6782 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05));
6783
6784 endGuard.moveBegin(-1);
6785 }
6786 endGuard.release();
6787 }
6788}
6789#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6790
6791#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6792template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6793 class ARGS_02,
6794 class ARGS_03,
6795 class ARGS_04,
6796 class ARGS_05,
6797 class ARGS_06>
6799 TARGET_TYPE *toBegin,
6800 TARGET_TYPE *toEnd,
6801 ALLOCATOR allocator,
6803 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6804 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6805 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6806 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6807 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6808 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
6809{
6811 toEnd));
6813
6814 size_type numElements = 1;
6815
6816
6817 size_type tailLen = toEnd - toBegin;
6818 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6819
6820
6821 TARGET_TYPE *destBegin = toBegin + numElements;
6822 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6823 std::memmove((void *)destBegin,
6824 toBegin,
6825 tailLen * sizeof(TARGET_TYPE));
6826 }
6827
6828
6829 TARGET_TYPE *destEnd = toEnd + numElements;
6830
6831 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6832 destEnd - numGuarded,
6833 destEnd - numGuarded,
6834 destEnd,
6835 allocator);
6836
6837 while (guard.middle() != guard.end()) {
6839 guard.destination(),
6840 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6841 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6842 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6843 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6844 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6845 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
6846 guard.advance();
6847 }
6848
6849
6850 if (tailLen < numElements) {
6851
6852 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6853 destEnd,
6854 allocator);
6855
6856
6857 while (toEnd != destBegin) {
6859 --destBegin,
6860 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6861 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6862 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6863 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6864 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
6865 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06));
6866
6867 endGuard.moveBegin(-1);
6868 }
6869 endGuard.release();
6870 }
6871}
6872#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6873
6874#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6875template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6876 class ARGS_02,
6877 class ARGS_03,
6878 class ARGS_04,
6879 class ARGS_05,
6880 class ARGS_06,
6881 class ARGS_07>
6883 TARGET_TYPE *toBegin,
6884 TARGET_TYPE *toEnd,
6885 ALLOCATOR allocator,
6887 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6888 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6889 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6890 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6891 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6893 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
6894{
6896 toEnd));
6898
6899 size_type numElements = 1;
6900
6901
6902 size_type tailLen = toEnd - toBegin;
6903 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6904
6905
6906 TARGET_TYPE *destBegin = toBegin + numElements;
6907 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6908 std::memmove((void *)destBegin,
6909 toBegin,
6910 tailLen * sizeof(TARGET_TYPE));
6911 }
6912
6913
6914 TARGET_TYPE *destEnd = toEnd + numElements;
6915
6916 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6917 destEnd - numGuarded,
6918 destEnd - numGuarded,
6919 destEnd,
6920 allocator);
6921
6922 while (guard.middle() != guard.end()) {
6924 guard.destination(),
6925 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6926 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6927 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6928 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6929 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6930 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6931 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
6932 guard.advance();
6933 }
6934
6935
6936 if (tailLen < numElements) {
6937
6938 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6939 destEnd,
6940 allocator);
6941
6942
6943 while (toEnd != destBegin) {
6945 --destBegin,
6946 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6947 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6948 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6949 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6950 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
6951 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
6952 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07));
6953
6954 endGuard.moveBegin(-1);
6955 }
6956 endGuard.release();
6957 }
6958}
6959#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6960
6961#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
6962template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6963 class ARGS_02,
6964 class ARGS_03,
6965 class ARGS_04,
6966 class ARGS_05,
6967 class ARGS_06,
6968 class ARGS_07,
6969 class ARGS_08>
6971 TARGET_TYPE *toBegin,
6972 TARGET_TYPE *toEnd,
6973 ALLOCATOR allocator,
6975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6976 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6977 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6978 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6979 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6980 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6981 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6982 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
6983{
6985 toEnd));
6987
6988 size_type numElements = 1;
6989
6990
6991 size_type tailLen = toEnd - toBegin;
6992 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6993
6994
6995 TARGET_TYPE *destBegin = toBegin + numElements;
6996 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6997 std::memmove((void *)destBegin,
6998 toBegin,
6999 tailLen * sizeof(TARGET_TYPE));
7000 }
7001
7002
7003 TARGET_TYPE *destEnd = toEnd + numElements;
7004
7005 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7006 destEnd - numGuarded,
7007 destEnd - numGuarded,
7008 destEnd,
7009 allocator);
7010
7011 while (guard.middle() != guard.end()) {
7013 guard.destination(),
7014 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7015 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7016 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7017 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7018 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7019 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7020 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7021 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7022 guard.advance();
7023 }
7024
7025
7026 if (tailLen < numElements) {
7027
7028 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7029 destEnd,
7030 allocator);
7031
7032
7033 while (toEnd != destBegin) {
7035 --destBegin,
7036 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7037 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7038 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7039 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7040 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7041 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7042 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7043 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08));
7044
7045 endGuard.moveBegin(-1);
7046 }
7047 endGuard.release();
7048 }
7049}
7050#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7051
7052#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7053template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7054 class ARGS_02,
7055 class ARGS_03,
7056 class ARGS_04,
7057 class ARGS_05,
7058 class ARGS_06,
7059 class ARGS_07,
7060 class ARGS_08,
7061 class ARGS_09>
7063 TARGET_TYPE *toBegin,
7064 TARGET_TYPE *toEnd,
7065 ALLOCATOR allocator,
7067 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7068 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7069 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7070 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7071 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7072 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7073 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7074 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7075 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7076{
7078 toEnd));
7080
7081 size_type numElements = 1;
7082
7083
7084 size_type tailLen = toEnd - toBegin;
7085 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
7086
7087
7088 TARGET_TYPE *destBegin = toBegin + numElements;
7089 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
7090 std::memmove((void *)destBegin,
7091 toBegin,
7092 tailLen * sizeof(TARGET_TYPE));
7093 }
7094
7095
7096 TARGET_TYPE *destEnd = toEnd + numElements;
7097
7098 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7099 destEnd - numGuarded,
7100 destEnd - numGuarded,
7101 destEnd,
7102 allocator);
7103
7104 while (guard.middle() != guard.end()) {
7106 guard.destination(),
7107 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7108 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7109 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7110 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7111 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7112 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7113 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7114 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7115 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7116 guard.advance();
7117 }
7118
7119
7120 if (tailLen < numElements) {
7121
7122 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7123 destEnd,
7124 allocator);
7125
7126
7127 while (toEnd != destBegin) {
7129 --destBegin,
7130 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7131 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7132 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7133 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7134 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7135 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7136 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7137 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7138 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09));
7139
7140 endGuard.moveBegin(-1);
7141 }
7142 endGuard.release();
7143 }
7144}
7145#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7146
7147#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7148template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7149 class ARGS_02,
7150 class ARGS_03,
7151 class ARGS_04,
7152 class ARGS_05,
7153 class ARGS_06,
7154 class ARGS_07,
7155 class ARGS_08,
7156 class ARGS_09,
7157 class ARGS_10>
7159 TARGET_TYPE *toBegin,
7160 TARGET_TYPE *toEnd,
7161 ALLOCATOR allocator,
7163 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7164 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7165 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7166 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7167 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7168 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7169 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7170 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7171 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7172 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
7173{
7175 toEnd));
7177
7178 size_type numElements = 1;
7179
7180
7181 size_type tailLen = toEnd - toBegin;
7182 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
7183
7184
7185 TARGET_TYPE *destBegin = toBegin + numElements;
7186 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
7187 std::memmove((void *)destBegin,
7188 toBegin,
7189 tailLen * sizeof(TARGET_TYPE));
7190 }
7191
7192
7193 TARGET_TYPE *destEnd = toEnd + numElements;
7194
7195 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7196 destEnd - numGuarded,
7197 destEnd - numGuarded,
7198 destEnd,
7199 allocator);
7200
7201 while (guard.middle() != guard.end()) {
7203 guard.destination(),
7204 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7205 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7206 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7207 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7208 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7209 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7210 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7211 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7212 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
7213 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
7214 guard.advance();
7215 }
7216
7217
7218 if (tailLen < numElements) {
7219
7220 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7221 destEnd,
7222 allocator);
7223
7224
7225 while (toEnd != destBegin) {
7227 --destBegin,
7228 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7229 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7230 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7231 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7232 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7233 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7234 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7235 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7236 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7237 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10));
7238
7239 endGuard.moveBegin(-1);
7240 }
7241 endGuard.release();
7242 }
7243}
7244#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7245
7246
7247#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
7248template <class TARGET_TYPE, class ALLOCATOR>
7250 TARGET_TYPE *toBegin,
7251 TARGET_TYPE *toEnd,
7252 ALLOCATOR allocator,
7254{
7256 toEnd));
7258
7259
7260 if (toEnd > toBegin) {
7261
7264 allocator,
7265 BSLS_UTIL_ADDRESSOF(space.object()));
7267 BSLS_UTIL_ADDRESSOF(space.object()));
7268
7269
7271 allocator,
7272 toEnd,
7274
7275 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7276 toEnd + 1,
7277 allocator);
7278
7279
7280 TARGET_TYPE *destEnd = toEnd;
7281 TARGET_TYPE *srcEnd = toEnd - 1;
7282 while (toBegin != srcEnd) {
7283 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7284 }
7285
7286
7288
7289 guard.release();
7290 }
7291 else {
7292
7294 allocator, toEnd);
7295 }
7296}
7297#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
7298
7299#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
7300template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
7302 TARGET_TYPE *toBegin,
7303 TARGET_TYPE *toEnd,
7304 ALLOCATOR allocator,
7306 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
7307{
7309 toEnd));
7311
7312
7313 if (toEnd > toBegin) {
7314
7317 allocator,
7318 BSLS_UTIL_ADDRESSOF(space.object()),
7319 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
7321 BSLS_UTIL_ADDRESSOF(space.object()));
7322
7323
7325 allocator,
7326 toEnd,
7328
7329 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7330 toEnd + 1,
7331 allocator);
7332
7333
7334 TARGET_TYPE *destEnd = toEnd;
7335 TARGET_TYPE *srcEnd = toEnd - 1;
7336 while (toBegin != srcEnd) {
7337 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7338 }
7339
7340
7342
7343 guard.release();
7344 }
7345 else {
7346
7348 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
7349 }
7350}
7351#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
7352
7353#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
7354template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7355 class ARGS_02>
7357 TARGET_TYPE *toBegin,
7358 TARGET_TYPE *toEnd,
7359 ALLOCATOR allocator,
7361 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7362 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
7363{
7365 toEnd));
7367
7368
7369 if (toEnd > toBegin) {
7370
7373 allocator,
7374 BSLS_UTIL_ADDRESSOF(space.object()),
7375 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7376 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
7378 BSLS_UTIL_ADDRESSOF(space.object()));
7379
7380
7382 allocator,
7383 toEnd,
7385
7386 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7387 toEnd + 1,
7388 allocator);
7389
7390
7391 TARGET_TYPE *destEnd = toEnd;
7392 TARGET_TYPE *srcEnd = toEnd - 1;
7393 while (toBegin != srcEnd) {
7394 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7395 }
7396
7397
7399
7400 guard.release();
7401 }
7402 else {
7403
7405 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7406 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
7407 }
7408}
7409#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
7410
7411#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
7412template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7413 class ARGS_02,
7414 class ARGS_03>
7416 TARGET_TYPE *toBegin,
7417 TARGET_TYPE *toEnd,
7418 ALLOCATOR allocator,
7420 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7421 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7422 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
7423{
7425 toEnd));
7427
7428
7429 if (toEnd > toBegin) {
7430
7433 allocator,
7434 BSLS_UTIL_ADDRESSOF(space.object()),
7435 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7436 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7437 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
7439 BSLS_UTIL_ADDRESSOF(space.object()));
7440
7441
7443 allocator,
7444 toEnd,
7446
7447 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7448 toEnd + 1,
7449 allocator);
7450
7451
7452 TARGET_TYPE *destEnd = toEnd;
7453 TARGET_TYPE *srcEnd = toEnd - 1;
7454 while (toBegin != srcEnd) {
7455 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7456 }
7457
7458
7460
7461 guard.release();
7462 }
7463 else {
7464
7466 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7467 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7468 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
7469 }
7470}
7471#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
7472
7473#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
7474template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7475 class ARGS_02,
7476 class ARGS_03,
7477 class ARGS_04>
7479 TARGET_TYPE *toBegin,
7480 TARGET_TYPE *toEnd,
7481 ALLOCATOR allocator,
7483 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7485 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7486 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
7487{
7489 toEnd));
7491
7492
7493 if (toEnd > toBegin) {
7494
7497 allocator,
7498 BSLS_UTIL_ADDRESSOF(space.object()),
7499 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7500 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7501 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7502 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
7504 BSLS_UTIL_ADDRESSOF(space.object()));
7505
7506
7508 allocator,
7509 toEnd,
7511
7512 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7513 toEnd + 1,
7514 allocator);
7515
7516
7517 TARGET_TYPE *destEnd = toEnd;
7518 TARGET_TYPE *srcEnd = toEnd - 1;
7519 while (toBegin != srcEnd) {
7520 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7521 }
7522
7523
7525
7526 guard.release();
7527 }
7528 else {
7529
7531 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7532 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7533 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7534 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
7535 }
7536}
7537#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
7538
7539#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
7540template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7541 class ARGS_02,
7542 class ARGS_03,
7543 class ARGS_04,
7544 class ARGS_05>
7546 TARGET_TYPE *toBegin,
7547 TARGET_TYPE *toEnd,
7548 ALLOCATOR allocator,
7550 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7551 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7552 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7553 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7554 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
7555{
7557 toEnd));
7559
7560
7561 if (toEnd > toBegin) {
7562
7565 allocator,
7566 BSLS_UTIL_ADDRESSOF(space.object()),
7567 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7568 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7569 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7570 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7571 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
7573 BSLS_UTIL_ADDRESSOF(space.object()));
7574
7575
7577 allocator,
7578 toEnd,
7580
7581 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7582 toEnd + 1,
7583 allocator);
7584
7585
7586 TARGET_TYPE *destEnd = toEnd;
7587 TARGET_TYPE *srcEnd = toEnd - 1;
7588 while (toBegin != srcEnd) {
7589 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7590 }
7591
7592
7594
7595 guard.release();
7596 }
7597 else {
7598
7600 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7601 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7602 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7603 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7604 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
7605 }
7606}
7607#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
7608
7609#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
7610template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7611 class ARGS_02,
7612 class ARGS_03,
7613 class ARGS_04,
7614 class ARGS_05,
7615 class ARGS_06>
7617 TARGET_TYPE *toBegin,
7618 TARGET_TYPE *toEnd,
7619 ALLOCATOR allocator,
7621 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7622 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7623 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7624 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7625 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7626 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
7627{
7629 toEnd));
7631
7632
7633 if (toEnd > toBegin) {
7634
7637 allocator,
7638 BSLS_UTIL_ADDRESSOF(space.object()),
7639 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7640 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7641 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7642 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7643 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7644 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
7646 BSLS_UTIL_ADDRESSOF(space.object()));
7647
7648
7650 allocator,
7651 toEnd,
7653
7654 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7655 toEnd + 1,
7656 allocator);
7657
7658
7659 TARGET_TYPE *destEnd = toEnd;
7660 TARGET_TYPE *srcEnd = toEnd - 1;
7661 while (toBegin != srcEnd) {
7662 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7663 }
7664
7665
7667
7668 guard.release();
7669 }
7670 else {
7671
7673 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7674 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7675 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7676 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7677 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7678 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
7679 }
7680}
7681#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
7682
7683#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
7684template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7685 class ARGS_02,
7686 class ARGS_03,
7687 class ARGS_04,
7688 class ARGS_05,
7689 class ARGS_06,
7690 class ARGS_07>
7692 TARGET_TYPE *toBegin,
7693 TARGET_TYPE *toEnd,
7694 ALLOCATOR allocator,
7696 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7697 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7698 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7699 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7700 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7701 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7702 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
7703{
7705 toEnd));
7707
7708
7709 if (toEnd > toBegin) {
7710
7713 allocator,
7714 BSLS_UTIL_ADDRESSOF(space.object()),
7715 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7716 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7717 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7718 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7719 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7720 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7721 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
7723 BSLS_UTIL_ADDRESSOF(space.object()));
7724
7725
7727 allocator,
7728 toEnd,
7730
7731 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7732 toEnd + 1,
7733 allocator);
7734
7735
7736 TARGET_TYPE *destEnd = toEnd;
7737 TARGET_TYPE *srcEnd = toEnd - 1;
7738 while (toBegin != srcEnd) {
7739 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7740 }
7741
7742
7744
7745 guard.release();
7746 }
7747 else {
7748
7750 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7751 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7752 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7753 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7754 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7755 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7756 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
7757 }
7758}
7759#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
7760
7761#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7762template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7763 class ARGS_02,
7764 class ARGS_03,
7765 class ARGS_04,
7766 class ARGS_05,
7767 class ARGS_06,
7768 class ARGS_07,
7769 class ARGS_08>
7771 TARGET_TYPE *toBegin,
7772 TARGET_TYPE *toEnd,
7773 ALLOCATOR allocator,
7775 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7776 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7777 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7778 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7779 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7780 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7781 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7782 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
7783{
7785 toEnd));
7787
7788
7789 if (toEnd > toBegin) {
7790
7793 allocator,
7794 BSLS_UTIL_ADDRESSOF(space.object()),
7795 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7796 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7797 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7798 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7799 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7800 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7801 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7802 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7804 BSLS_UTIL_ADDRESSOF(space.object()));
7805
7806
7808 allocator,
7809 toEnd,
7811
7812 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7813 toEnd + 1,
7814 allocator);
7815
7816
7817 TARGET_TYPE *destEnd = toEnd;
7818 TARGET_TYPE *srcEnd = toEnd - 1;
7819 while (toBegin != srcEnd) {
7820 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7821 }
7822
7823
7825
7826 guard.release();
7827 }
7828 else {
7829
7831 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7832 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7833 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7834 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7835 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7836 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7837 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7838 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7839 }
7840}
7841#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7842
7843#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7844template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7845 class ARGS_02,
7846 class ARGS_03,
7847 class ARGS_04,
7848 class ARGS_05,
7849 class ARGS_06,
7850 class ARGS_07,
7851 class ARGS_08,
7852 class ARGS_09>
7854 TARGET_TYPE *toBegin,
7855 TARGET_TYPE *toEnd,
7856 ALLOCATOR allocator,
7858 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7859 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7860 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7862 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7863 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7864 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7865 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7866 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7867{
7869 toEnd));
7871
7872
7873 if (toEnd > toBegin) {
7874
7877 allocator,
7878 BSLS_UTIL_ADDRESSOF(space.object()),
7879 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7880 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7881 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7882 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7883 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7884 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7885 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7886 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7887 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7889 BSLS_UTIL_ADDRESSOF(space.object()));
7890
7891
7893 allocator,
7894 toEnd,
7896
7897 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7898 toEnd + 1,
7899 allocator);
7900
7901
7902 TARGET_TYPE *destEnd = toEnd;
7903 TARGET_TYPE *srcEnd = toEnd - 1;
7904 while (toBegin != srcEnd) {
7905 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7906 }
7907
7908
7910
7911 guard.release();
7912 }
7913 else {
7914
7916 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7917 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7918 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7919 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7920 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7921 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7922 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7923 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7924 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7925 }
7926}
7927#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7928
7929#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7930template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7931 class ARGS_02,
7932 class ARGS_03,
7933 class ARGS_04,
7934 class ARGS_05,
7935 class ARGS_06,
7936 class ARGS_07,
7937 class ARGS_08,
7938 class ARGS_09,
7939 class ARGS_10>
7941 TARGET_TYPE *toBegin,
7942 TARGET_TYPE *toEnd,
7943 ALLOCATOR allocator,
7945 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7946 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7947 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7948 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7949 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7950 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7951 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7952 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7953 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7954 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
7955{
7957 toEnd));
7959
7960
7961 if (toEnd > toBegin) {
7962
7965 allocator,
7966 BSLS_UTIL_ADDRESSOF(space.object()),
7967 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7968 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7969 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7970 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7971 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7972 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7973 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7974 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7975 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
7976 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
7978 BSLS_UTIL_ADDRESSOF(space.object()));
7979
7980
7982 allocator,
7983 toEnd,
7985
7986 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7987 toEnd + 1,
7988 allocator);
7989
7990
7991 TARGET_TYPE *destEnd = toEnd;
7992 TARGET_TYPE *srcEnd = toEnd - 1;
7993 while (toBegin != srcEnd) {
7994 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7995 }
7996
7997
7999
8000 guard.release();
8001 }
8002 else {
8003
8005 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8006 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8007 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8008 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8009 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8010 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8011 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8012 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8013 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
8014 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
8015 }
8016}
8017#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
8018
8019#else
8020// The generated code below is a workaround for the absence of perfect
8021// forwarding in some compilers.
8022template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8023inline
8025 TARGET_TYPE *toBegin,
8026 TARGET_TYPE *toEnd,
8027 ALLOCATOR allocator,
8030{
8031
8033 toBegin,
8034 toEnd,
8035 allocator,
8037 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8038}
8039
8040template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8042 TARGET_TYPE *toBegin,
8043 TARGET_TYPE *toEnd,
8044 ALLOCATOR allocator,
8047{
8049 toEnd));
8051
8052 size_type numElements = 1;
8053
8054
8055 size_type tailLen = toEnd - toBegin;
8056 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8057
8058
8059 TARGET_TYPE *destBegin = toBegin + numElements;
8060 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8061 std::memmove((void *)destBegin,
8062 toBegin,
8063 tailLen * sizeof(TARGET_TYPE));
8064 }
8065
8066
8067 TARGET_TYPE *destEnd = toEnd + numElements;
8068
8069 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8070 destEnd - numGuarded,
8071 destEnd - numGuarded,
8072 destEnd,
8073 allocator);
8074
8075 while (guard.middle() != guard.end()) {
8077 guard.destination(),
8078 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8079 guard.advance();
8080 }
8081
8082
8083 if (tailLen < numElements) {
8084
8085 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
8086 destEnd,
8087 allocator);
8088
8089
8090 while (toEnd != destBegin) {
8092 --destBegin,
8093 BSLS_COMPILERFEATURES_FORWARD(ARGS,args)...);
8094
8095 endGuard.moveBegin(-1);
8096 }
8097 endGuard.release();
8098 }
8099}
8100
8101template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8103 TARGET_TYPE *toBegin,
8104 TARGET_TYPE *toEnd,
8105 ALLOCATOR allocator,
8108{
8110 toEnd));
8112
8113
8114 if (toEnd > toBegin) {
8115
8118 allocator,
8119 BSLS_UTIL_ADDRESSOF(space.object()),
8120 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8122 BSLS_UTIL_ADDRESSOF(space.object()));
8123
8124
8126 allocator,
8127 toEnd,
8129
8130 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8131 toEnd + 1,
8132 allocator);
8133
8134
8135 TARGET_TYPE *destEnd = toEnd;
8136 TARGET_TYPE *srcEnd = toEnd - 1;
8137 while (toBegin != srcEnd) {
8138 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
8139 }
8140
8141
8143
8144 guard.release();
8145 }
8146 else {
8147
8149 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8150 }
8151}
8152// }}} END GENERATED CODE
8153#endif
8154
8155 // *** 'erase' overloads: ***
8156
8157template <class TARGET_TYPE, class ALLOCATOR>
8159 TARGET_TYPE *first,
8160 TARGET_TYPE *middle,
8161 TARGET_TYPE *last,
8162 ALLOCATOR allocator,
8164{
8167
8168 // Key to the transformation diagrams:
8169 //..
8170 // t...z Original contents of '[first, middle)'
8171 // A...G Original contents of '[middle, last)'
8172 // _ Destroyed array element
8173 //..
8174
8175 //..
8176 // Transformation: tuvABCDEFG => ___ABCDEFG (no throw)
8177 //..
8178 ArrayDestructionPrimitives::destroy(first, middle, allocator);
8179
8180 //..
8181 // Transformation: ___ABCDEFG => ABCDEFG___ (might overlap, but no throw)
8182 //..
8183 size_type numBytes = reinterpret_cast<const char *>(last)
8184 - reinterpret_cast<const char *>(middle);
8185 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8186 std::memmove((void *)first, middle, numBytes);
8187 }
8188}
8189
8190template <class TARGET_TYPE, class ALLOCATOR>
8192 TARGET_TYPE *first,
8193 TARGET_TYPE *middle,
8194 TARGET_TYPE *last,
8195 ALLOCATOR allocator,
8197{
8200
8201 // Key to the transformation diagrams:
8202 //..
8203 // t...z Original contents of '[first, middle)'
8204 // A...G Original contents of '[middle, last)'
8205 // _ Destructed array element
8206 //..
8207
8208 //..
8209 // Transformation: tuvABCDEFG => ABCDEFGEFG.
8210 //..
8211
8212 while (middle != last) {
8213 *first++ = bslmf::MovableRefUtil::move_if_noexcept(*middle++);
8214 }
8215
8216 //..
8217 // Transformation: ABCDEFGEFG => ABCDEFG___.
8218 //..
8219
8220 ArrayDestructionPrimitives::destroy(first, middle, allocator);
8221}
8222
8223 // *** 'insert' with 'value' overloads: ***
8224
8225template <class TARGET_TYPE, class ALLOCATOR>
8226inline
8228 TARGET_TYPE *toBegin,
8229 TARGET_TYPE *toEnd,
8230 const TARGET_TYPE& value,
8231 size_type numElements,
8232 ALLOCATOR allocator,
8234{
8237
8238 // Key to the transformation diagrams:
8239 //..
8240 // A...G original contents of '[toBegin, toEnd)' ("tail")
8241 // v...v contents of '[fromBegin, fromEnd)' ("input")
8242 // _____ uninitialized array element
8243 //..
8244
8245 // ALIASING: If 'value' is a reference into the array 'toBegin..toEnd',
8246 // then moving the array first might introduce a change in 'value'. Since
8247 // type is bitwise copyable, then no memory changes outside the array, so
8248 // the test below is sufficient to discover all the possible aliasing.
8249 // Note that we never make a copy.
8250
8251 const TARGET_TYPE *tempValuePtr = BSLS_UTIL_ADDRESSOF(value);
8252 if (toBegin <= tempValuePtr && tempValuePtr < toEnd ) {
8253 // Adjust pointer for shifting after the move.
8254
8255 tempValuePtr += numElements;
8256 }
8257
8258 //..
8259 // Transformation: ABCDE___ => ___ABCDE (might overlap).
8260 //..
8261
8262 const size_type numBytes = reinterpret_cast<const char*>(toEnd)
8263 - reinterpret_cast<const char*>(toBegin);
8264 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8265 std::memmove((void *)(toBegin + numElements), toBegin, numBytes);
8266 }
8267
8268 //..
8269 // Transformation: ___ABCDE => v__ABCDE (no overlap).
8270 //..
8271
8272 // Use 'copyConstruct' instead of 'memcpy' because the former optimizes for
8273 // fundamental types using 'operator=' instead, which avoid the 'memcpy'
8274 // function call.
8275
8277 toBegin,
8278 *tempValuePtr);
8279 //..
8280 // Transformation: v__ABCDE => vvvABCDE.
8281 //..
8282
8283 bitwiseFillN(reinterpret_cast<char *>(toBegin),
8284 sizeof value,
8285 numElements * sizeof value);
8286}
8287
8288template <class TARGET_TYPE, class ALLOCATOR>
8290 TARGET_TYPE *toBegin,
8291 TARGET_TYPE *toEnd,
8292 const TARGET_TYPE& value,
8293 size_type numElements,
8294 ALLOCATOR allocator,
8296{
8299
8300 // Key to the transformation diagrams:
8301 //..
8302 // A...G original contents of '[toBegin, toEnd)' ("tail")
8303 // v...v contents of '[fromBegin, fromEnd)' ("input")
8304 // _____ uninitialized array element
8305 // [...] part of an array guarded by an exception guard object
8306 // |.(.,.) part of array guarded by move guard
8307 // (middle indicated by ',' and dest by '|')
8308 //..
8309
8310 const TARGET_TYPE *tempValuePtr = BSLS_UTIL_ADDRESSOF(value);
8311 if (toBegin <= tempValuePtr && tempValuePtr < toEnd + numElements) {
8312 // Adjust pointer for shifting after the move.
8313
8314 tempValuePtr += numElements;
8315 }
8316
8317 size_type tailLen = toEnd - toBegin;
8318 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8319
8320 //..
8321 // Transformation: ABCDE_______ => _______ABCDE (might overlap)
8322 //..
8323
8324 TARGET_TYPE *destBegin = toBegin + numElements;
8325 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8326 std::memmove((void *)destBegin,
8327 toBegin,
8328 tailLen * sizeof(TARGET_TYPE));
8329 }
8330
8331 //..
8332 // Transformation: |_______(,ABCDE) => vvvvv|__(ABCDE,)
8333 //..
8334
8335 TARGET_TYPE *destEnd = toEnd + numElements;
8336
8337 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8338 destEnd - numGuarded,
8339 destEnd - numGuarded,
8340 destEnd,
8341 allocator);
8342
8343 while (guard.middle() != guard.end()) {
8345 guard.destination(),
8346 *tempValuePtr);
8347 guard.advance();
8348 }
8349
8350 // The bitwise 'guard' is now inactive, since 'middle() == end()' and
8351 // 'guard.destination()' is the smaller of 'destBegin' or 'toEnd'.
8352
8353 if (tailLen < numElements) {
8354 // There still is a gap of 'numElements - tailLen' to fill in between
8355 // 'toEnd' and 'destBegin'. The elements that have been 'memmove'-ed
8356 // need to be guarded, we fill the gap backward from there to keep
8357 // guarded portion in one piece.
8358
8359 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
8360 destEnd,
8361 allocator);
8362
8363 //..
8364 // Transformation: vvvvv__[ABCDE] => vvvvv[vvABCDE]
8365 //..
8366
8367 while (toEnd != destBegin) {
8369 --destBegin,
8370 *tempValuePtr);
8371
8372 endGuard.moveBegin(-1);
8373 }
8374 endGuard.release();
8375 }
8376}
8377
8378template <class TARGET_TYPE, class ALLOCATOR>
8380 TARGET_TYPE *toBegin,
8381 TARGET_TYPE *toEnd,
8382 const TARGET_TYPE& value,
8383 size_type numElements,
8384 ALLOCATOR allocator,
8386{
8389
8390 // Aliasing: Make a temp copy of 'value' (always). The reason is that
8391 // 'value' could be a reference inside the input range, or even outside
8392 // but with lifetime controlled by one of these values, and so the next
8393 // transformation could invalidate 'value'. Note: One cannot rely on
8394 // 'TARGET_TYPE' to have a single-argument copy constructor (i.e.,
8395 // default allocator argument to 0) if it takes an allocator; hence the
8396 // constructor proxy.
8397
8401 value);
8403 BSLS_UTIL_ADDRESSOF(space.object()));
8404
8405 // Key to the transformation diagrams:
8406 //..
8407 // A...G original contents of '[toBegin, toEnd)' ("tail")
8408 // v...v copies of 'value' ("input")
8409 // _____ uninitialized array elements
8410 // [...] part of array protected by an exception guard object
8411 //..
8412
8413 const size_type tailLen = toEnd - toBegin;
8414 if (tailLen >= numElements) {
8415 // Tail is not shorter than input.
8416
8417 //..
8418 // Transformation: ABCDEFG___[] => ABCDEFG[EFG].
8419 //..
8420
8421 moveIfNoexcept(toEnd, // destination
8422 toEnd - numElements, // source
8423 toEnd, // end source
8424 allocator,
8426
8427 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8428 toEnd + numElements,
8429 allocator);
8430
8431 // TBD: this does the same thing as the old code - don't like that we
8432 // circumvent the whole allocator thing, but for now, let's keep it
8433 // consistent.
8434 // ConstructorProxy<TARGET_TYPE>
8435 // tempValue(value, bslma::Default::allocator());
8436
8437 //..
8438 // Transformation: ABCDEFG[EFG] => ABCABCD[EFG].
8439 //..
8440
8441 TARGET_TYPE *src = toEnd - numElements;
8442 TARGET_TYPE *dest = toEnd;
8443 while (toBegin != src) {
8445 }
8446
8447 //..
8448 // Transformation: ABCABCD[EFG] => vvvABCD[EFG].
8449 //..
8450
8451 for ( ; toBegin != dest; ++toBegin) {
8452 *toBegin = space.object();
8453 }
8454 // TBD: this can't be good
8455 guard.release();
8456 }
8457 else {
8458 // Tail is shorter than input. We can avoid the temp copy of value
8459 // since there will be space to make a first copy after the tail, and
8460 // use that to make the subsequent copies.
8461 //
8462 // TBD: Update comment now that the assumption is no longer true, and
8463 // we make a copy at the top of the call, regardless. We could
8464 // restore this optimization if we use metaprogramming to check if
8465 // 'moveIfNoexcept' will move or copy, but not convinced it is worth
8466 // the complexity.
8467
8468 difference_type remElements = numElements - tailLen;
8469
8470 //..
8471 // Transformation: ABC_______[] => ABC____[ABC].
8472 //..
8473
8474 moveIfNoexcept(toBegin + numElements, // destination
8475 toBegin, // source
8476 toEnd, // end source
8477 allocator,
8479
8480 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd + remElements,
8481 toEnd + numElements,
8482 allocator);
8483
8484 //..
8485 // Transformation: ABC____[ABC] => ABC[vvvvABC].
8486 //..
8487
8488 uninitializedFillN(toEnd,
8489 space.object(),
8490 remElements,
8491 &allocator,
8493 guard.moveBegin(-remElements);
8494
8495 //..
8496 // Transformation: ABC[vvvvABC] => vvv[vvvvABC].
8497 //..
8498
8499 for ( ; toBegin != toEnd; ++toBegin) {
8500 *toBegin = space.object();
8501 }
8502
8503 guard.release();
8504 }
8505}
8506
8507 // *** 'insert' with 'FWD_ITER' overloads: ***
8508
8509
8510template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
8511inline
8513 TARGET_TYPE *toBegin,
8514 TARGET_TYPE *toEnd,
8515 FWD_ITER fromBegin,
8516 FWD_ITER fromEnd,
8517 size_type numElements,
8518 ALLOCATOR allocator,
8520{
8521 // We may be casting a function pointer to a 'void *' here, so this won't
8522 // work if we port to an architecture where the two are of different sizes.
8523
8524 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
8525
8526#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
8527 // fall back on traditional C-style casts.
8528 insert((void * *)toBegin,
8529 (void * *)toEnd,
8530 (void * const *)fromBegin,
8531 (void * const *)fromEnd,
8532 numElements,
8533 allocator,
8535#else
8536 typedef typename bsl::remove_cv<
8537 typename bsl::remove_pointer<TARGET_TYPE>::type>::type NcPtrType;
8538
8539 typedef typename bsl::remove_cv<
8540 typename bsl::remove_pointer<
8541 typename bsl::remove_pointer<FWD_ITER>::type>::type>::type NcIter;
8542
8543 insert(
8544 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toBegin)),
8545 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toEnd)),
8546 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromBegin)),
8547 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromEnd)),
8548 numElements,
8549 allocator,
8551#endif
8552}
8553
8554template <class TARGET_TYPE, class ALLOCATOR>
8555inline
8557 TARGET_TYPE *toBegin,
8558 TARGET_TYPE *toEnd,
8559 const TARGET_TYPE *fromBegin,
8560 const TARGET_TYPE *fromEnd,
8561 size_type numElements,
8562 ALLOCATOR,
8564{
8566
8567 // 'FWD_ITER' has been converted to a 'const TARGET_TYPE *' and
8568 // 'TARGET_TYPE' is bit-wise copyable.
8571 BSLS_ASSERT_SAFE(fromBegin || 0 == numElements);
8572
8573 BSLS_ASSERT_SAFE(fromBegin + numElements == fromEnd);
8574 BSLS_ASSERT_SAFE(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8575
8576 (void) fromEnd; // quell warning when 'BSLS_ASSERT_SAFE' is compiled out
8577
8578 // Key to the transformation diagrams:
8579 //..
8580 // A...G original contents of '[toBegin, toEnd)' ("tail")
8581 // t...z contents of '[fromBegin, fromEnd)' ("input")
8582 // _____ uninitialized array element
8583 //..
8584
8585 //..
8586 // Transformation: ABCDE_______ => _______ABCDE (might overlap).
8587 //..
8588
8589 const size_type numBytes = reinterpret_cast<const char*>(toEnd)
8590 - reinterpret_cast<const char*>(toBegin);
8591 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8592 std::memmove((void *)(toBegin + numElements), toBegin, numBytes);
8593 }
8594
8595 //..
8596 // Transformation: _______ABCDE => tuvwxyzABCDE (no overlap).
8597 //..
8598
8599 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
8600 std::memcpy((void *)toBegin,
8601 fromBegin,
8602 numElements * sizeof(TARGET_TYPE));
8603 }
8604}
8605
8606template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
8608 TARGET_TYPE *toBegin,
8609 TARGET_TYPE *toEnd,
8610 FWD_ITER fromBegin,
8611 FWD_ITER,
8612 size_type numElements,
8613 ALLOCATOR allocator,
8615{
8616 // 'TARGET_TYPE' is bit-wise moveable.
8619
8620 if (0 == numElements) {
8621 return; // RETURN
8622 }
8623
8624 // The following assertions make sense only if 'FWD_ITER' is a pointer to a
8625 // possibly cv-qualified 'TARGET_TYPE', and are tested in that overload
8626 // (see above).
8627 //..
8628 // BSLS_ASSERT(fromBegin + numElements == fromEnd);
8629 // BSLS_ASSERT(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8630 //..
8631
8632 // Key to the transformation diagrams:
8633 //..
8634 // A...G original contents of '[toBegin, toEnd)' ("tail")
8635 // t...z contents of '[fromBegin, fromEnd)' ("input")
8636 // _____ uninitialized array element
8637 // [...] part of array guarded by exception guard
8638 // |.(.,.) part of array guarded by move guard
8639 // (middle indicated by ',' and dest by '|')
8640 //..
8641
8642 const size_type tailLen = toEnd - toBegin;
8643 const size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8644
8645 //..
8646 // Transformation: ABCDE____ => ____ABCDE (might overlap).
8647 //..
8648
8649 TARGET_TYPE *destBegin = toBegin + numElements;
8650 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8651 std::memmove((void *)destBegin,
8652 toBegin,
8653 tailLen * sizeof(TARGET_TYPE));
8654 }
8655
8656 //..
8657 // Transformation: |_______(,ABCDE) => tuvwx|__(ABCDE,).
8658 //..
8659
8660 TARGET_TYPE *destEnd = toEnd + numElements;
8661
8662 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8663 destEnd - numGuarded,
8664 destEnd - numGuarded,
8665 destEnd,
8666 allocator);
8667
8668 for (; guard.middle() != guard.end(); ++fromBegin) {
8670 guard.destination(),
8671 *fromBegin);
8672 guard.advance();
8673 }
8674
8675 // The bitwise 'guard' is now inactive, since 'middle() == end()', and
8676 // 'guard.destination()' is the smaller of 'destBegin' or 'toEnd'.
8677
8678 if (tailLen < numElements) {
8679 // There still is a gap of 'numElements - tailLen' to fill in between
8680 // 'toEnd' and 'destBegin'. The elements that have been 'memmove'-ed
8681 // need to be guarded, and we need to continue to fill the hole at the
8682 // same guarding the copied elements as well.
8683
8684 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard1(toEnd,
8685 toEnd,
8686 allocator);
8687 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard2(destBegin,
8688 destEnd,
8689 allocator);
8690
8691 //..
8692 // Transformation: tuvwx[]__[ABCDE] => tuvwx[yz][ABCDE].
8693 //..
8694
8695 for (; toEnd != destBegin; ++fromBegin) {
8697 toEnd,
8698 *fromBegin);
8699 toEnd = endGuard1.moveEnd(1);
8700 }
8701 endGuard1.release();
8702 endGuard2.release();
8703 }
8704}
8705
8706template <class TARGET_TYPE, class FWD_ITER, class ALLOCATOR>
8708 TARGET_TYPE *toBegin,
8709 TARGET_TYPE *toEnd,
8710 FWD_ITER fromBegin,
8711 FWD_ITER fromEnd,
8712 size_type numElements,
8713 ALLOCATOR allocator,
8715{
8718
8719 if (0 == numElements) {
8720 return; // RETURN
8721 }
8722
8723 // Key to the transformation diagrams:
8724 //..
8725 // A...G original contents of '[toBegin, toEnd)' ("tail")
8726 // t...z contents of '[fromBegin, fromEnd)' ("input")
8727 // _____ uninitialized array elements
8728 // [...] part of array protected by a guard object
8729 //..
8730
8731 const size_type tailLen = toEnd - toBegin;
8732 if (tailLen > numElements) {
8733 // Tail is longer than input.
8734
8735 //..
8736 // Transformation: ABCDEFG___[] => ABCDEFG[EFG].
8737 //..
8738
8739 moveIfNoexcept(toEnd, // destination
8740 toEnd - numElements, // source
8741 toEnd, // end source
8742 allocator,
8744
8745 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8746 toEnd + numElements,
8747 allocator);
8748
8749 //..
8750 // Transformation: ABCDEFG[EFG] => ABCABCD[EFG].
8751 //..
8752
8753 TARGET_TYPE *src = toEnd - numElements;
8754 TARGET_TYPE *dest = toEnd;
8755 while (toBegin != src) {
8757 }
8758
8759 //..
8760 // Transformation: ABCABCD[EFG] => tuvABCD[EFG].
8761 //..
8762
8763 for (; toBegin != dest; ++toBegin, ++fromBegin) {
8764 *toBegin = *fromBegin;
8765 }
8766
8767 guard.release();
8768 }
8769 else {
8770 // Tail is not longer than input (numElements).
8771
8772 difference_type remElements = numElements - tailLen;
8773
8774 //..
8775 // Transformation: ABC_______[] => ABC____[ABC]
8776 //..
8777
8778 moveIfNoexcept(toBegin + numElements, // destination
8779 toBegin, // source
8780 toEnd, // end source
8781 allocator,
8783
8784 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd + remElements,
8785 toEnd + numElements,
8786 allocator);
8787
8788 //..
8789 // Transformation: ABC____[ABC] => tuv____[ABC].
8790 //..
8791
8792 for (; toBegin != toEnd; ++fromBegin, ++toBegin) {
8793 *toBegin = *fromBegin;
8794 }
8795
8796 //..
8797 // Transformation: tuv____[ABC] => tuvwxyzABC[].
8798 //..
8799 copyConstruct(toBegin,
8800 fromBegin,
8801 fromEnd,
8802 allocator,
8804
8805 guard.release();
8806 }
8807}
8808
8809template <class FWD_ITER, class ALLOCATOR>
8811 void **toBegin,
8812 void **toEnd,
8813 FWD_ITER fromBegin,
8814 FWD_ITER,
8815 size_type numElements,
8816 ALLOCATOR,
8818{
8819 // This very specific overload is required for the case that 'FWD_ITER' is
8820 // an iterator that is not a pointer, iterating over a sequence of function
8821 // pointers. The implementation relies on the conditionally-supported
8822 // behavior that any function pointer can be @ref reinterpret_cast to
8823 // 'void *'.
8824
8825 // 'TARGET_TYPE' is bit-wise moveable.
8828
8829 if (0 == numElements) {
8830 return; // RETURN
8831 }
8832
8833 // The following assertions make sense only if 'FWD_ITER' is a pointer to a
8834 // possibly cv-qualified 'TARGET_TYPE', and are tested in that overload
8835 // (see above).
8836 //..
8837 // BSLS_ASSERT(fromBegin + numElements == fromEnd);
8838 // BSLS_ASSERT(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8839 //..
8840
8841 // Key to the transformation diagrams:
8842 //..
8843 // A...G original contents of '[toBegin, toEnd)' ("tail")
8844 // t...z contents of '[fromBegin, fromEnd)' ("input")
8845 // _____ uninitialized array element
8846 // [...] part of array guarded by exception guard
8847 // |.(.,.) part of array guarded by move guard
8848 // (middle indicated by ',' and dest by '|')
8849 //..
8850
8851 const size_type tailLen = toEnd - toBegin;
8852
8853 //..
8854 // Transformation: ABCDE____ => ____ABCDE (might overlap).
8855 //..
8856
8857 void **destBegin = toBegin + numElements;
8858
8859 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8860 std::memmove(destBegin, toBegin, tailLen * sizeof(void **));
8861 }
8862
8863 for (size_type i = 0; i < numElements; ++i) {
8864 *toBegin = reinterpret_cast<void *>(*fromBegin);
8865
8866 ++fromBegin;
8867 ++toBegin;
8868 }
8869}
8870
8871 // *** 'moveInsert' overloads: ***
8872
8873template <class TARGET_TYPE, class ALLOCATOR>
8874inline
8876 TARGET_TYPE *toBegin,
8877 TARGET_TYPE *toEnd,
8878 TARGET_TYPE **lastPtr,
8879 TARGET_TYPE *first,
8880 TARGET_TYPE *last,
8881 size_type numElements,
8882 ALLOCATOR allocator,
8884{
8887 BSLS_ASSERT_SAFE(first || 0 == numElements);
8889 BSLS_ASSERT_SAFE(lastPtr);
8890
8891 // Functionally indistinguishable from this:
8892
8893 *lastPtr = last;
8894 insert(toBegin, toEnd, first, last, numElements, allocator,
8896 *lastPtr = first;
8897}
8898
8899template <class TARGET_TYPE, class ALLOCATOR>
8900inline
8902 TARGET_TYPE *toBegin,
8903 TARGET_TYPE *toEnd,
8904 TARGET_TYPE **lastPtr,
8905 TARGET_TYPE *first,
8906 TARGET_TYPE *last,
8907 size_type numElements,
8908 ALLOCATOR allocator,
8910{
8913 BSLS_ASSERT_SAFE(first || 0 == numElements);
8915 BSLS_ASSERT_SAFE(lastPtr);
8916
8917 // There isn't any advantage at destroying [first,last) one by one as we're
8918 // moving it, except perhaps for slightly better memory usage.
8919
8920 *lastPtr = last;
8921 insert(toBegin, toEnd, first, last, numElements, allocator,
8923 ArrayDestructionPrimitives::destroy(first, last, allocator);
8924 *lastPtr = first;
8925}
8926
8927 // *** 'rotate' overloads: ***
8928
8929template <class TARGET_TYPE>
8930inline
8932 TARGET_TYPE *begin,
8933 TARGET_TYPE *middle,
8934 TARGET_TYPE *end,
8936{
8939
8940 bitwiseRotate(reinterpret_cast<char *>(begin),
8941 reinterpret_cast<char *>(middle),
8942 reinterpret_cast<char *>(end));
8943}
8944
8945template <class TARGET_TYPE>
8947 TARGET_TYPE *begin,
8948 TARGET_TYPE *middle,
8949 TARGET_TYPE *end,
8951{
8954
8955 if (begin == middle || middle == end) {
8956 // This test changes into O(1) what would otherwise be O(N): Do not
8957 // remove!
8958
8959 return; // RETURN
8960 }
8961
8962 // This case is simple enough, it should be taken care of on its own.
8963
8964 const std::size_t numElements = middle - begin;
8965 const std::size_t remElements = end - middle;
8966
8967 if (numElements == remElements) {
8968 for (; middle != end; ++begin, ++middle) {
8969 TARGET_TYPE tmp(*middle);
8970 *middle = *begin;
8971 *begin = tmp;
8972 }
8973 return; // RETURN
8974 }
8975
8976 // This algorithm proceeds by decomposing the rotation into cycles, which
8977 // can then be rotated using a single element buffer. First we compute the
8978 // 'gcd(end - begin, numElements)' which is the number of cycles in the
8979 // rotation.
8980
8981 std::size_t numCycles = end - begin;
8982 std::size_t remainder = numElements;
8983 while (remainder != 0) {
8984 std::size_t t = numCycles % remainder;
8985 numCycles = remainder;
8986 remainder = t;
8987 }
8988
8989 // Key to the transformation diagrams:
8990 //..
8991 // A...D Contents of the current cycle
8992 // W...Z Contents of another cycle
8993 // _ Elements not in the current cycle
8994 //..
8995
8996 for (std::size_t i = 0; i < numCycles; ++i) {
8997 // Let the current cycle be initially 'A__B__C__D__', (note that its
8998 // stride is 'length / numCycles') and let (*) denote the current
8999 // position of 'ptr'.
9000
9001 TARGET_TYPE *ptr = begin; // seed for current cycle: A(*)__B__C__D__
9002 TARGET_TYPE tmp = *ptr; // value held at the seed: tmp == A
9003
9004 if (numElements < remElements) {
9005 // Rotate the cycle forward by numElements positions (or backward
9006 // by -(length-numElements)=-remElements positions if crossing the
9007 // boundary forward). The transformation is:
9008 //..
9009 // A(*)__B__C__D__ => B__B(*)__C__D__
9010 // => B__C__C(*)__D__
9011 // => B__C__D__D(*)__
9012 //..
9013 // The length of the cycle is always 'length / numCycles', but it
9014 // crosses the range boundaries 'numElements / numCycles' times,
9015 // each triggering an extra assignment in the 'if' clause below, so
9016 // the loop must only be executed:
9017 //..
9018 // (length - numElements) / numCycles = remElements / numCycles
9019 //..
9020 // times.
9021
9022 std::size_t cycleSize = remElements / numCycles;
9023
9024 for (std::size_t j = 0; j < cycleSize; ++j) {
9025 if (ptr > begin + remElements) {
9026 // Wrap around the range boundaries. (Note that
9027 // '-remElements == numElements - (end - begin)'.)
9028
9029 *ptr = *(ptr - remElements);
9030 ptr -= remElements;
9031 }
9032
9033 *ptr = *(ptr + numElements);
9034 ptr += numElements;
9035 }
9036 }
9037 else {
9038 // Rotate the cycle backward by '-remElements' positions (or
9039 // forward by 'numElements' positions if crossing the boundary
9040 // backward). The transformation is:
9041 //..
9042 // A(*)__B__C__D__ => D__B__C__D(*)__
9043 // => D__B__C(*)__C__
9044 // => D__B(*)__B__C__
9045 //..
9046 // The length of the cycle is always 'length/numCycles', but going
9047 // backward (which adds an initial extra crossing) crosses the
9048 // range boundaries 'remElements/numCycles+1' times each of which
9049 // trigger an extra assignment in the 'if' clause below, so the
9050 // loop must only be executed:
9051 //..
9052 // (length - remElements) / numCycles - 1 =
9053 // numElements / numCycles - 1
9054 //..
9055 // times.
9056
9057 std::size_t cycleSize = numElements / numCycles - 1;
9058
9059 for (std::size_t j = 0; j < cycleSize; ++j) {
9060 if (ptr < end - numElements) {
9061 *ptr = *(ptr + numElements);
9062 ptr += numElements;
9063 }
9064
9065 *ptr = *(ptr - remElements);
9066 ptr -= remElements;
9067 }
9068 }
9069
9070 *ptr = tmp; // Close the cycle, e.g.:
9071 //..
9072 // (first case): B__C__D__D(*)__ => B__C__D__A__
9073 // (second case): D__D(*)__B__C__ => D__A__B__C__
9074 //..
9075 ++begin; // and move on to the next cycle:
9076 //..
9077 // => _W__X__Y__Z_
9078 //..
9079 }
9080}
9081
9082 // *** 'shiftAndInsert' overloads: ***
9083
9084template <class ALLOCATOR>
9085inline
9091 ALLOCATOR allocator,
9093{
9094 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9095
9096 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9097
9098 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9099 // then moving the array first might introduce a change in 'value'.
9100 // Fortunately we can easily predict its new position after the shift.
9101
9102 ValueType *valuePtr =
9104 if (begin <= valuePtr && valuePtr < end) {
9105 valuePtr += 1; // new address after the shift
9106 }
9107
9108#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9109// clang does not support this pragma
9110#pragma GCC diagnostic push
9111#pragma GCC diagnostic ignored "-Wclass-memaccess"
9112#endif
9113
9114 // shift
9115 std::memmove(begin + 1, begin, (end - begin) * sizeof(ValueType));
9116
9117 // insert
9119 allocator,
9120 begin,
9122
9123#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9124#pragma GCC diagnostic pop
9125#endif
9126}
9127
9128template <class ALLOCATOR>
9129inline
9135 ALLOCATOR allocator,
9137{
9138 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9139
9140 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9141
9142 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9143 // then moving the array first might introduce a change in 'value'.
9144 // Fortunately we can easily predict its new position after the shift.
9145
9146 ValueType *valuePtr =
9148 if (begin <= valuePtr && valuePtr < end) {
9149 valuePtr += 1; // new address after the shift
9150 }
9151
9152 // shift
9153 size_t bytesNum = (end - begin) * sizeof(ValueType);
9154
9155
9156#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9157// clang does not support this pragma
9158#pragma GCC diagnostic push
9159#pragma GCC diagnostic ignored "-Wclass-memaccess"
9160#endif
9161
9162 std::memmove(begin + 1, begin, bytesNum);
9163
9164
9165 /// Moves the elements back if `construct` throws.
9166 ///
9167 /// See @ref bslalg_arrayprimitives_cpp03
9168 class ElementsProctor {
9169
9170 // DATA
9171 ValueType *d_begin;
9172 size_t d_bytesNum;
9173 public:
9174 // CREATORS
9175 ElementsProctor(ValueType *p, size_t n) : d_begin(p), d_bytesNum(n) {}
9176 ~ElementsProctor()
9177 {
9178 if(d_bytesNum) std::memmove(d_begin, d_begin + 1, d_bytesNum);
9179 }
9180 // MANIPULATORS
9181 void release() { d_bytesNum = 0; }
9182 } proctor(begin, bytesNum);
9183
9184
9185 // insert
9187 allocator,
9188 begin,
9190 proctor.release();
9191#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9192#pragma GCC diagnostic pop
9193#endif
9194}
9195
9196template <class ALLOCATOR>
9197inline
9203 ALLOCATOR allocator,
9205{
9206 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9207
9208 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9209
9210 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9211 // then moving the array first might introduce a change in 'value'.
9212 // Fortunately we can easily predict its new position after the shift.
9213
9214 ValueType *valuePtr =
9216 if (begin <= valuePtr && valuePtr < end) {
9217 valuePtr += 1; // new address after the shift
9218 }
9219
9220 // Key to the transformation diagrams:
9221 //..
9222 // A...G original contents of '[toBegin, toEnd)' ("tail")
9223 // a...g moved-from or copied values
9224 // v moved 'value' ("input")
9225 // _____ uninitialized array elements
9226 // [...] part of array protected by an exception guard object
9227 //..
9228
9229 //..
9230 // Transformation: ABCDEFG_[] => ABCDEFg[G].
9231 //..
9232
9234 allocator,
9235 end,
9237
9239 end, end + 1, allocator);
9240
9241 //..
9242 // Transformation: ABCDEFg[G] => aABCDEF[G].
9243 //..
9244
9245 ValueType *dst = end;
9246 ValueType *src = end - 1;
9247 while (src != begin) {
9249 }
9250
9251 //..
9252 // Transformation: aABCDEFG[G] => vABCDEF[G].
9253 //..
9254
9256
9257 guard.release();
9258}
9259
9260} // close package namespace
9261
9262#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
9263// ============================================================================
9264// BACKWARD COMPATIBILITY
9265// ============================================================================
9266
9267/// This alias is defined for backward compatibility.
9269#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
9270
9271
9272
9273#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
9274# undef BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER
9275#endif
9276
9277#else // if ! defined(DEFINED_BSLALG_ARRAYPRIMITIVES_H)
9278# error Not valid except when included from bslalg_arrayprimitives.h
9279#endif // ! defined(COMPILING_BSLALG_ARRAYPRIMITIVES_H)
9280
9281#endif // ! defined(INCLUDED_BSLALG_ARRAYPRIMITIVES_CPP03)
9282
9283// ----------------------------------------------------------------------------
9284// Copyright 2013 Bloomberg Finance L.P.
9285//
9286// Licensed under the Apache License, Version 2.0 (the "License");
9287// you may not use this file except in compliance with the License.
9288// You may obtain a copy of the License at
9289//
9290// http://www.apache.org/licenses/LICENSE-2.0
9291//
9292// Unless required by applicable law or agreed to in writing, software
9293// distributed under the License is distributed on an "AS IS" BASIS,
9294// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9295// See the License for the specific language governing permissions and
9296// limitations under the License.
9297// ----------------------------- END-OF-FILE ----------------------------------
9298
9299/** @} */
9300/** @} */
9301/** @} */
Definition bslalg_autoarraydestructor.h:232
Definition bslma_allocator.h:457
Definition bslma_destructorproctor.h:259
Definition bslmf_movableref.h:751
bslalg::ArrayPrimitives bslalg_ArrayPrimitives
This alias is defined for backward compatibility.
Definition bslalg_arrayprimitives.h:4993
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#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_PERFORMANCEHINT_PREDICT_LIKELY(expr)
Definition bsls_performancehint.h:451
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:289
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
Definition bdlc_flathashmap.h:1805
Definition balxml_encoderoptions.h:68
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1472
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR_TYPE >::type pointer
Definition bslma_allocatortraits.h:1149
ALLOCATOR_TYPE::value_type value_type
Definition bslma_allocatortraits.h:1145
Definition bslmf_integralconstant.h:244
Definition bslmf_isenum.h:270
Definition bslmf_isfundamental.h:329
Definition bslmf_ismemberpointer.h:143
Definition bslmf_ispointer.h:138
Definition bslmf_issame.h:146
Definition bslmf_istriviallydefaultconstructible.h:293
Definition bslmf_isvoid.h:138
Definition bslmf_removecv.h:118
Definition bslmf_removepointer.h:255
BloombergLP::bslmf::RemovePointer_Imp< t_TYPE >::Type type
Definition bslmf_removepointer.h:267
static void destroy(TARGET_TYPE *begin, TARGET_TYPE *end, ALLOCATOR allocator, bsl::true_type)
Definition bslalg_arraydestructionprimitives.h:232
static void emplace(TARGET_TYPE *toBegin, TARGET_TYPE *toEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_COPYABLE_TRAITS >, ARGS &&... args)
TBD: document this.
Definition bslalg_arrayprimitives.h:3698
static void moveConstruct(TARGET_TYPE *toBegin, TARGET_TYPE *fromBegin, TARGET_TYPE *fromEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_COPYABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:3520
static bool isInvalidRange(FORWARD_ITERATOR begin, FORWARD_ITERATOR end)
Definition bslalg_arrayprimitives.h:3027
static void bitwiseRotateBackward(char *begin, char *middle, char *end)
static void bitwiseRotate(char *begin, char *middle, char *end)
@ e_BITWISE_MOVEABLE_TRAITS
Definition bslalg_arrayprimitives.h:1260
@ e_HAS_TRIVIAL_DEFAULT_CTOR_TRAITS
Definition bslalg_arrayprimitives.h:1258
@ e_NIL_TRAITS
Definition bslalg_arrayprimitives.h:1261
@ e_BITWISE_COPYABLE_TRAITS
Definition bslalg_arrayprimitives.h:1259
@ e_IS_FUNDAMENTAL_OR_POINTER
Definition bslalg_arrayprimitives.h:1257
@ e_IS_ITERATOR_TO_FUNCTION_POINTER
Definition bslalg_arrayprimitives.h:1255
@ e_IS_POINTER_TO_POINTER
Definition bslalg_arrayprimitives.h:1256
static void shiftAndInsert(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, typename bsl::allocator_traits< ALLOCATOR >::pointer end, bslmf::MovableRef< typename bsl::allocator_traits< ALLOCATOR >::value_type > value, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_COPYABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:4811
static void bitwiseFillN(char *begin, size_type numBytesInitialized, size_type numBytes)
static void bitwiseSwapRanges(char *begin, char *middle, char *end)
static void uninitializedFillN(bool *begin, bool value, size_type numElements, void *=0, bsl::integral_constant< int, e_IS_FUNDAMENTAL_OR_POINTER >=bsl::integral_constant< int, e_IS_FUNDAMENTAL_OR_POINTER >())
Definition bslalg_arrayprimitives.h:3064
static void moveInsert(TARGET_TYPE *toBegin, TARGET_TYPE *toEnd, TARGET_TYPE **lastPtr, TARGET_TYPE *first, TARGET_TYPE *last, size_type numElements, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_MOVEABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:4600
static void moveIfNoexcept(TARGET_TYPE *toBegin, TARGET_TYPE *fromBegin, TARGET_TYPE *fromEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_NIL_TRAITS >)
Definition bslalg_arrayprimitives.h:3565
ArrayPrimitives::difference_type difference_type
Definition bslalg_arrayprimitives.h:1247
static void bitwiseRotateForward(char *begin, char *middle, char *end)
static void copyConstruct(TARGET_TYPE *toBegin, FWD_ITER fromBegin, FWD_ITER fromEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_IS_POINTER_TO_POINTER >)
Definition bslalg_arrayprimitives.h:3407
ArrayPrimitives::size_type size_type
Definition bslalg_arrayprimitives.h:1246
static void destructiveMove(TARGET_TYPE *toBegin, TARGET_TYPE *fromBegin, TARGET_TYPE *fromEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_MOVEABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:3654
@ k_INPLACE_BUFFER_SIZE
Definition bslalg_arrayprimitives.h:1268
static void erase(TARGET_TYPE *first, TARGET_TYPE *middle, TARGET_TYPE *last, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_MOVEABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:3883
static void rotate(TARGET_TYPE *begin, TARGET_TYPE *middle, TARGET_TYPE *end, bsl::integral_constant< int, e_BITWISE_MOVEABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:4656
static void insert(TARGET_TYPE *toBegin, TARGET_TYPE *toEnd, const TARGET_TYPE &value, size_type numElements, ALLOCATOR allocator, bsl::integral_constant< int, e_BITWISE_COPYABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:3952
static void defaultConstruct(TARGET_TYPE *begin, size_type numElements, ALLOCATOR allocator, bsl::integral_constant< int, e_HAS_TRIVIAL_DEFAULT_CTOR_TRAITS >)
Definition bslalg_arrayprimitives.h:3595
Definition bslalg_arrayprimitives.h:418
static void destructiveMoveAndMoveInsert(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer *fromEndPtr, typename bsl::allocator_traits< ALLOCATOR >::pointer *lastPtr, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer position, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, typename bsl::allocator_traits< ALLOCATOR >::pointer first, typename bsl::allocator_traits< ALLOCATOR >::pointer last, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2488
static void copyConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, FWD_ITER fromBegin, FWD_ITER fromEnd, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:1959
static void destructiveMoveAndEmplace(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer *fromEndPtr, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer position, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, ALLOCATOR allocator, ARGS &&... arguments)
Definition bslalg_arrayprimitives.h:2146
ArrayPrimitives_Imp Imp
Definition bslalg_arrayprimitives.h:422
static void insert(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer toEnd, bslmf::MovableRef< typename bsl::allocator_traits< ALLOCATOR >::value_type > value, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2680
static void destructiveMove(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2107
static void defaultConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2064
static void moveInsert(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer toEnd, typename bsl::allocator_traits< ALLOCATOR >::pointer *fromEndPtr, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2942
static void emplace(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer toEnd, ALLOCATOR allocator, ARGS &&... arguments)
Definition bslalg_arrayprimitives.h:2591
static void moveConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2904
static void destructiveMoveAndInsert(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer *fromEndPtr, typename bsl::allocator_traits< ALLOCATOR >::pointer fromBegin, typename bsl::allocator_traits< ALLOCATOR >::pointer position, typename bsl::allocator_traits< ALLOCATOR >::pointer fromEnd, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2217
std::ptrdiff_t difference_type
Definition bslalg_arrayprimitives.h:424
static void erase(typename bsl::allocator_traits< ALLOCATOR >::pointer first, typename bsl::allocator_traits< ALLOCATOR >::pointer middle, typename bsl::allocator_traits< ALLOCATOR >::pointer last, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2637
static void uninitializedFillN(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, const typename bsl::allocator_traits< ALLOCATOR >::value_type &value, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:1905
std::size_t size_type
Definition bslalg_arrayprimitives.h:423
static void rotate(TARGET_TYPE *first, TARGET_TYPE *middle, TARGET_TYPE *last)
Definition bslalg_arrayprimitives.h:2989
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1243
static Allocator * allocator(Allocator *basicAllocator=0)
Definition bslma_default.h:897
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_functionpointertraits.h:153
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1060
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1032
static bsl::enable_if<!bsl::is_nothrow_move_constructible< t_TYPE >::value &&bsl::is_copy_constructible< t_TYPE >::value, constt_TYPE & >::type move_if_noexcept(t_TYPE &lvalue) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:915
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:275
unsigned long long Uint64
Definition bsls_types.h:137
long long Int64
Definition bsls_types.h:132
Definition bsls_objectbuffer.h:276
TYPE & object()
Definition bsls_objectbuffer.h:351