BDE 4.39.x 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 Tue Feb 3 18:41:11 2026
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.
88///
89/// See @ref bslalg_arrayprimitives_cpp03
90struct ArrayPrimitives {
91
92 public:
93 // TYPES
94 typedef ArrayPrimitives_Imp Imp;
95 typedef std::size_t size_type;
96 typedef std::ptrdiff_t difference_type;
97
98 // CLASS METHODS
99
100 /// Copy the elements of type `allocator_traits<ALLOCATOR>::value_type`
101 /// in the range beginning at the specified `fromBegin` location and
102 /// ending immediately before the specified `fromEnd` location into the
103 /// uninitialized array beginning at the specified `toBegin` location,
104 /// using the specified `allocator` to supply memory (if required). If
105 /// a constructor throws an exception during this operation, the output
106 /// array is left in an uninitialized state.
107 ///
108 /// \pre The behavior is undefined unless `toBegin` refers to space sufficient to hold
109 /// `fromEnd - fromBegin` elements.
110 template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
111 static void
114 FWD_ITER fromBegin,
115 SENTINEL fromEnd,
116 ALLOCATOR allocator);
117 template <class ALLOCATOR, class SOURCE_TYPE>
118 static void
121 SOURCE_TYPE *fromBegin,
122 SOURCE_TYPE *fromEnd,
123 ALLOCATOR allocator);
124
125 /// Copy into an uninitialized array of (the template parameter)
126 /// `TARGET_TYPE` beginning at the specified `toBegin` address, the
127 /// elements in the array of `TARGET_TYPE` starting at the specified
128 /// `fromBegin` address and ending immediately before the specified
129 /// `fromEnd` address. If the (template parameter) `ALLOCATOR` type is
130 /// derived from `bslma::Allocator` and `TARGET_TYPE` supports `bslma`
131 /// allocators, then the specified `allocator` is passed to each
132 /// invocation of the `TARGET_TYPE` copy constructor. If a
133 /// `TARGET_TYPE` constructor throws an exception during the operation,
134 /// then the destructor is called on any newly-constructed elements,
135 /// leaving the output array in an uninitialized state.
136 template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
137 static void copyConstruct(TARGET_TYPE *toBegin,
138 FWD_ITER fromBegin,
139 SENTINEL fromEnd,
140 bslma::Allocator *allocator);
141 template <class TARGET_TYPE, class SOURCE_TYPE>
142 static void copyConstruct(TARGET_TYPE *toBegin,
143 SOURCE_TYPE *fromBegin,
144 SOURCE_TYPE *fromEnd,
145 bslma::Allocator *allocator);
146
147 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
148 /// in the range beginning at the specified `fromBegin` location and
149 /// ending immediately before the specified `fromEnd` location into the
150 /// uninitialized array beginning at the specified `toBegin` location,
151 /// using the specified `allocator` to supply memory (if required). The
152 /// elements in the input array are left in a valid but unspecified
153 /// state. If a constructor throws an exception during this operation,
154 /// the output array is left in an uninitialized state.
155 ///
156 /// \pre The behavior is undefined unless `toBegin` refers to space sufficient to hold
157 /// `fromEnd - fromBegin` elements.
158 template <class ALLOCATOR>
159 static void
164 ALLOCATOR allocator);
165
166 /// Move the elements of the (template parameter) `TARGET_TYPE` starting
167 /// at the specified `fromBegin` address and ending immediately before
168 /// the specified `fromEnd` address into the uninitialized array of
169 /// `TARGET_TYPE` beginning at the specified `toBegin` address, using
170 /// the specified `allocator` to supply memory (if required). The
171 /// elements in the input array are left in a valid but unspecified
172 /// state. If a constructor throws an exception during this operation,
173 /// the output array is left in an uninitialized state.
174 ///
175 /// \pre The behavior is undefined unless `toBegin` refers to space sufficient to hold
176 /// `fromEnd - fromBegin` elements.
177 template <class TARGET_TYPE>
178 static void moveConstruct(TARGET_TYPE *toBegin,
179 TARGET_TYPE *fromBegin,
180 TARGET_TYPE *fromEnd,
181 bslma::Allocator *allocator);
182
183 /// Value-inititalize the specified `numElements` objects of type
184 /// `allocator_traits<ALLOCATOR>::value_type` into the uninitialized
185 /// array beginning at the specified `begin` location, using the
186 /// specified `allocator` to supply memory (if required). If a
187 /// constructor throws an exception during this operation, then the
188 /// destructor is called on any newly constructed elements, leaving the
189 /// output array in an uninitialized state.
190 ///
191 /// \pre The behavior is undefined unless the `begin` refers to space sufficient to hold `numElements`.
192 template <class ALLOCATOR>
193 static void defaultConstruct(
195 size_type numElements,
196 ALLOCATOR allocator);
197
198 /// Construct each of the elements of an array of the specified
199 /// `numElements` of the parameterized `TARGET_TYPE` starting at the
200 /// specified `begin` address by value-initialization. If the (template
201 /// parameter) `ALLOCATOR` type is derived from `bslma::Allocator` and
202 /// `TARGET_TYPE` supports `bslma` allocators, then the specified
203 /// `allocator` is passed to each `TARGET_TYPE` default constructor call.
204 ///
205 /// \pre The behavior is undefined unless the output array contains at
206 /// least `numElements` uninitialized elements after `begin`. If a
207 /// `TARGET_TYPE` constructor throws an exception during this operation,
208 /// then the destructor is called on any newly-constructed elements,
209 /// leaving the output array in an uninitialized state.
210 template <class TARGET_TYPE>
211 static void defaultConstruct(TARGET_TYPE *begin,
212 size_type numElements,
213 bslma::Allocator *allocator);
214
215 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
216 /// in the range beginning at the specified `fromBegin` location and
217 /// ending immediately before the specified `fromEnd` location into the
218 /// uninitialized array beginning at the specified `toBegin` location,
219 /// using the specified `allocator` to supply memory (if required). On
220 /// return, the elements in the input range are invalid, i.e., their
221 /// destructors must not be called after this operation returns. If a
222 /// constructor throws an exception during this operation, the output
223 /// array is left in an uninitialized state. If a constructor other
224 /// than the move constructor of a non-copy-constructible type throws
225 /// an exception during this operation, the input array is unaffected;
226 /// otherwise, if the move constructor of a non-copy-constructible type
227 /// throws an exception during this operation, the input array is left in a valid but unspecified state.
228 ///
229 /// \pre The behavior is undefined unless
230 /// `toBegin` refers to space sufficient to hold `fromEnd - fromBegin`
231 /// elements.
232 template <class ALLOCATOR>
233 static void destructiveMove(
237 ALLOCATOR allocator);
238
239 /// Move the elements of the parameterized `TARGET_TYPE` in the array
240 /// starting at the specified `fromBegin` address and ending immediately
241 /// before the specified `fromEnd` address into an uninitialized array
242 /// of `TARGET_TYPE` beginning at the specified `toBegin` address. On
243 /// return, the elements in the input range are invalid, i.e., their
244 /// destructors must not be called after this operation returns. If the
245 /// parameterized `ALLOCATOR` type is derived from `bslma::Allocator`
246 /// and `TARGET_TYPE` supports `bslma` allocators, then the specified
247 /// `allocator` is used by the objects in their new location. If an
248 /// exception is thrown by a `TARGET_TYPE` constructor during the
249 /// operation, then the output array is left in an uninitialized state
250 /// and the input elements remain in their original state.
251 template <class TARGET_TYPE>
252 static void destructiveMove(TARGET_TYPE *toBegin,
253 TARGET_TYPE *fromBegin,
254 TARGET_TYPE *fromEnd,
255 bslma::Allocator *allocator);
256
257#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
258// {{{ BEGIN GENERATED CODE
259// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
260#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
261#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
262#endif
263#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A
264#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
265#endif
266
267#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 0
268 template <class ALLOCATOR>
269 static void destructiveMoveAndEmplace(
275 ALLOCATOR allocator);
276#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 0
277
278#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 1
279 template <class ALLOCATOR, class ARGS_01>
280 static void destructiveMoveAndEmplace(
286 ALLOCATOR allocator,
287 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01);
288#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 1
289
290#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 2
291 template <class ALLOCATOR, class ARGS_01,
292 class ARGS_02>
293 static void destructiveMoveAndEmplace(
299 ALLOCATOR allocator,
300 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
301 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02);
302#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 2
303
304#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 3
305 template <class ALLOCATOR, class ARGS_01,
306 class ARGS_02,
307 class ARGS_03>
308 static void destructiveMoveAndEmplace(
314 ALLOCATOR allocator,
315 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
316 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
317 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03);
318#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 3
319
320#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 4
321 template <class ALLOCATOR, class ARGS_01,
322 class ARGS_02,
323 class ARGS_03,
324 class ARGS_04>
325 static void destructiveMoveAndEmplace(
331 ALLOCATOR allocator,
332 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
333 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
334 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
335 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04);
336#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 4
337
338#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 5
339 template <class ALLOCATOR, class ARGS_01,
340 class ARGS_02,
341 class ARGS_03,
342 class ARGS_04,
343 class ARGS_05>
344 static void destructiveMoveAndEmplace(
350 ALLOCATOR allocator,
351 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
355 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05);
356#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 5
357
358#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 6
359 template <class ALLOCATOR, class ARGS_01,
360 class ARGS_02,
361 class ARGS_03,
362 class ARGS_04,
363 class ARGS_05,
364 class ARGS_06>
365 static void destructiveMoveAndEmplace(
371 ALLOCATOR allocator,
372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
374 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
375 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
376 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
377 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06);
378#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 6
379
380#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 7
381 template <class ALLOCATOR, class ARGS_01,
382 class ARGS_02,
383 class ARGS_03,
384 class ARGS_04,
385 class ARGS_05,
386 class ARGS_06,
387 class ARGS_07>
388 static void destructiveMoveAndEmplace(
394 ALLOCATOR allocator,
395 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
396 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
397 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
398 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
401 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07);
402#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 7
403
404#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 8
405 template <class ALLOCATOR, class ARGS_01,
406 class ARGS_02,
407 class ARGS_03,
408 class ARGS_04,
409 class ARGS_05,
410 class ARGS_06,
411 class ARGS_07,
412 class ARGS_08>
413 static void destructiveMoveAndEmplace(
419 ALLOCATOR allocator,
420 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
421 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
422 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
423 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
424 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
425 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
426 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
427 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08);
428#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 8
429
430#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 9
431 template <class ALLOCATOR, class ARGS_01,
432 class ARGS_02,
433 class ARGS_03,
434 class ARGS_04,
435 class ARGS_05,
436 class ARGS_06,
437 class ARGS_07,
438 class ARGS_08,
439 class ARGS_09>
440 static void destructiveMoveAndEmplace(
446 ALLOCATOR allocator,
447 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
448 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
449 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
450 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
451 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
452 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
453 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
454 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
455 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09);
456#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 9
457
458#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 10
459 template <class ALLOCATOR, class ARGS_01,
460 class ARGS_02,
461 class ARGS_03,
462 class ARGS_04,
463 class ARGS_05,
464 class ARGS_06,
465 class ARGS_07,
466 class ARGS_08,
467 class ARGS_09,
468 class ARGS_10>
469 static void destructiveMoveAndEmplace(
475 ALLOCATOR allocator,
476 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
477 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
478 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
479 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
480 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
481 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
482 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
483 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
485 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10);
486#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_A >= 10
487
488#else
489// The generated code below is a workaround for the absence of perfect
490// forwarding in some compilers.
491
492 template <class ALLOCATOR, class... ARGS>
493 static void destructiveMoveAndEmplace(
499 ALLOCATOR allocator,
500 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments);
501
502// }}} END GENERATED CODE
503#endif
504
505 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
506 /// in the range beginning at the specified `fromBegin` location and
507 /// ending immediately before the specified `fromEnd` location into the
508 /// uninitialized array beginning at the specified `toBegin` location
509 /// using the specified `allocator` to supply memory (if required),
510 /// inserting at the specified `position` (after translating from
511 /// `fromBegin` to `toBegin`) the specified `numElements` objects
512 /// initialized to default values, ensuring that the specified
513 /// `fromEndPtr` points to the first uninitialized element in
514 /// `[fromBegin .. fromEnd)` as the elements are moved from source to
515 /// destination. On return, the elements in the input range are
516 /// invalid, i.e., their destructors must not be called after this
517 /// operation returns. If a constructor throws an exception during this
518 /// operation, the output array is left in an uninitialized state. If a
519 /// default constructor throws an exception, the input array is
520 /// unaffected; otherwise, if a (copy or move) constructor throws an
521 /// exception during this operation, the input elements in the range
522 /// `[fromBegin .. *fromEndPtr)` are left in a valid but unspecified
523 /// state and the remaining portion of the input array is left in an uninitialized state.
524 ///
525 /// \pre The behavior is undefined unless 'fromBegin <=
526 /// position <= fromEnd' and `toBegin` refers to space sufficient to
527 /// hold `fromEnd - fromBegin + 1` elements.
528 template <class ALLOCATOR>
529 static void destructiveMoveAndInsert(
535 size_type numElements,
536 ALLOCATOR allocator);
537
538 /// Move the elements of the (template parameter) `TARGET_TYPE` in the
539 /// starting at the specified `fromBegin` address and ending immediately
540 /// before the specified `fromEnd` address into the uninitialized array
541 /// beginning at the specified `toBegin` location using the specified
542 /// `allocator` to supply memory (if required), inserting at the
543 /// specified `position` (after translating from `fromBegin` to
544 /// `toBegin`) `numElements` objects initialized to default values,
545 /// ensuring that the specified `fromEndPtr` points to the first
546 /// uninitialized element in `[fromBegin .. fromEnd)` as the elements
547 /// are moved from source to destination. On return, the elements in
548 /// the input range are invalid, i.e., their destructors must not be
549 /// called after this operation returns. If a constructor throws an
550 /// exception during this operation, the output array is left in an
551 /// uninitialized state. If a default constructor throws an exception,
552 /// the input array is unaffected; otherwise, if a (copy or move)
553 /// constructor throws an exception during this operation, the input
554 /// elements in the range `[fromBegin .. *fromEndPtr)` are left in a
555 /// valid but unspecified state and the remaining portion of the input
556 /// array is left in an uninitialized state.
557 ///
558 /// \pre The behavior is undefined unless `fromBegin <= position <= fromEnd` and `toBegin` refers to
559 /// space sufficient to hold `fromEnd - fromBegin + numElements`
560 /// elements.
561 template <class TARGET_TYPE>
562 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
563 TARGET_TYPE **fromEndPtr,
564 TARGET_TYPE *fromBegin,
565 TARGET_TYPE *position,
566 TARGET_TYPE *fromEnd,
567 size_type numElements,
568 bslma::Allocator *allocator);
569
570 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type`
571 /// in the range beginning at the specified `fromBegin` location and
572 /// ending immediately before the specified `fromEnd` location into the
573 /// uninitialized array beginning at the specified `toBegin` location
574 /// using the specified `allocator` to supply memory (if required),
575 /// inserting at the specified `position` (after translating from
576 /// `fromBegin` to `toBegin`) the specified `numElements` copies of the
577 /// specified `value`, ensuring that the specified `fromEndPtr` points
578 /// to the first uninitialized element in `[fromBegin .. fromEnd)` as
579 /// the elements are moved from source to destination. On return, the
580 /// elements in the input range are invalid, i.e., their destructors
581 /// must not be called after this operation returns. If a constructor
582 /// throws an exception during this operation, the output array is left
583 /// in an uninitialized state. If a (copy or move) constructor throws
584 /// an exception during this operation, the input elements in the range
585 /// `[fromBegin .. *fromEndPtr)` are left in a valid but unspecified
586 /// state and the remaining portion of the input array is left in an uninitialized state.
587 ///
588 /// \pre The behavior is undefined unless
589 /// `fromBegin <= position <= fromEnd` and `toBegin` refers to space
590 /// sufficient to hold `fromEnd - fromBegin + numElements` elements.
591 template <class ALLOCATOR>
592 static void destructiveMoveAndInsert(
599 size_type numElements,
600 ALLOCATOR allocator);
601
602 /// Move the elements of the parameterized `TARGET_TYPE` in the array
603 /// starting at the specified `fromBegin` address and ending immediately
604 /// before the specified `fromEnd` address into an uninitialized array
605 /// of `TARGET_TYPE` at the specified `toBegin` address, inserting at
606 /// the specified `position` (after translating from `fromBegin` to
607 /// `toBegin`) the specified `numElements` copies of the specified
608 /// `value`. Keep the pointer at the specified `fromEndPtr` address
609 /// pointing to the first uninitialized element in '[ fromBegin,
610 /// fromEnd)' as the elements are moved from source to destination.
611 ///
612 /// \pre The behavior is undefined unless `fromBegin <= position <= fromEnd` and
613 /// the destination array contains at least
614 /// `(fromEnd - fromBegin) + numElements` uninitialized elements. If a
615 /// copy constructor or assignment operator for `TARGET_TYPE` throws an
616 /// exception, then any elements created in the output array are
617 /// destroyed and the elements in the range `[ fromBegin, *fromEndPtr )`
618 /// will have unspecified but valid values.
619 template <class TARGET_TYPE>
620 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
621 TARGET_TYPE **fromEndPtr,
622 TARGET_TYPE *fromBegin,
623 TARGET_TYPE *position,
624 TARGET_TYPE *fromEnd,
625 const TARGET_TYPE& value,
626 size_type numElements,
627 bslma::Allocator *allocator);
628
629 /// Move the elements of type `allocator_traits<ALLOCATOR>::value_type` in
630 /// the range beginning at the specified `fromBegin` location and ending
631 /// immediately before the specified `fromEnd` location into the
632 /// uninitialized array beginning at the specified `toBegin` location using
633 /// the specified `allocator` to supply memory (if required), inserting at
634 /// the specified `position` (after translating from `fromBegin` to
635 /// `toBegin`) the specified `numElements` copies of the non-modifiable
636 /// elements from the range starting at the specified `first` iterator of
637 /// (template parameter) type `FWD_ITER` and ending immediately before the
638 /// specified `last` sentinel or iterator, ensuring that the specified
639 /// `fromEndPtr` points to the first uninitialized element in
640 /// `[fromBegin .. fromEnd)` as the elements are moved from source to
641 /// destination. On return, the elements in the input range are invalid,
642 /// i.e., their destructors must not be called after this operation
643 /// returns. If a constructor throws an exception during this operation,
644 /// the output array is left in an uninitialized state. If a constructor
645 /// other than the copy or move constructor throws an exception during this
646 /// operation, the input array is unaffected; otherwise, if a copy or move
647 /// constructor throws an exception during this operation, the input
648 /// elements in the range `[fromBegin .. *fromEndPtr)` are left in a valid
649 /// but unspecified state and the remaining portion of the input array is left in an uninitialized state.
650 ///
651 /// \pre The behavior is undefined unless
652 /// `fromBegin <= position <= fromEnd` and `toBegin` refers to space
653 /// sufficient to hold `fromEnd - fromBegin + numElements` elements.
654 template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
655 static void destructiveMoveAndInsert(
661 FWD_ITER first,
662 SENTINEL last,
663 size_type numElements,
664 ALLOCATOR allocator);
665
666 /// Move the elements of the parameterized `TARGET_TYPE` in the array
667 /// starting at the specified `fromBegin` address and ending immediately
668 /// before the specified `fromEnd` address into an uninitialized array of
669 /// `TARGET_TYPE` at the specified `toBegin` address, inserting at the
670 /// specified `position` (after translating from `fromBegin` to `toBegin`)
671 /// the specified `numElements` copies of the non-modifiable elements from
672 /// the range starting at the specified `first` iterator of the
673 /// parameterized `FWD_ITER` type and ending immediately before the
674 /// specified `last` sentinel or iterator. Keep the pointer at the
675 /// specified `fromEndPtr` to point to the first uninitialized element in
676 /// `[fromBegin, fromEnd)` as the elements are moved from source to destination.
677 ///
678 /// \pre The behavior is undefined unless
679 /// `fromBegin <= position <= fromEnd`, the destination array contains at
680 /// least `(fromEnd - fromBegin) + numElements` uninitialized elements
681 /// after `toBegin`, and `numElements` is the distance from `first` to
682 /// `last`. If a copy constructor or assignment operator for `TARGET_TYPE`
683 /// throws an exception, then any elements created in the output array are
684 /// destroyed and the elements in the range `[ fromBegin, *fromEndPtr )`
685 /// will have unspecified but valid values.
686 template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
687 static void destructiveMoveAndInsert(TARGET_TYPE *toBegin,
688 TARGET_TYPE **fromEndPtr,
689 TARGET_TYPE *fromBegin,
690 TARGET_TYPE *position,
691 TARGET_TYPE *fromEnd,
692 FWD_ITER first,
693 SENTINEL last,
694 size_type numElements,
695 bslma::Allocator *allocator);
696
697 /// TBD: improve comment
698 /// Move, into an uninitialized array beginning at the specified
699 /// `toBegin` pointer, elements of type given by the `allocator_traits`
700 /// class template for (template parameter) `ALLOCATOR`, from elements
701 /// starting at the specified `fromBegin` pointer and ending immediately
702 /// before the specified `fromEnd` address, moving into the specified
703 /// `position` (after translating from `fromBegin` to `toBegin`) the
704 /// specified `numElements` elements starting at the specified `first`
705 /// pointer and ending immediately before the specified `last` pointer.
706 /// Keep the pointer at the specified `fromEndPtr` address pointing to
707 /// the first uninitialized element in `[ fromBegin, fromEnd)` as the
708 /// elements are moved from source to destination.
709 ///
710 /// \pre The behavior is undefined unless `fromBegin <= position <= fromEnd` and the
711 /// destination array contains at least
712 /// `(fromEnd - fromBegin) + numElements` uninitialized elements. If a
713 /// constructor or assignment operator for the target type throws an
714 /// exception, then any elements created in the output array are
715 /// destroyed and the elements in the range `[ fromBegin, *fromEndPtr )`
716 /// will have valid but unspecified values.
717 template <class ALLOCATOR>
727 size_type numElements,
728 ALLOCATOR allocator);
729
730 /// Move the elements of (template parameter) `TARGET_TYPE` in the array
731 /// starting at the specified `fromBegin` address and ending immediately
732 /// before the specified `fromEnd` address into an uninitialized array
733 /// of `TARGET_TYPE` at the specified `toBegin` address, moving into the
734 /// specified `position` (after translating from `fromBegin` to
735 /// `toBegin`) the specified `numElements` of the `TARGET_TYPE` from the
736 /// array starting at the specified `first` address and ending
737 /// immediately before the specified `last` address. Keep the pointer
738 /// at the specified `fromEndPtr` address pointing to the first
739 /// uninitialized element in `[fromBegin, fromEnd)`, and the pointer at
740 /// the specified `lastPtr` address pointing to the end of the moved
741 /// range as the elements from the range `[ first, last)` are moved from source to destination.
742 ///
743 /// \pre The behavior is undefined unless
744 /// `fromBegin <= position <= fromEnd`, the destination array contains
745 /// at least `(fromEnd - fromBegin) + numElements` uninitialized
746 /// elements after `toBegin`, and `numElements` is the distance from
747 /// `first` to `last`. If a copy constructor or assignment operator for
748 /// `TARGET_TYPE` throws an exception, then any elements in
749 /// `[ *lastPtr, last )` as well as in `[ toBegin, ... )` are destroyed,
750 /// and the elements in the ranges `[ first, *lastPtr )` and
751 /// `[ fromBegin, *fromEndPtr )` will have unspecified but valid values.
752 template <class TARGET_TYPE>
753 static void destructiveMoveAndMoveInsert(TARGET_TYPE *toBegin,
754 TARGET_TYPE **fromEndPtr,
755 TARGET_TYPE **lastPtr,
756 TARGET_TYPE *fromBegin,
757 TARGET_TYPE *position,
758 TARGET_TYPE *fromEnd,
759 TARGET_TYPE *first,
760 TARGET_TYPE *last,
761 size_type numElements,
762 bslma::Allocator *allocator);
763
764#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
765// {{{ BEGIN GENERATED CODE
766// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
767#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
768#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
769#endif
770#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B
771#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
772#endif
773
774#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
775 template <class ALLOCATOR>
776 static void emplace(
779 ALLOCATOR allocator);
780#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
781
782#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
783 template <class ALLOCATOR, class ARGS_01>
784 static void emplace(
787 ALLOCATOR allocator,
788 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01);
789#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
790
791#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
792 template <class ALLOCATOR, class ARGS_01,
793 class ARGS_02>
794 static void emplace(
797 ALLOCATOR allocator,
798 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
799 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02);
800#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
801
802#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
803 template <class ALLOCATOR, class ARGS_01,
804 class ARGS_02,
805 class ARGS_03>
806 static void emplace(
809 ALLOCATOR allocator,
810 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
811 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
812 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03);
813#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
814
815#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
816 template <class ALLOCATOR, class ARGS_01,
817 class ARGS_02,
818 class ARGS_03,
819 class ARGS_04>
820 static void emplace(
823 ALLOCATOR allocator,
824 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
825 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
826 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
827 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04);
828#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
829
830#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
831 template <class ALLOCATOR, class ARGS_01,
832 class ARGS_02,
833 class ARGS_03,
834 class ARGS_04,
835 class ARGS_05>
836 static void emplace(
839 ALLOCATOR allocator,
840 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
841 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
842 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
843 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
844 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05);
845#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
846
847#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
848 template <class ALLOCATOR, class ARGS_01,
849 class ARGS_02,
850 class ARGS_03,
851 class ARGS_04,
852 class ARGS_05,
853 class ARGS_06>
854 static void emplace(
857 ALLOCATOR allocator,
858 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
859 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
860 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
862 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
863 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06);
864#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
865
866#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
867 template <class ALLOCATOR, class ARGS_01,
868 class ARGS_02,
869 class ARGS_03,
870 class ARGS_04,
871 class ARGS_05,
872 class ARGS_06,
873 class ARGS_07>
874 static void emplace(
877 ALLOCATOR allocator,
878 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
879 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
880 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
881 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
882 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
883 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
884 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07);
885#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
886
887#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
888 template <class ALLOCATOR, class ARGS_01,
889 class ARGS_02,
890 class ARGS_03,
891 class ARGS_04,
892 class ARGS_05,
893 class ARGS_06,
894 class ARGS_07,
895 class ARGS_08>
896 static void emplace(
899 ALLOCATOR allocator,
900 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
901 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
902 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
903 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
904 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
905 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
906 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
907 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08);
908#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
909
910#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
911 template <class ALLOCATOR, class ARGS_01,
912 class ARGS_02,
913 class ARGS_03,
914 class ARGS_04,
915 class ARGS_05,
916 class ARGS_06,
917 class ARGS_07,
918 class ARGS_08,
919 class ARGS_09>
920 static void emplace(
923 ALLOCATOR allocator,
924 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
925 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
926 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
927 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
928 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
929 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
930 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
931 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
932 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09);
933#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
934
935#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
936 template <class ALLOCATOR, class ARGS_01,
937 class ARGS_02,
938 class ARGS_03,
939 class ARGS_04,
940 class ARGS_05,
941 class ARGS_06,
942 class ARGS_07,
943 class ARGS_08,
944 class ARGS_09,
945 class ARGS_10>
946 static void emplace(
949 ALLOCATOR allocator,
950 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
951 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
952 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
953 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
954 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
955 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
956 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
957 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
958 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
959 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10);
960#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
961
962
963#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
964 template <class TARGET_TYPE>
965 static void emplace(TARGET_TYPE *toBegin,
966 TARGET_TYPE *toEnd,
967 bslma::Allocator *allocator);
968#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 0
969
970#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
971 template <class TARGET_TYPE, class ARGS_01>
972 static void emplace(TARGET_TYPE *toBegin,
973 TARGET_TYPE *toEnd,
974 bslma::Allocator *allocator,
975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01);
976#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 1
977
978#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
979 template <class TARGET_TYPE, class ARGS_01,
980 class ARGS_02>
981 static void emplace(TARGET_TYPE *toBegin,
982 TARGET_TYPE *toEnd,
983 bslma::Allocator *allocator,
984 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
985 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
986#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 2
987
988#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
989 template <class TARGET_TYPE, class ARGS_01,
990 class ARGS_02,
991 class ARGS_03>
992 static void emplace(TARGET_TYPE *toBegin,
993 TARGET_TYPE *toEnd,
994 bslma::Allocator *allocator,
995 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
996 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
997 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
998#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 3
999
1000#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
1001 template <class TARGET_TYPE, class ARGS_01,
1002 class ARGS_02,
1003 class ARGS_03,
1004 class ARGS_04>
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#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 4
1013
1014#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
1015 template <class TARGET_TYPE, class ARGS_01,
1016 class ARGS_02,
1017 class ARGS_03,
1018 class ARGS_04,
1019 class ARGS_05>
1020 static void emplace(TARGET_TYPE *toBegin,
1021 TARGET_TYPE *toEnd,
1022 bslma::Allocator *allocator,
1023 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1024 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1027 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
1028#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 5
1029
1030#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
1031 template <class TARGET_TYPE, class ARGS_01,
1032 class ARGS_02,
1033 class ARGS_03,
1034 class ARGS_04,
1035 class ARGS_05,
1036 class ARGS_06>
1037 static void emplace(TARGET_TYPE *toBegin,
1038 TARGET_TYPE *toEnd,
1039 bslma::Allocator *allocator,
1040 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1041 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1042 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1043 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1044 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1045 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
1046#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 6
1047
1048#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
1049 template <class TARGET_TYPE, class ARGS_01,
1050 class ARGS_02,
1051 class ARGS_03,
1052 class ARGS_04,
1053 class ARGS_05,
1054 class ARGS_06,
1055 class ARGS_07>
1056 static void emplace(TARGET_TYPE *toBegin,
1057 TARGET_TYPE *toEnd,
1058 bslma::Allocator *allocator,
1059 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1060 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1061 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1062 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1063 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1064 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1065 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
1066#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 7
1067
1068#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
1069 template <class TARGET_TYPE, class ARGS_01,
1070 class ARGS_02,
1071 class ARGS_03,
1072 class ARGS_04,
1073 class ARGS_05,
1074 class ARGS_06,
1075 class ARGS_07,
1076 class ARGS_08>
1077 static void emplace(TARGET_TYPE *toBegin,
1078 TARGET_TYPE *toEnd,
1079 bslma::Allocator *allocator,
1080 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1081 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1082 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1083 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1084 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1085 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1086 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1087 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
1088#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 8
1089
1090#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
1091 template <class TARGET_TYPE, class ARGS_01,
1092 class ARGS_02,
1093 class ARGS_03,
1094 class ARGS_04,
1095 class ARGS_05,
1096 class ARGS_06,
1097 class ARGS_07,
1098 class ARGS_08,
1099 class ARGS_09>
1100 static void emplace(TARGET_TYPE *toBegin,
1101 TARGET_TYPE *toEnd,
1102 bslma::Allocator *allocator,
1103 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1104 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1105 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1106 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1107 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1108 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1109 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1110 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1111 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
1112#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 9
1113
1114#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
1115 template <class TARGET_TYPE, class ARGS_01,
1116 class ARGS_02,
1117 class ARGS_03,
1118 class ARGS_04,
1119 class ARGS_05,
1120 class ARGS_06,
1121 class ARGS_07,
1122 class ARGS_08,
1123 class ARGS_09,
1124 class ARGS_10>
1125 static void emplace(TARGET_TYPE *toBegin,
1126 TARGET_TYPE *toEnd,
1127 bslma::Allocator *allocator,
1128 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1129 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1130 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1131 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1132 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1133 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
1134 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
1135 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
1136 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
1137 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
1138#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_B >= 10
1139
1140#else
1141// The generated code below is a workaround for the absence of perfect
1142// forwarding in some compilers.
1143
1144 template <class ALLOCATOR, class... ARGS>
1145 static void emplace(
1148 ALLOCATOR allocator,
1149 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments);
1150
1151 template <class TARGET_TYPE, class... ARGS>
1152 static void emplace(TARGET_TYPE *toBegin,
1153 TARGET_TYPE *toEnd,
1154 bslma::Allocator *allocator,
1155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
1156
1157// }}} END GENERATED CODE
1158#endif
1159
1160 /// TBD: improve comment
1161 /// Destroy the elements of type given by the `allocator_traits` class
1162 /// template for (template parameter) `ALLOCATOR` starting at the
1163 /// specified `first` `first` pointer and ending immediately before the
1164 /// specified `middle` pointer, and move the elements in the array
1165 /// starting at `middle` and ending at the specified `last` pointer down
1166 /// to the `first` pointer. If an assignment throws an exception during
1167 /// this process, all of the elements in the range `[ first, last )`
1168 /// will have unspecified but valid values, and no elements are destroyed.
1169 ///
1170 /// \pre The behavior is undefined unless
1171 /// `first <= middle <= last`.
1172 template <class ALLOCATOR>
1173 static void
1177 ALLOCATOR allocator);
1178
1179 /// Destroy the elements of the parameterized `TARGET_TYPE` in the array
1180 /// starting at the specified `first` address and ending immediately
1181 /// before the specified `middle` address, and move the elements in the
1182 /// array starting at `middle` and ending at the specified `last`
1183 /// address down to the `first` address. If an assignment throws an
1184 /// exception during this process, all of the elements in the range
1185 /// `[ first, last )` will have unspecified but valid values, and no elements are destroyed.
1186 ///
1187 /// \pre The behavior is undefined unless
1188 /// `first <= middle <= last`.
1189 template <class TARGET_TYPE>
1190 static void erase(TARGET_TYPE *first,
1191 TARGET_TYPE *middle,
1192 TARGET_TYPE *last,
1193 bslma::Allocator *allocator = 0);
1194
1195 /// Insert the specified `value` into the array of
1196 /// `allocator_traits<ALLOCATOR>::value_type` objects at the specified
1197 /// `toBegin` location, shifting forward the elements from `toBegin` to
1198 /// the specified `toEnd` location by one position. `value` is left in
1199 /// a valid but unspecified state. If a (copy or move) constructor or a
1200 /// (copy or move) assignment operator throws an exception, then any
1201 /// elements created after `toEnd` are destroyed and the elements in the
1202 /// range `[toBegin .. toEnd )` are left in a valid but unspecified state.
1203 ///
1204 /// \pre The behavior is undefined unless `toBegin` refers to
1205 /// sufficient space to hold at least `toEnd - toBegin + 1` elements.
1206 template <class ALLOCATOR>
1207 static void
1212 ALLOCATOR allocator);
1213
1214 /// Insert the specified `value` into the array of the (template
1215 /// parameter) type `TARGET_TYPE` at the specified `toBegin` address,
1216 /// shifting the elements from `toBegin` to the specified `toEnd`
1217 /// address by one position towards larger addresses. `value` is left
1218 /// in a valid but unspecified state. If a (copy or move) constructor
1219 /// or a (copy or move) assignment operator throws an exception, then
1220 /// any elements created after `toEnd` are destroyed and the elements in
1221 /// the range `[toBegin .. toEnd )` are left in a valid but unspecified state.
1222 ///
1223 /// \pre The behavior is undefined unless `toBegin` refers to
1224 /// sufficient space to hold at least `toEnd - toBegin + 1` elements.
1225 template <class TARGET_TYPE>
1226 static void insert(TARGET_TYPE *toBegin,
1227 TARGET_TYPE *toEnd,
1229 bslma::Allocator *allocator);
1230
1231 /// Insert the specified `numElements` copies of the specified `value`
1232 /// into the array of type `allocator_traits<ALLOCATOR>::value_type`
1233 /// starting at the specified `toBegin` location, shifting forward the
1234 /// elements from `toBegin` to the specified `toEnd` location by
1235 /// `numElements` positions. If a (copy or move) constructor or a (copy
1236 /// or move) assignment operator throws an exception, any elements
1237 /// created after `toEnd` are destroyed and the elements in the range
1238 /// `[toBegin .. toEnd)` are left in a valid but unspecified state.
1239 ///
1240 /// \pre The behavior is undefined unless `toBegin` refers to space sufficient to
1241 /// hold at least `toEnd - toBegin + numElements` elements.
1242 template <class ALLOCATOR>
1243 static void
1244 insert(
1248 size_type numElements,
1249 ALLOCATOR allocator);
1250
1251 /// Insert the specified `numElements` copies of the specified `value`
1252 /// into the array of (template parameter) `TARGET_TYPE` starting at the
1253 /// specified `toBegin` address and ending immediately before the
1254 /// specified `toEnd` address, shifting the elements in the array by
1255 /// `numElements` positions towards larger addresses.
1256 ///
1257 /// \pre The behavior is undefined unless the destination array contains at least
1258 /// `numElements` uninitialized elements after `toEnd`. If a copy
1259 /// constructor or assignment operator for `TARGET_TYPE` throws an
1260 /// exception, then any elements created after `toEnd` are destroyed and
1261 /// the elements in the range `[ toBegin, toEnd )` will have
1262 /// unspecified, but valid, values.
1263 template <class TARGET_TYPE>
1264 static void insert(TARGET_TYPE *toBegin,
1265 TARGET_TYPE *toEnd,
1266 const TARGET_TYPE& value,
1267 size_type numElements,
1268 bslma::Allocator *allocator);
1269
1270 /// TBD: improve comment
1271 /// Insert the specified `numElements` from the range starting at the
1272 /// specified `fromBegin` of (template parameter) `FWD_ITER` type (or
1273 /// template parameter `SOURCE_TYPE *`) and ending immediately before the
1274 /// specified `fromEnd` sentinels or iterators of (template parameter)
1275 /// `SENTINEL` type (or template parameter `SOURCE_TYPE *`), into the array
1276 /// of elements of type given by the `allocator_traits` class template for
1277 /// (template parameter) `ALLOCATOR`, starting at the specified `toBegin`
1278 /// address, shifting forward the elements in the array by `numElements` positions.
1279 ///
1280 /// \pre The behavior is undefined unless the destination array
1281 /// contains `numElements` uninitialized elements after `toEnd`,
1282 /// `numElements` is the distance between `fromBegin` and `fromEnd`, and
1283 /// the input array and the destination array do not overlap. If a copy
1284 /// constructor or assignment operator throws an exception, then any
1285 /// elements created after `toEnd` are destroyed and the elements in the
1286 /// range `[ toBegin, toEnd )` will have valid but unspecified values.
1287 template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
1288 static void
1291 FWD_ITER fromBegin,
1292 SENTINEL fromEnd,
1293 size_type numElements,
1294 ALLOCATOR allocator);
1295 template <class ALLOCATOR, class SOURCE_TYPE>
1296 static void
1299 SOURCE_TYPE *fromBegin,
1300 SOURCE_TYPE *fromEnd,
1301 size_type numElements,
1302 ALLOCATOR allocator);
1303
1304 /// Insert, into the array at the specified `toBegin` location, the
1305 /// specified `numElements` from the range starting at the specified
1306 /// `fromBegin` iterators of the (template parameter) `FWD_ITER` type (or
1307 /// the (template parameter) `SOURCE_TYPE *`) and ending immediately before
1308 /// the specified `fromEnd` sentinels or iterators of the (template
1309 /// parameter) `SENTINEL` type (or the (template parameter)
1310 /// `SOURCE_TYPE *`), into the array of elements of the parameterized
1311 /// `TARGET_TYPE` starting at the specified `toBegin` address and ending
1312 /// immediately before the specified `toEnd` address, shifting the elements
1313 /// in the array by `numElements` positions towards larger addresses.
1314 ///
1315 /// \pre The behavior is undefined unless the destination array contains
1316 /// `numElements` uninitialized elements after `toEnd`, `numElements` is
1317 /// the distance between `fromBegin` and `fromEnd`, and the input array and
1318 /// the destination array do not overlap. If a copy constructor or
1319 /// assignment operator for `TARGET_TYPE` throws an exception, then any
1320 /// elements created after `toEnd` are destroyed and the elements in the
1321 /// range `[ toBegin, toEnd )` will have unspecified, but valid, values.
1322 template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
1323 static void insert(TARGET_TYPE *toBegin,
1324 TARGET_TYPE *toEnd,
1325 FWD_ITER fromBegin,
1326 SENTINEL fromEnd,
1327 size_type numElements,
1328 bslma::Allocator *allocator);
1329 template <class TARGET_TYPE, class SOURCE_TYPE>
1330 static void insert(TARGET_TYPE *toBegin,
1331 TARGET_TYPE *toEnd,
1332 SOURCE_TYPE *fromBegin,
1333 SOURCE_TYPE *fromEnd,
1334 size_type numElements,
1335 bslma::Allocator *allocator);
1336
1337 /// TBD: improve comment
1338 /// Move the elements of type given by the `allocator_traits` class
1339 /// template for (template parameter) `ALLOCATOR` in the array starting
1340 /// at the specified `toBegin` location and ending immediately before
1341 /// the specified `toEnd` location by the specified `numElements`
1342 /// positions towards larger addresses, and fill the `numElements` at
1343 /// the `toBegin` location by moving the elements from the array
1344 /// starting at the specified `fromBegin` and ending immediately before
1345 /// the specified `fromEnd` location. Keep the iterator at the
1346 /// specified `fromEndPtr` address pointing to the end of the range as
1347 /// the elements from `[ fromBegin, fromEnd )` are moved from source to destination.
1348 ///
1349 /// \pre The behavior is undefined unless the destination array
1350 /// contains `numElements` uninitialized elements after `toEnd`,
1351 /// `numElements` is the distance from `fromBegin` to `fromEnd`, and the
1352 /// input and destination arrays do not overlap. If a copy constructor
1353 /// or assignment operator for `TARGET_TYPE` throws an exception, then
1354 /// any elements created after `toEnd` are destroyed, the elements in
1355 /// the ranges `[ toBegin, toEnd)` and `[ fromBegin, *fromEndPtr )` will
1356 /// have unspecified, but valid, values, and the elements in
1357 /// `[ *fromEndPtr, fromEnd )` will be destroyed.
1358 template <class ALLOCATOR>
1359 static void moveInsert(
1362 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
1365 size_type numElements,
1366 ALLOCATOR allocator);
1367
1368 /// Move the elements of the (template parameter) `TARGET_TYPE` in the
1369 /// array starting at the specified `toBegin` address and ending
1370 /// immediately before the specified `toEnd` address by the specified
1371 /// `numElements` positions towards larger addresses, and fill the
1372 /// `numElements` at the `toBegin` address by moving the elements from
1373 /// the array starting at the specified `fromBegin` and ending
1374 /// immediately before the specified `fromEnd` address. Keep the
1375 /// iterator at the specified `fromEndPtr` address pointing to the end
1376 /// of the range as the elements from `[ fromBegin, fromEnd )` are moved from source to destination.
1377 ///
1378 /// \pre The behavior is undefined unless the
1379 /// destination array contains `numElements` uninitialized elements
1380 /// after `toEnd`, `numElements` is the distance from `fromBegin` to
1381 /// `fromEnd`, and the input and destination arrays do not overlap. If
1382 /// a copy constructor or assignment operator for `TARGET_TYPE` throws
1383 /// an exception, then any elements created after `toEnd` are destroyed,
1384 /// the elements in the ranges `[ toBegin, toEnd)` and
1385 /// `[ fromBegin, *fromEndPtr )` will have unspecified, but valid,
1386 /// values, and the elements in `[ *fromEndPtr, fromEnd )` will be
1387 /// destroyed.
1388 template <class TARGET_TYPE>
1389 static void moveInsert(TARGET_TYPE *toBegin,
1390 TARGET_TYPE *toEnd,
1391 TARGET_TYPE **fromEndPtr,
1392 TARGET_TYPE *fromBegin,
1393 TARGET_TYPE *fromEnd,
1394 size_type numElements,
1395 bslma::Allocator *allocator);
1396
1397 /// Move the elements of the parameterized `TARGET_TYPE` in the array
1398 /// starting at the specified `first` address and ending immediately
1399 /// before the specified `middle` address to the array of the same
1400 /// length ending at the specified `last` address (and thus starting at
1401 /// the `last - (middle - first)` address), and move the elements
1402 /// previously in the array starting at `middle` and ending at `last`
1403 /// down to the `first` address. If the assignment operator throws an
1404 /// exception during this process, all of the elements in
1405 /// `[ first, last )` will have unspecified, but valid, values.
1406 ///
1407 /// \pre The behavior is undefined unless `first <= middle <= last`.
1408 template <class TARGET_TYPE>
1409 static void rotate(TARGET_TYPE *first,
1410 TARGET_TYPE *middle,
1411 TARGET_TYPE *last);
1412
1413 /// TBD: improve comment
1414 /// Construct copies of the specified `value` of type given by the
1415 /// `allocator_traits` class template for (template parameter)
1416 /// `ALLOCATOR` into the uninitialized array containing the specified
1417 /// `numElements` starting at the specified `begin` location.
1418 ///
1419 /// \pre The behavior is undefined unless the output array contains at least
1420 /// `numElements` uninitialized elements after `begin`. If a
1421 /// constructor throws an exception during the operation, then the
1422 /// destructor is called on any newly-constructed elements, leaving the
1423 /// output array in an uninitialized state.
1424 template <class ALLOCATOR>
1425 static void uninitializedFillN(
1427 size_type numElements,
1429 ALLOCATOR allocator);
1430
1431 /// Construct copies of the specified `value` of the parameterized type
1432 /// `TARGET_TYPE` into the uninitialized array containing the specified
1433 /// `numElements` starting at the specified `begin` address. If the
1434 /// (template parameter) `ALLOCATOR` type is derived from
1435 /// `bslma::Allocator` and `TARGET_TYPE` supports `bslma` allocators,
1436 /// then the specified `allocator` is passed to each invocation of the `TARGET_TYPE` copy constructor.
1437 ///
1438 /// \pre The behavior is undefined unless
1439 /// the output array contains at least `numElements` uninitialized
1440 /// elements after `begin`. If a `TARGET_TYPE` constructor throws an
1441 /// exception during the operation, then the destructor is called on any
1442 /// newly-constructed elements, leaving the output array in an uninitialized state.
1443 ///
1444 /// \note Note that the argument order was chosen to
1445 /// maintain compatibility with the existing `bslalg`.
1446 template <class TARGET_TYPE>
1447 static void uninitializedFillN(TARGET_TYPE *begin,
1448 size_type numElements,
1449 const TARGET_TYPE& value,
1450 bslma::Allocator *allocator);
1451};
1452
1453 // ==========================
1454 // struct ArrayPrimitives_Imp
1455 // ==========================
1456
1457/// This `struct` provides a namespace for a suite of independent utility
1458/// functions that operate on arrays of elements of a parameterized
1459/// `TARGET_TYPE`. These utility functions are only for the purpose of
1460/// implementing those in the `ArrayPrimitives` utility. For brevity, we do
1461/// not repeat the main contracts here, but instead refer to the
1462/// corresponding contract in the `ArrayPrimitives` utility.
1463///
1464/// See @ref bslalg_arrayprimitives_cpp03
1465struct ArrayPrimitives_Imp {
1466
1467 private:
1468 // PRIVATE METHODS
1469
1470 /// Copy-assign the specified `value` to the range starting at the
1471 /// specified `srcStart` and ending immediately before the specified `srcEnd`.
1472 ///
1473 /// \note Note that the (template parameter) `TARGET_TYPE` must be
1474 /// copy-assignable. Also note that `value` should not be an element in
1475 /// the range `[srcStart, srcEnd)`.
1476 template <class TARGET_TYPE>
1477 static void assign(TARGET_TYPE *srcStart,
1478 TARGET_TYPE *srcEnd,
1479 TARGET_TYPE& value);
1480
1481 /// Copy-assign the elements in reverse order from the range starting at
1482 /// the specified `srcStart` and ending immediately before the specified
1483 /// `srcEnd` to the range starting at the specified `dest` and ending
1484 /// immediately before `dest + (srcEnd - srcStart)`.
1485 ///
1486 /// \pre The behavior is undefined unless each element is both range `[srcStart, srcEnd)` and range `[dest, dest + (srcEnd - srcStart))` is valid.
1487 ///
1488 /// \note Note that the
1489 /// (template parameter) `TARGET_TYPE` must be copy-assignable. Also
1490 /// note that this method is intended to support range assignment when
1491 /// the two ranges may be overlapped, and `srcStart <= dest`.
1492 template <class TARGET_TYPE>
1493 static void reverseAssign(TARGET_TYPE *dest,
1494 TARGET_TYPE *srcStart,
1495 TARGET_TYPE *srcEnd);
1496
1497 public:
1498 // TYPES
1501
1502 enum {
1503 // These constants are used in the overloads below, when the last
1504 // argument is of type 'bslmf::integral_constant<int,N>', indicating
1505 // that 'TARGET_TYPE' has the traits for which the enumerator equal to
1506 // 'N' is named.
1507
1514 e_NIL_TRAITS = 0
1515 };
1516
1517 enum {
1518 // Number of bytes for which a stack-allocated buffer can be
1519 // comfortably obtained to optimize bitwise moves.
1520
1522 };
1523
1524 // CLASS METHODS
1525
1526 /// Fill the specified `numBytes` in the array starting at the specified
1527 /// `begin` address, as if by bit-wise copying the specified
1528 /// `numBytesInitialized` at every offset that is a multiple of
1529 /// `numBytesInitialized` within the output array.
1530 ///
1531 /// \pre The behavior is undefined unless `numBytesInitialized <= numBytes`.
1532 ///
1533 /// \note Note that `numBytes` usually is, but does not have to be, a multiple of
1534 /// `numBytesInitialized`.
1535 static void bitwiseFillN(char *begin,
1536 size_type numBytesInitialized,
1537 size_type numBytes);
1538
1539 /// Copy the specified `value` of the parameterized `TARGET_TYPE` into
1540 /// every of the specified `numElements` in the array starting at the
1541 /// specified `begin` address. Pass the specified `allocator` to the copy constructor if appropriate.
1542 ///
1543 /// \note Note that if `TARGET_TYPE` is
1544 /// bit-wise copyable or is not based on `bslma::Allocator`, `allocator`
1545 /// is ignored. The last argument is for removing overload ambiguities
1546 /// and is not used.
1547 static void uninitializedFillN(
1548 bool *begin,
1549 bool value,
1550 size_type numElements,
1551 void * = 0,
1554 static void uninitializedFillN(
1555 char *begin,
1556 char value,
1557 size_type numElements,
1558 void * = 0,
1561 static void uninitializedFillN(
1562 unsigned char *begin,
1563 unsigned char value,
1564 size_type numElements,
1565 void * = 0,
1568 static void uninitializedFillN(
1569 signed char *begin,
1570 signed char value,
1571 size_type numElements,
1572 void * = 0,
1575 static void uninitializedFillN(
1576 wchar_t *begin,
1577 wchar_t value,
1578 size_type numElements,
1579 void * = 0,
1582 static void uninitializedFillN(
1583 short *begin,
1584 short value,
1585 size_type numElements,
1586 void * = 0,
1589 static void uninitializedFillN(
1590 unsigned short *begin,
1591 unsigned short value,
1592 size_type numElements,
1593 void * = 0,
1596 static void uninitializedFillN(
1597 int *begin,
1598 int value,
1599 size_type numElements,
1600 void * = 0,
1603 static void uninitializedFillN(
1604 unsigned int *begin,
1605 unsigned int value,
1606 size_type numElements,
1607 void * = 0,
1610 static void uninitializedFillN(
1611 long *begin,
1612 long value,
1613 size_type numElements,
1614 void * = 0,
1617 static void uninitializedFillN(
1618 unsigned long *begin,
1619 unsigned long value,
1620 size_type numElements,
1621 void * = 0,
1624 static void uninitializedFillN(
1625 bsls::Types::Int64 *begin,
1626 bsls::Types::Int64 value,
1627 size_type numElements,
1628 void * = 0,
1631 static void uninitializedFillN(
1632 bsls::Types::Uint64 *begin,
1633 bsls::Types::Uint64 value,
1634 size_type numElements,
1635 void * = 0,
1638 static void uninitializedFillN(
1639 float *begin,
1640 float value,
1641 size_type numElements,
1642 void * = 0,
1645 static void uninitializedFillN(
1646 double *begin,
1647 double value,
1648 size_type numElements,
1649 void * = 0,
1652 static void uninitializedFillN(
1653 long double *begin,
1654 long double value,
1655 size_type numElements,
1656 void * = 0,
1659 static void uninitializedFillN(
1660 void **begin,
1661 void *value,
1662 size_type numElements,
1663 void * = 0,
1666 static void uninitializedFillN(
1667 const void **begin,
1668 const void *value,
1669 size_type numElements,
1670 void * = 0,
1673 static void uninitializedFillN(
1674 volatile void **begin,
1675 volatile void *value,
1676 size_type numElements,
1677 void * = 0,
1680 static void uninitializedFillN(
1681 const volatile void **begin,
1682 const volatile void *value,
1683 size_type numElements,
1684 void * = 0,
1687 template <class TARGET_TYPE>
1688 static void uninitializedFillN(
1689 TARGET_TYPE **begin,
1690 TARGET_TYPE *value,
1691 size_type numElements,
1692 void * = 0,
1695 template <class TARGET_TYPE>
1696 static void uninitializedFillN(
1697 const TARGET_TYPE **begin,
1698 const TARGET_TYPE *value,
1699 size_type numElements,
1700 void * = 0,
1703 template <class TARGET_TYPE>
1704 static void uninitializedFillN(
1705 volatile TARGET_TYPE **begin,
1706 volatile TARGET_TYPE *value,
1707 size_type numElements,
1708 void * = 0,
1711 template <class TARGET_TYPE>
1712 static void uninitializedFillN(
1713 const volatile TARGET_TYPE **begin,
1714 const volatile TARGET_TYPE *value,
1715 size_type numElements,
1716 void * = 0,
1719 template <class TARGET_TYPE, class ALLOCATOR>
1720 static void uninitializedFillN(
1721 TARGET_TYPE *begin,
1722 const TARGET_TYPE& value,
1723 size_type numElements,
1724 ALLOCATOR *allocator,
1726 template <class TARGET_TYPE, class ALLOCATOR>
1727 static void uninitializedFillN(
1728 TARGET_TYPE *begin,
1729 const TARGET_TYPE& value,
1730 size_type numElements,
1731 ALLOCATOR *allocator,
1733
1734 /// These functions follow the `copyConstruct` contract. If the (template
1735 /// parameter) `ALLOCATOR` type is based on `bslma::Allocator` and the
1736 /// `TARGET_TYPE` constructors take an allocator argument, then pass the
1737 /// specified `allocator` to the copy constructor.
1738 ///
1739 /// \pre The behavior is undefined unless the output array has length at least the distance from the specified `fromBegin` to the specified `fromEnd`.
1740 ///
1741 /// \note Note that if
1742 /// `FWD_ITER` is the `TARGET_TYPE *` pointer type and `TARGET_TYPE` is
1743 /// bit-wise copyable, then this operation is simply `memcpy`. The last
1744 /// argument is for removing overload ambiguities and is not used.
1745 template <class TARGET_TYPE,
1746 class FWD_ITER,
1747 class SENTINEL,
1748 class ALLOCATOR>
1749 static void copyConstruct(
1750 TARGET_TYPE *toBegin,
1751 FWD_ITER fromBegin,
1752 SENTINEL fromEnd,
1753 ALLOCATOR allocator,
1755 template <class TARGET_TYPE, class ALLOCATOR>
1756 static void copyConstruct(
1757 TARGET_TYPE *toBegin,
1758 const TARGET_TYPE *fromBegin,
1759 const TARGET_TYPE *fromEnd,
1760 ALLOCATOR allocator,
1762 template <class TARGET_TYPE,
1763 class FWD_ITER,
1764 class SENTINEL,
1765 class ALLOCATOR>
1766 static void copyConstruct(
1767 TARGET_TYPE *toBegin,
1768 FWD_ITER fromBegin,
1769 SENTINEL fromEnd,
1770 ALLOCATOR allocator,
1772 template <class FWD_ITER, class SENTINEL, class ALLOCATOR>
1773 static void copyConstruct(
1774 void **toBegin,
1775 FWD_ITER fromBegin,
1776 SENTINEL fromEnd,
1777 ALLOCATOR allocator,
1779 template <class TARGET_TYPE,
1780 class FWD_ITER,
1781 class SENTINEL,
1782 class ALLOCATOR>
1783 static void copyConstruct(
1784 TARGET_TYPE *toBegin,
1785 FWD_ITER fromBegin,
1786 SENTINEL fromEnd,
1787 ALLOCATOR allocator,
1789
1790 /// TBD: improve comment
1791 /// Move-insert into an uninitialized array beginning at the specified
1792 /// `toBegin` pointer, elements of type given by the `allocator_traits`
1793 /// class template for (template parameter) `ALLOCATOR` from elements
1794 /// starting at the specified `fromBegin` pointer and ending immediately
1795 /// before the specified `fromEnd` pointer. The elements in the range
1796 /// `[fromBegin...fromEnd)` are left in a valid but unspecified state.
1797 /// If a constructor throws an exception during the operation, then the
1798 /// destructor is called on any newly-constructed elements, leaving the
1799 /// output array in an uninitialized state.
1800 ///
1801 /// \pre The behavior is undefined unless `toBegin` refers to space sufficient to hold
1802 /// `fromEnd - fromBegin` elements.
1803 template <class TARGET_TYPE, class ALLOCATOR>
1804 static void moveConstruct(
1805 TARGET_TYPE *toBegin,
1806 TARGET_TYPE *fromBegin,
1807 TARGET_TYPE *fromEnd,
1808 ALLOCATOR allocator,
1810 template <class TARGET_TYPE, class ALLOCATOR>
1811 static void moveConstruct(
1812 TARGET_TYPE *toBegin,
1813 TARGET_TYPE *fromBegin,
1814 TARGET_TYPE *fromEnd,
1815 ALLOCATOR allocator,
1817
1818 /// TBD: improve comment
1819 /// Either move- or copy-insert into an uninitialized array beginning at
1820 /// the specified `toBegin` pointer, elements of type given by the
1821 /// `allocator_traits` class template for (template parameter)
1822 /// `ALLOCATOR` from elements starting at the specified `fromBegin`
1823 /// pointer and ending immediately before the specified `fromEnd`
1824 /// pointer. The elements in the range `[fromBegin...fromEnd)` are left
1825 /// in a valid but unspecified state. Use the move constructor if it is
1826 /// guaranteed to not throw or if the target type does not define a copy
1827 /// constructor; otherwise use the copy constructor. If a constructor
1828 /// throws an exception during the operation, then the destructor is
1829 /// called on any newly-constructed elements, leaving the output array in an uninitialized state.
1830 ///
1831 /// \pre The behavior is undefined unless
1832 /// `toBegin` refers to space sufficient to hold `fromEnd - fromBegin`
1833 /// elements.
1834 template <class TARGET_TYPE, class ALLOCATOR>
1835 static void moveIfNoexcept(
1836 TARGET_TYPE *toBegin,
1837 TARGET_TYPE *fromBegin,
1838 TARGET_TYPE *fromEnd,
1839 ALLOCATOR allocator,
1841
1842 /// Use the default constructor of the (template parameter)
1843 /// `TARGET_TYPE` (or `memset` to 0 if `TARGET_TYPE` has a trivial
1844 /// default constructor) on each element of the array starting at the
1845 /// specified `begin` address and ending immediately before the `end`
1846 /// address. Pass the specified `allocator` to the default constructor
1847 /// if appropriate. The last argument is for traits overloading
1848 /// resolution only and its value is ignored.
1849 template <class TARGET_TYPE, class ALLOCATOR>
1850 static void defaultConstruct(
1851 TARGET_TYPE *begin,
1852 size_type numElements,
1853 ALLOCATOR allocator,
1855 template <class TARGET_TYPE, class ALLOCATOR>
1856 static void defaultConstruct(
1857 TARGET_TYPE *begin,
1858 size_type numElements,
1859 ALLOCATOR allocator,
1861 template <class TARGET_TYPE, class ALLOCATOR>
1862 static void defaultConstruct(
1863 TARGET_TYPE *begin,
1864 size_type numElements,
1865 ALLOCATOR allocator,
1867
1868 /// These functions follow the `destructiveMove` contract.
1869 ///
1870 /// \note Note that both arrays cannot overlap (one contains only initialized elements
1871 /// and the other only uninitialized elements), and that if
1872 /// `TARGET_TYPE` is bit-wise moveable, then this operation is simply
1873 /// `memcpy`. The last argument is for removing overload ambiguities
1874 /// and is not used.
1875 template <class TARGET_TYPE, class ALLOCATOR>
1876 static void destructiveMove(
1877 TARGET_TYPE *toBegin,
1878 TARGET_TYPE *fromBegin,
1879 TARGET_TYPE *fromEnd,
1880 ALLOCATOR allocator,
1882 template <class TARGET_TYPE, class ALLOCATOR>
1883 static void destructiveMove(
1884 TARGET_TYPE *toBegin,
1885 TARGET_TYPE *fromBegin,
1886 TARGET_TYPE *fromEnd,
1887 ALLOCATOR allocator,
1889
1890#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1891// {{{ BEGIN GENERATED CODE
1892// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
1893#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
1894#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
1895#endif
1896#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C
1897#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
1898#endif
1899#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
1900 template <class TARGET_TYPE, class ALLOCATOR>
1901 static void emplace(
1902 TARGET_TYPE *toBegin,
1903 TARGET_TYPE *toEnd,
1904 ALLOCATOR allocator,
1906#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
1907
1908#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
1909 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
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#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
1917
1918#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
1919 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1920 class ARGS_02>
1921 static void emplace(
1922 TARGET_TYPE *toBegin,
1923 TARGET_TYPE *toEnd,
1924 ALLOCATOR allocator,
1926 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1927 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
1928#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
1929
1930#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
1931 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1932 class ARGS_02,
1933 class ARGS_03>
1934 static void emplace(
1935 TARGET_TYPE *toBegin,
1936 TARGET_TYPE *toEnd,
1937 ALLOCATOR allocator,
1939 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1940 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1941 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
1942#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
1943
1944#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
1945 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1946 class ARGS_02,
1947 class ARGS_03,
1948 class ARGS_04>
1949 static void emplace(
1950 TARGET_TYPE *toBegin,
1951 TARGET_TYPE *toEnd,
1952 ALLOCATOR allocator,
1954 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1955 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1956 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1957 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
1958#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
1959
1960#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
1961 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1962 class ARGS_02,
1963 class ARGS_03,
1964 class ARGS_04,
1965 class ARGS_05>
1966 static void emplace(
1967 TARGET_TYPE *toBegin,
1968 TARGET_TYPE *toEnd,
1969 ALLOCATOR allocator,
1971 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1972 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1973 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1974 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1975 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
1976#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
1977
1978#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
1979 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
1980 class ARGS_02,
1981 class ARGS_03,
1982 class ARGS_04,
1983 class ARGS_05,
1984 class ARGS_06>
1985 static void emplace(
1986 TARGET_TYPE *toBegin,
1987 TARGET_TYPE *toEnd,
1988 ALLOCATOR allocator,
1990 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
1991 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
1992 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
1993 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
1994 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
1995 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
1996#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
1997
1998#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
1999 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2000 class ARGS_02,
2001 class ARGS_03,
2002 class ARGS_04,
2003 class ARGS_05,
2004 class ARGS_06,
2005 class ARGS_07>
2006 static void emplace(
2007 TARGET_TYPE *toBegin,
2008 TARGET_TYPE *toEnd,
2009 ALLOCATOR allocator,
2011 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2012 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2013 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2014 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2015 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2016 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2017 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2018#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2019
2020#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2021 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2022 class ARGS_02,
2023 class ARGS_03,
2024 class ARGS_04,
2025 class ARGS_05,
2026 class ARGS_06,
2027 class ARGS_07,
2028 class ARGS_08>
2029 static void emplace(
2030 TARGET_TYPE *toBegin,
2031 TARGET_TYPE *toEnd,
2032 ALLOCATOR allocator,
2034 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2035 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2036 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2037 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2038 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2039 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2040 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2041 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2042#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2043
2044#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2045 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2046 class ARGS_02,
2047 class ARGS_03,
2048 class ARGS_04,
2049 class ARGS_05,
2050 class ARGS_06,
2051 class ARGS_07,
2052 class ARGS_08,
2053 class ARGS_09>
2054 static void emplace(
2055 TARGET_TYPE *toBegin,
2056 TARGET_TYPE *toEnd,
2057 ALLOCATOR allocator,
2059 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2060 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2061 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2062 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2063 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2064 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2065 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2066 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2067 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2068#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2069
2070#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2071 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2072 class ARGS_02,
2073 class ARGS_03,
2074 class ARGS_04,
2075 class ARGS_05,
2076 class ARGS_06,
2077 class ARGS_07,
2078 class ARGS_08,
2079 class ARGS_09,
2080 class ARGS_10>
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 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2089 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2090 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2091 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2092 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2093 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2094 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2095 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2096#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2097
2098#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2099 template <class TARGET_TYPE, class ALLOCATOR>
2100 static void emplace(
2101 TARGET_TYPE *toBegin,
2102 TARGET_TYPE *toEnd,
2103 ALLOCATOR allocator,
2105#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2106
2107#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2108 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
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#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2116
2117#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2118 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2119 class ARGS_02>
2120 static void emplace(
2121 TARGET_TYPE *toBegin,
2122 TARGET_TYPE *toEnd,
2123 ALLOCATOR allocator,
2125 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2126 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2127#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2128
2129#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2130 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2131 class ARGS_02,
2132 class ARGS_03>
2133 static void emplace(
2134 TARGET_TYPE *toBegin,
2135 TARGET_TYPE *toEnd,
2136 ALLOCATOR allocator,
2138 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2139 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2140 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2141#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2142
2143#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2144 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2145 class ARGS_02,
2146 class ARGS_03,
2147 class ARGS_04>
2148 static void emplace(
2149 TARGET_TYPE *toBegin,
2150 TARGET_TYPE *toEnd,
2151 ALLOCATOR allocator,
2153 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2154 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2155 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2156 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2157#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2158
2159#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2160 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2161 class ARGS_02,
2162 class ARGS_03,
2163 class ARGS_04,
2164 class ARGS_05>
2165 static void emplace(
2166 TARGET_TYPE *toBegin,
2167 TARGET_TYPE *toEnd,
2168 ALLOCATOR allocator,
2170 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2171 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2172 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2173 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2174 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2175#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2176
2177#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2178 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2179 class ARGS_02,
2180 class ARGS_03,
2181 class ARGS_04,
2182 class ARGS_05,
2183 class ARGS_06>
2184 static void emplace(
2185 TARGET_TYPE *toBegin,
2186 TARGET_TYPE *toEnd,
2187 ALLOCATOR allocator,
2189 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2190 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2191 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2192 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2193 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2194 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2195#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2196
2197#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2198 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2199 class ARGS_02,
2200 class ARGS_03,
2201 class ARGS_04,
2202 class ARGS_05,
2203 class ARGS_06,
2204 class ARGS_07>
2205 static void emplace(
2206 TARGET_TYPE *toBegin,
2207 TARGET_TYPE *toEnd,
2208 ALLOCATOR allocator,
2210 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2211 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2212 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2213 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2214 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2215 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2216 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2217#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2218
2219#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2220 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2221 class ARGS_02,
2222 class ARGS_03,
2223 class ARGS_04,
2224 class ARGS_05,
2225 class ARGS_06,
2226 class ARGS_07,
2227 class ARGS_08>
2228 static void emplace(
2229 TARGET_TYPE *toBegin,
2230 TARGET_TYPE *toEnd,
2231 ALLOCATOR allocator,
2233 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2234 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2235 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2236 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2237 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2238 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2239 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2240 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2241#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2242
2243#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2244 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2245 class ARGS_02,
2246 class ARGS_03,
2247 class ARGS_04,
2248 class ARGS_05,
2249 class ARGS_06,
2250 class ARGS_07,
2251 class ARGS_08,
2252 class ARGS_09>
2253 static void emplace(
2254 TARGET_TYPE *toBegin,
2255 TARGET_TYPE *toEnd,
2256 ALLOCATOR allocator,
2258 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2259 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2260 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2261 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2262 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2263 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2264 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2265 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2266 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2267#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2268
2269#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2270 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2271 class ARGS_02,
2272 class ARGS_03,
2273 class ARGS_04,
2274 class ARGS_05,
2275 class ARGS_06,
2276 class ARGS_07,
2277 class ARGS_08,
2278 class ARGS_09,
2279 class ARGS_10>
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 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2288 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2289 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2290 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2291 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2292 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2293 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2294 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2295#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2296
2297#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2298 template <class TARGET_TYPE, class ALLOCATOR>
2299 static void emplace(
2300 TARGET_TYPE *toBegin,
2301 TARGET_TYPE *toEnd,
2302 ALLOCATOR allocator,
2304#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 0
2305
2306#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2307 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
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#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 1
2315
2316#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2317 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2318 class ARGS_02>
2319 static void emplace(
2320 TARGET_TYPE *toBegin,
2321 TARGET_TYPE *toEnd,
2322 ALLOCATOR allocator,
2324 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2325 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02);
2326#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 2
2327
2328#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2329 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2330 class ARGS_02,
2331 class ARGS_03>
2332 static void emplace(
2333 TARGET_TYPE *toBegin,
2334 TARGET_TYPE *toEnd,
2335 ALLOCATOR allocator,
2337 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2338 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2339 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03);
2340#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 3
2341
2342#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2343 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2344 class ARGS_02,
2345 class ARGS_03,
2346 class ARGS_04>
2347 static void emplace(
2348 TARGET_TYPE *toBegin,
2349 TARGET_TYPE *toEnd,
2350 ALLOCATOR allocator,
2352 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2355 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04);
2356#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 4
2357
2358#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2359 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2360 class ARGS_02,
2361 class ARGS_03,
2362 class ARGS_04,
2363 class ARGS_05>
2364 static void emplace(
2365 TARGET_TYPE *toBegin,
2366 TARGET_TYPE *toEnd,
2367 ALLOCATOR allocator,
2369 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2370 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2371 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2372 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2373 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05);
2374#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 5
2375
2376#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2377 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2378 class ARGS_02,
2379 class ARGS_03,
2380 class ARGS_04,
2381 class ARGS_05,
2382 class ARGS_06>
2383 static void emplace(
2384 TARGET_TYPE *toBegin,
2385 TARGET_TYPE *toEnd,
2386 ALLOCATOR allocator,
2388 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2389 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2390 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2391 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2392 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2393 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06);
2394#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 6
2395
2396#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2397 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2398 class ARGS_02,
2399 class ARGS_03,
2400 class ARGS_04,
2401 class ARGS_05,
2402 class ARGS_06,
2403 class ARGS_07>
2404 static void emplace(
2405 TARGET_TYPE *toBegin,
2406 TARGET_TYPE *toEnd,
2407 ALLOCATOR allocator,
2409 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2410 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2411 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2412 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2413 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2414 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2415 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07);
2416#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 7
2417
2418#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2419 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2420 class ARGS_02,
2421 class ARGS_03,
2422 class ARGS_04,
2423 class ARGS_05,
2424 class ARGS_06,
2425 class ARGS_07,
2426 class ARGS_08>
2427 static void emplace(
2428 TARGET_TYPE *toBegin,
2429 TARGET_TYPE *toEnd,
2430 ALLOCATOR allocator,
2432 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2433 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2434 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2435 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2436 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2437 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2438 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2439 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08);
2440#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 8
2441
2442#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2443 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2444 class ARGS_02,
2445 class ARGS_03,
2446 class ARGS_04,
2447 class ARGS_05,
2448 class ARGS_06,
2449 class ARGS_07,
2450 class ARGS_08,
2451 class ARGS_09>
2452 static void emplace(
2453 TARGET_TYPE *toBegin,
2454 TARGET_TYPE *toEnd,
2455 ALLOCATOR allocator,
2457 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2458 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2459 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2460 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2461 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2462 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2463 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2464 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2465 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09);
2466#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 9
2467
2468#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2469 template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
2470 class ARGS_02,
2471 class ARGS_03,
2472 class ARGS_04,
2473 class ARGS_05,
2474 class ARGS_06,
2475 class ARGS_07,
2476 class ARGS_08,
2477 class ARGS_09,
2478 class ARGS_10>
2479 static void emplace(
2480 TARGET_TYPE *toBegin,
2481 TARGET_TYPE *toEnd,
2482 ALLOCATOR allocator,
2484 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
2485 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
2486 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
2487 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
2488 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
2489 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
2490 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
2491 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
2492 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
2493 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10);
2494#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_C >= 10
2495
2496#else
2497// The generated code below is a workaround for the absence of perfect
2498// forwarding in some compilers.
2499 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2500 static void emplace(
2501 TARGET_TYPE *toBegin,
2502 TARGET_TYPE *toEnd,
2503 ALLOCATOR allocator,
2505 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2506 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2507 static void emplace(
2508 TARGET_TYPE *toBegin,
2509 TARGET_TYPE *toEnd,
2510 ALLOCATOR allocator,
2512 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2513 template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
2514 static void emplace(
2515 TARGET_TYPE *toBegin,
2516 TARGET_TYPE *toEnd,
2517 ALLOCATOR allocator,
2519 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... args);
2520// }}} END GENERATED CODE
2521#endif
2522
2523 /// These functions follow the `erase` contract.
2524 /// \note Note that if (template
2525 /// parameter) `TARGET_TYPE` is bit-wise moveable, then this operation
2526 /// can be implemented by first bit-wise moving the elements in
2527 /// `[middle, last)` towards first, and destroying
2528 /// `[ last - (middle - first), last)`; note that this cannot throw
2529 /// exceptions.
2530 template <class TARGET_TYPE, class ALLOCATOR>
2531 static void erase(
2532 TARGET_TYPE *first,
2533 TARGET_TYPE *middle,
2534 TARGET_TYPE *last,
2535 ALLOCATOR allocator,
2537 template <class TARGET_TYPE, class ALLOCATOR>
2538 static void erase(
2539 TARGET_TYPE *first,
2540 TARGET_TYPE *middle,
2541 TARGET_TYPE *last,
2542 ALLOCATOR allocator,
2544
2545 /// These functions follow the `insert` contract.
2546 /// \note Note that if
2547 /// `TARGET_TYPE` is bit-wise copyable, then this operation is simply
2548 /// `memmove` followed by `bitwiseFillN`. If `TARGET_TYPE` is bit-wise
2549 /// moveable, then this operation can still be optimized using `memmove`
2550 /// followed by repeated assignments, but a guard needs to be set up.
2551 /// The last argument is for removing overload ambiguities and is not
2552 /// used.
2553 template <class TARGET_TYPE, class ALLOCATOR>
2554 static void insert(
2555 TARGET_TYPE *toBegin,
2556 TARGET_TYPE *toEnd,
2557 const TARGET_TYPE& value,
2558 size_type numElements,
2559 ALLOCATOR allocator,
2561 template <class TARGET_TYPE, class ALLOCATOR>
2562 static void insert(
2563 TARGET_TYPE *toBegin,
2564 TARGET_TYPE *toEnd,
2565 const TARGET_TYPE& value,
2566 size_type numElements,
2567 ALLOCATOR allocator,
2569 template <class TARGET_TYPE, class ALLOCATOR>
2570 static void insert(
2571 TARGET_TYPE *toBegin,
2572 TARGET_TYPE *toEnd,
2573 const TARGET_TYPE& value,
2574 size_type numElements,
2575 ALLOCATOR allocator,
2577
2578 /// These functions follow the `insert` contract.
2579 /// \note Note that if
2580 /// `TARGET_TYPE` is bit-wise copyable and `FWD_ITER` is convertible to
2581 /// `const TARGET_TYPE *`, then this operation is simply `memmove`
2582 /// followed by `memcpy`. If `TARGET_TYPE` is bit-wise moveable and
2583 /// `FWD_ITER` is convertible to `const TARGET_TYPE *`, then this
2584 /// operation can still be optimized using `memmove` followed by
2585 /// repeated copies. The last argument is for removing overload
2586 /// ambiguities and is not used.
2587 template <class TARGET_TYPE,
2588 class FWD_ITER,
2589 class SENTINEL,
2590 class ALLOCATOR>
2591 static void insert(
2592 TARGET_TYPE *toBegin,
2593 TARGET_TYPE *toEnd,
2594 FWD_ITER fromBegin,
2595 SENTINEL fromEnd,
2596 size_type numElements,
2597 ALLOCATOR allocator,
2599 template <class TARGET_TYPE, class ALLOCATOR>
2600 static void insert(
2601 TARGET_TYPE *toBegin,
2602 TARGET_TYPE *toEnd,
2603 const TARGET_TYPE *fromBegin,
2604 const TARGET_TYPE *fromEnd,
2605 size_type numElements,
2606 ALLOCATOR allocator,
2608 template <class TARGET_TYPE,
2609 class FWD_ITER,
2610 class SENTINEL,
2611 class ALLOCATOR>
2612 static void insert(
2613 TARGET_TYPE *toBegin,
2614 TARGET_TYPE *toEnd,
2615 FWD_ITER fromBegin,
2616 SENTINEL fromEnd,
2617 size_type numElements,
2618 ALLOCATOR allocator,
2620 template <class FWD_ITER, class SENTINEL, class ALLOCATOR>
2621 static void insert(
2622 void **toBegin,
2623 void **toEnd,
2624 FWD_ITER fromBegin,
2625 SENTINEL fromEnd,
2626 size_type numElements,
2627 ALLOCATOR allocator,
2629 template <class TARGET_TYPE,
2630 class FWD_ITER,
2631 class SENTINEL,
2632 class ALLOCATOR>
2633 static void insert(
2634 TARGET_TYPE *toBegin,
2635 TARGET_TYPE *toEnd,
2636 FWD_ITER fromBegin,
2637 SENTINEL fromEnd,
2638 size_type numElements,
2639 ALLOCATOR allocator,
2641
2642 /// These functions follow the `moveInsert` contract.
2643 /// \note Note that if
2644 /// `TARGET_TYPE` is at least bit-wise moveable, then this operation is
2645 /// simply `memmove` followed by `memcpy`.
2646 template <class TARGET_TYPE, class ALLOCATOR>
2647 static void moveInsert(
2648 TARGET_TYPE *toBegin,
2649 TARGET_TYPE *toEnd,
2650 TARGET_TYPE **lastPtr,
2651 TARGET_TYPE *first,
2652 TARGET_TYPE *last,
2653 size_type numElements,
2654 ALLOCATOR allocator,
2656 template <class TARGET_TYPE, class ALLOCATOR>
2657 static void moveInsert(
2658 TARGET_TYPE *toBegin,
2659 TARGET_TYPE *toEnd,
2660 TARGET_TYPE **lastPtr,
2661 TARGET_TYPE *first,
2662 TARGET_TYPE *last,
2663 size_type numElements,
2664 ALLOCATOR allocator,
2666
2667 /// These functions follow the `rotate` contract, but the first overload
2668 /// is optimized when the parameterized `TARGET_TYPE` is bit-wise
2669 /// moveable. The last argument is for removing overload ambiguities and is not used.
2670 ///
2671 /// \note Note that if `TARGET_TYPE` is bit-wise moveable,
2672 /// the `rotate(char*, char*, char*)` can be used, enabling to take the
2673 /// whole implementation out-of-line.
2674 template <class TARGET_TYPE>
2675 static void rotate(
2676 TARGET_TYPE *begin,
2677 TARGET_TYPE *middle,
2678 TARGET_TYPE *end,
2680 template <class TARGET_TYPE>
2681 static void rotate(
2682 TARGET_TYPE *begin,
2683 TARGET_TYPE *middle,
2684 TARGET_TYPE *end,
2686
2687 /// Shift the specified `[begin, end)` sequence one position right, then
2688 /// insert the specified `value` at the position pointed by `begin`.
2689 /// The specified `allocator` is used for the element construction.
2690 ///
2691 /// \pre The behavior is undefined unless the specified `[begin, end)` sequence
2692 /// contains at least one element.
2693 template <class ALLOCATOR>
2694 static void shiftAndInsert(
2699 ALLOCATOR allocator,
2701 template <class ALLOCATOR>
2702 static void shiftAndInsert(
2707 ALLOCATOR allocator,
2709 template <class ALLOCATOR>
2710 static void shiftAndInsert(
2715 ALLOCATOR allocator,
2717
2718 // 'bitwise' METHODS
2719
2720 /// This function follows the `rotate` contract, but by using bit-wise
2721 /// moves on the underlying `char` array.
2722 static void bitwiseRotate(char *begin, char *middle, char *end);
2723
2724 /// Move the characters in the array starting at the specified `first`
2725 /// address and ending immediately before the specified `middle` address
2726 /// to the array of the same length ending at the specified `last`
2727 /// address (and thus starting at the `last - (middle - first)`
2728 /// address), and move the elements previously in the array starting at
2729 /// `middle` and ending at `last` down to the `first` address.
2730 ///
2731 /// \pre The behavior is undefined unless
2732 /// `middle - begin <= k_INPLACE_BUFFER_SIZE`.
2733 static void bitwiseRotateBackward(char *begin, char *middle, char *end);
2734
2735 /// Move the characters in the array starting at the specified `first`
2736 /// address and ending immediately before the specified `middle` address
2737 /// to the array of the same length ending at the specified `last`
2738 /// address (and thus starting at the `last - (middle - first)`
2739 /// address), and move the elements previously in the array starting at
2740 /// `middle` and ending at `last` down to the `first` address.
2741 ///
2742 /// \pre The behavior is undefined unless
2743 /// `end - middle <= k_INPLACE_BUFFER_SIZE`.
2744 static void bitwiseRotateForward(char *begin, char *middle, char *end);
2745
2746 /// Swap the characters in the array starting at the specified `first`
2747 /// address and ending immediately before the specified `middle` address
2748 /// with the array of the same length starting at the `middle` address
2749 /// and ending at the specified `last` address.
2750 ///
2751 /// \pre The behavior is undefined unless `middle - begin == end - middle`.
2752 static void bitwiseSwapRanges(char *begin, char *middle, char *end);
2753
2754 /// Return `true` if the specified `begin` and the specified `end`
2755 /// provably do not form a valid semi-open range, `[begin, end)`, and `false` otherwise.
2756 ///
2757 /// \note Note that `begin == null == end` produces a
2758 /// valid range, and any other use of the null pointer value will return
2759 /// `true`. Also note that this function is intended to support
2760 /// testing, primarily through assertions, so will return `false` unless
2761 /// it can *prove* that the passed range is invalid. Currently, this
2762 /// function can prove invalid ranges only for pointers, although should
2763 /// also encompass generic random access iterators in a future update,
2764 /// where iterator tag types are levelized below `bslalg`.
2765 template <class FORWARD_ITERATOR, class SENTINEL>
2766 static bool isInvalidRange(FORWARD_ITERATOR begin, SENTINEL end);
2767 template <class TARGET_TYPE>
2768 static bool isInvalidRange(TARGET_TYPE *begin, TARGET_TYPE *end);
2769};
2770
2771// ============================================================================
2772// INLINE FUNCTION DEFINITIONS
2773// ============================================================================
2774// IMPLEMENTATION NOTES: Specializations of 'uninitializedFillN' for most
2775// fundamental types are not templates nor inline, and thus can be found in the
2776// '.cpp' file.
2777
2778 // =====================================
2779 // struct ArrayPrimitives_CanBitwiseCopy
2780 // =====================================
2781
2782template <class FROM_TYPE, class TO_TYPE>
2783struct ArrayPrimitives_CanBitwiseCopy
2785 bsl::is_same<
2786 typename bsl::remove_const<FROM_TYPE>::type,
2787 typename bsl::remove_const<TO_TYPE >::type>
2788 ::value
2789 && bslmf::IsBitwiseCopyable<
2790 typename bsl::remove_const<TO_TYPE >::type>
2791 ::value
2792 > {
2793};
2794
2795 // ----------------------
2796 // struct ArrayPrimitives
2797 // ----------------------
2798
2799template <class ALLOCATOR>
2800inline
2803 size_type numElements,
2805 ALLOCATOR allocator)
2806{
2807 BSLS_ASSERT_SAFE(begin || 0 == numElements);
2809
2810 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2811
2812 enum {
2813 // We provide specialized overloads of 'uninitializedFillN' for
2814 // fundamental and pointer types. However, function pointers can have
2815 // extern "C" linkage and SunPro doesn't match them properly with the
2816 // pointer template function overload in 'Imp', so we resort to the
2817 // general case for those.
2818
2819 k_IS_FUNCTION_POINTER = bslmf::IsFunctionPointer<TargetType>::value,
2820 k_IS_FUNDAMENTAL = bsl::is_fundamental<TargetType>::value,
2822
2823 k_IS_FUNDAMENTAL_OR_POINTER = k_IS_FUNDAMENTAL ||
2824 (k_IS_POINTER && !k_IS_FUNCTION_POINTER),
2825
2826 k_IS_BITWISECOPYABLE = bslmf::IsBitwiseCopyable<TargetType>::value,
2827
2828 k_VALUE =
2829 k_IS_FUNDAMENTAL_OR_POINTER ? Imp::e_IS_FUNDAMENTAL_OR_POINTER
2830 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
2831 : Imp::e_NIL_TRAITS
2832 };
2834 begin,
2835 value,
2836 numElements,
2837 &allocator,
2839}
2840
2841template <class TARGET_TYPE>
2842inline
2843void ArrayPrimitives::uninitializedFillN(TARGET_TYPE *begin,
2844 size_type numElements,
2845 const TARGET_TYPE& value,
2846 bslma::Allocator *basicAllocator)
2847{
2848 uninitializedFillN<bsl::allocator<TARGET_TYPE> >(begin,
2849 numElements,
2850 value,
2851 basicAllocator);
2852}
2853
2854template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
2857 FWD_ITER fromBegin,
2858 SENTINEL fromEnd,
2859 ALLOCATOR allocator)
2860{
2861 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
2862
2864 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2865
2866 /// Overload resolution will handle the case where `FWD_ITER` is a raw
2867 /// pointer, so we need handle only user-defined iterators. As `bslalg`
2868 /// is levelized below `bslstl` we cannot use `iterator_traits`, but
2869 /// rely on the same property as `iterator_traits` that this typedef
2870 /// must be defined for any standard-conforming iterator, unless the
2871 /// iterator explicitly specialized the `std::iterator_traits` template.
2872 /// In practice, iterators always prefer to provide the member typedef
2873 /// than specialize the traits as it is a much simpler implementation,
2874 /// so this assumption is good enough.
2875 ///
2876 /// Also note that as we know that `FWD_ITER` is not a pointer, then we
2877 /// cannot take advantage of bitwise copying as we do not have pointers
2878 /// to pass to the `memcpy` describing the whole range. It is not worth
2879 /// the effort to try to bitwise copy one element at a time.
2880 typedef typename FWD_ITER::value_type FwdTarget;
2881
2882 /// We want to detect the special case of copying function pointers to
2883 /// `void *` or `const void *` pointers.
2884 typedef typename bsl::remove_pointer<TargetType>::type RemovePtrTarget;
2885
2886 enum {
2887 k_ITER_TO_FUNC_PTRS = bslmf::IsFunctionPointer<FwdTarget>::value,
2888 k_TARGET_IS_VOID_PTR = bsl::is_pointer<TargetType>::value &&
2890
2891 k_VALUE = k_ITER_TO_FUNC_PTRS && k_TARGET_IS_VOID_PTR
2894 };
2895
2897 fromBegin,
2898 fromEnd,
2899 allocator,
2901}
2902
2903template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
2904inline
2905void ArrayPrimitives::copyConstruct(TARGET_TYPE *toBegin,
2906 FWD_ITER fromBegin,
2907 SENTINEL fromEnd,
2908 bslma::Allocator *basicAllocator)
2909{
2910 copyConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
2911 fromBegin,
2912 fromEnd,
2913 basicAllocator);
2914}
2915
2916template <class ALLOCATOR, class SOURCE_TYPE>
2917inline
2920 SOURCE_TYPE *fromBegin,
2921 SOURCE_TYPE *fromEnd,
2922 ALLOCATOR allocator)
2923{
2924 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
2925
2926 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2927
2928 enum {
2929 k_ARE_PTRS_TO_PTRS = bsl::is_pointer<TargetType>::value &&
2931 k_IS_BITWISECOPYABLE =
2933 k_VALUE = k_ARE_PTRS_TO_PTRS ? Imp::e_IS_POINTER_TO_POINTER
2934 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
2936 };
2937
2939 fromBegin,
2940 fromEnd,
2941 allocator,
2943}
2944
2945template <class TARGET_TYPE, class SOURCE_TYPE>
2946inline
2947void ArrayPrimitives::copyConstruct(TARGET_TYPE *toBegin,
2948 SOURCE_TYPE *fromBegin,
2949 SOURCE_TYPE *fromEnd,
2950 bslma::Allocator *basicAllocator)
2951{
2952 copyConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
2953 fromBegin,
2954 fromEnd,
2955 basicAllocator);
2956}
2957
2958template <class ALLOCATOR>
2959inline
2962 size_type numElements,
2963 ALLOCATOR allocator)
2964{
2966 BSLS_ASSERT_SAFE(begin || 0 == numElements);
2967
2968 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
2969
2970 enum {
2974#if !defined(BSLALG_ARRAYPRIMITIVES_NON_ZERO_NULL_VALUE_FOR_MEMBER_POINTERS)
2976#endif
2982 };
2984 begin,
2985 numElements,
2986 allocator,
2988}
2989
2990template <class TARGET_TYPE>
2991inline
2992void ArrayPrimitives::defaultConstruct(TARGET_TYPE *begin,
2993 size_type numElements,
2994 bslma::Allocator *basicAllocator)
2995{
2996 defaultConstruct<bsl::allocator<TARGET_TYPE> >(begin,
2997 numElements,
2998 basicAllocator);
2999}
3000
3001template <class ALLOCATOR>
3002inline
3007 ALLOCATOR allocator)
3008{
3009 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
3011
3012 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3013
3014 enum {
3018 };
3020 toBegin,
3021 fromBegin,
3022 fromEnd,
3023 allocator,
3025}
3026
3027template <class TARGET_TYPE>
3028inline
3029void ArrayPrimitives::destructiveMove(TARGET_TYPE *toBegin,
3030 TARGET_TYPE *fromBegin,
3031 TARGET_TYPE *fromEnd,
3032 bslma::Allocator *basicAllocator)
3033{
3034 destructiveMove<bsl::allocator<TARGET_TYPE> >(toBegin,
3035 fromBegin,
3036 fromEnd,
3037 basicAllocator);
3038}
3039
3040#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
3041// {{{ BEGIN GENERATED CODE
3042// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
3043#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
3044#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
3045#endif
3046#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D
3047#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
3048#endif
3049#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 0
3050template <class ALLOCATOR>
3053 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3057 ALLOCATOR allocator)
3058{
3059
3060 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3061
3062 *fromEndPtr = fromEnd;
3063
3064
3065 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3066
3068 allocator,
3069 toPositionBegin);
3070
3071 TargetType *toPositionEnd = toPositionBegin + 1;
3072
3073 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3074 toPositionEnd,
3075 allocator);
3076
3077
3078 destructiveMove(toPositionEnd,
3079 position,
3080 fromEnd,
3081 allocator);
3082
3083 *fromEndPtr = position;
3084 guard.moveEnd(fromEnd - position);
3085
3086
3087 destructiveMove(toBegin,
3088 fromBegin,
3089 position,
3090 allocator);
3091
3092 *fromEndPtr = fromBegin;
3093 guard.release();
3094}
3095#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 0
3096
3097#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 1
3098template <class ALLOCATOR, class ARGS_01>
3101 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3105 ALLOCATOR allocator,
3106 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01)
3107{
3108
3109 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3110
3111 *fromEndPtr = fromEnd;
3112
3113
3114 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3115
3117 allocator,
3118 toPositionBegin,
3119 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01));
3120
3121 TargetType *toPositionEnd = toPositionBegin + 1;
3122
3123 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3124 toPositionEnd,
3125 allocator);
3126
3127
3128 destructiveMove(toPositionEnd,
3129 position,
3130 fromEnd,
3131 allocator);
3132
3133 *fromEndPtr = position;
3134 guard.moveEnd(fromEnd - position);
3135
3136
3137 destructiveMove(toBegin,
3138 fromBegin,
3139 position,
3140 allocator);
3141
3142 *fromEndPtr = fromBegin;
3143 guard.release();
3144}
3145#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 1
3146
3147#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 2
3148template <class ALLOCATOR, class ARGS_01,
3149 class ARGS_02>
3152 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3156 ALLOCATOR allocator,
3157 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3158 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02)
3159{
3160
3161 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3162
3163 *fromEndPtr = fromEnd;
3164
3165
3166 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3167
3169 allocator,
3170 toPositionBegin,
3171 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3172 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02));
3173
3174 TargetType *toPositionEnd = toPositionBegin + 1;
3175
3176 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3177 toPositionEnd,
3178 allocator);
3179
3180
3181 destructiveMove(toPositionEnd,
3182 position,
3183 fromEnd,
3184 allocator);
3185
3186 *fromEndPtr = position;
3187 guard.moveEnd(fromEnd - position);
3188
3189
3190 destructiveMove(toBegin,
3191 fromBegin,
3192 position,
3193 allocator);
3194
3195 *fromEndPtr = fromBegin;
3196 guard.release();
3197}
3198#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 2
3199
3200#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 3
3201template <class ALLOCATOR, class ARGS_01,
3202 class ARGS_02,
3203 class ARGS_03>
3206 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3210 ALLOCATOR allocator,
3211 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3212 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3213 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03)
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
3230 TargetType *toPositionEnd = toPositionBegin + 1;
3231
3232 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3233 toPositionEnd,
3234 allocator);
3235
3236
3237 destructiveMove(toPositionEnd,
3238 position,
3239 fromEnd,
3240 allocator);
3241
3242 *fromEndPtr = position;
3243 guard.moveEnd(fromEnd - position);
3244
3245
3246 destructiveMove(toBegin,
3247 fromBegin,
3248 position,
3249 allocator);
3250
3251 *fromEndPtr = fromBegin;
3252 guard.release();
3253}
3254#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 3
3255
3256#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 4
3257template <class ALLOCATOR, class ARGS_01,
3258 class ARGS_02,
3259 class ARGS_03,
3260 class ARGS_04>
3263 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3267 ALLOCATOR allocator,
3268 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3269 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3270 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3271 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04)
3272{
3273
3274 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3275
3276 *fromEndPtr = fromEnd;
3277
3278
3279 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3280
3282 allocator,
3283 toPositionBegin,
3284 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3285 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3286 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3287 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04));
3288
3289 TargetType *toPositionEnd = toPositionBegin + 1;
3290
3291 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3292 toPositionEnd,
3293 allocator);
3294
3295
3296 destructiveMove(toPositionEnd,
3297 position,
3298 fromEnd,
3299 allocator);
3300
3301 *fromEndPtr = position;
3302 guard.moveEnd(fromEnd - position);
3303
3304
3305 destructiveMove(toBegin,
3306 fromBegin,
3307 position,
3308 allocator);
3309
3310 *fromEndPtr = fromBegin;
3311 guard.release();
3312}
3313#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 4
3314
3315#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 5
3316template <class ALLOCATOR, class ARGS_01,
3317 class ARGS_02,
3318 class ARGS_03,
3319 class ARGS_04,
3320 class ARGS_05>
3323 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3327 ALLOCATOR allocator,
3328 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3329 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3330 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3331 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3332 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05)
3333{
3334
3335 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3336
3337 *fromEndPtr = fromEnd;
3338
3339
3340 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3341
3343 allocator,
3344 toPositionBegin,
3345 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3346 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3347 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3348 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3349 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05));
3350
3351 TargetType *toPositionEnd = toPositionBegin + 1;
3352
3353 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3354 toPositionEnd,
3355 allocator);
3356
3357
3358 destructiveMove(toPositionEnd,
3359 position,
3360 fromEnd,
3361 allocator);
3362
3363 *fromEndPtr = position;
3364 guard.moveEnd(fromEnd - position);
3365
3366
3367 destructiveMove(toBegin,
3368 fromBegin,
3369 position,
3370 allocator);
3371
3372 *fromEndPtr = fromBegin;
3373 guard.release();
3374}
3375#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 5
3376
3377#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 6
3378template <class ALLOCATOR, class ARGS_01,
3379 class ARGS_02,
3380 class ARGS_03,
3381 class ARGS_04,
3382 class ARGS_05,
3383 class ARGS_06>
3386 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3390 ALLOCATOR allocator,
3391 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3392 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3393 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3394 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3395 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3396 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06)
3397{
3398
3399 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3400
3401 *fromEndPtr = fromEnd;
3402
3403
3404 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3405
3407 allocator,
3408 toPositionBegin,
3409 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3410 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3411 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3412 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3413 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3414 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06));
3415
3416 TargetType *toPositionEnd = toPositionBegin + 1;
3417
3418 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3419 toPositionEnd,
3420 allocator);
3421
3422
3423 destructiveMove(toPositionEnd,
3424 position,
3425 fromEnd,
3426 allocator);
3427
3428 *fromEndPtr = position;
3429 guard.moveEnd(fromEnd - position);
3430
3431
3432 destructiveMove(toBegin,
3433 fromBegin,
3434 position,
3435 allocator);
3436
3437 *fromEndPtr = fromBegin;
3438 guard.release();
3439}
3440#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 6
3441
3442#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 7
3443template <class ALLOCATOR, class ARGS_01,
3444 class ARGS_02,
3445 class ARGS_03,
3446 class ARGS_04,
3447 class ARGS_05,
3448 class ARGS_06,
3449 class ARGS_07>
3452 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3456 ALLOCATOR allocator,
3457 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3458 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3459 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3460 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3461 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3462 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3463 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07)
3464{
3465
3466 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3467
3468 *fromEndPtr = fromEnd;
3469
3470
3471 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3472
3474 allocator,
3475 toPositionBegin,
3476 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3477 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3478 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3479 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3480 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3481 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3482 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07));
3483
3484 TargetType *toPositionEnd = toPositionBegin + 1;
3485
3486 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3487 toPositionEnd,
3488 allocator);
3489
3490
3491 destructiveMove(toPositionEnd,
3492 position,
3493 fromEnd,
3494 allocator);
3495
3496 *fromEndPtr = position;
3497 guard.moveEnd(fromEnd - position);
3498
3499
3500 destructiveMove(toBegin,
3501 fromBegin,
3502 position,
3503 allocator);
3504
3505 *fromEndPtr = fromBegin;
3506 guard.release();
3507}
3508#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 7
3509
3510#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 8
3511template <class ALLOCATOR, class ARGS_01,
3512 class ARGS_02,
3513 class ARGS_03,
3514 class ARGS_04,
3515 class ARGS_05,
3516 class ARGS_06,
3517 class ARGS_07,
3518 class ARGS_08>
3521 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3525 ALLOCATOR allocator,
3526 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3527 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3528 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3529 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3530 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3531 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3532 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3533 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08)
3534{
3535
3536 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3537
3538 *fromEndPtr = fromEnd;
3539
3540
3541 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3542
3544 allocator,
3545 toPositionBegin,
3546 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3547 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3548 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3549 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3550 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3551 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3552 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3553 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08));
3554
3555 TargetType *toPositionEnd = toPositionBegin + 1;
3556
3557 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3558 toPositionEnd,
3559 allocator);
3560
3561
3562 destructiveMove(toPositionEnd,
3563 position,
3564 fromEnd,
3565 allocator);
3566
3567 *fromEndPtr = position;
3568 guard.moveEnd(fromEnd - position);
3569
3570
3571 destructiveMove(toBegin,
3572 fromBegin,
3573 position,
3574 allocator);
3575
3576 *fromEndPtr = fromBegin;
3577 guard.release();
3578}
3579#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 8
3580
3581#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 9
3582template <class ALLOCATOR, class ARGS_01,
3583 class ARGS_02,
3584 class ARGS_03,
3585 class ARGS_04,
3586 class ARGS_05,
3587 class ARGS_06,
3588 class ARGS_07,
3589 class ARGS_08,
3590 class ARGS_09>
3593 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3597 ALLOCATOR allocator,
3598 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3599 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3600 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3601 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3602 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3603 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3604 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3605 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
3606 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09)
3607{
3608
3609 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3610
3611 *fromEndPtr = fromEnd;
3612
3613
3614 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3615
3617 allocator,
3618 toPositionBegin,
3619 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3620 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3621 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3622 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3623 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3624 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3625 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3626 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08),
3627 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,arguments_09));
3628
3629 TargetType *toPositionEnd = toPositionBegin + 1;
3630
3631 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3632 toPositionEnd,
3633 allocator);
3634
3635
3636 destructiveMove(toPositionEnd,
3637 position,
3638 fromEnd,
3639 allocator);
3640
3641 *fromEndPtr = position;
3642 guard.moveEnd(fromEnd - position);
3643
3644
3645 destructiveMove(toBegin,
3646 fromBegin,
3647 position,
3648 allocator);
3649
3650 *fromEndPtr = fromBegin;
3651 guard.release();
3652}
3653#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 9
3654
3655#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 10
3656template <class ALLOCATOR, class ARGS_01,
3657 class ARGS_02,
3658 class ARGS_03,
3659 class ARGS_04,
3660 class ARGS_05,
3661 class ARGS_06,
3662 class ARGS_07,
3663 class ARGS_08,
3664 class ARGS_09,
3665 class ARGS_10>
3668 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3672 ALLOCATOR allocator,
3673 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) arguments_01,
3674 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) arguments_02,
3675 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) arguments_03,
3676 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) arguments_04,
3677 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) arguments_05,
3678 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) arguments_06,
3679 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) arguments_07,
3680 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) arguments_08,
3681 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) arguments_09,
3682 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) arguments_10)
3683{
3684
3685 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3686
3687 *fromEndPtr = fromEnd;
3688
3689
3690 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3691
3693 allocator,
3694 toPositionBegin,
3695 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,arguments_01),
3696 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,arguments_02),
3697 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,arguments_03),
3698 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,arguments_04),
3699 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,arguments_05),
3700 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,arguments_06),
3701 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,arguments_07),
3702 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,arguments_08),
3703 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,arguments_09),
3704 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,arguments_10));
3705
3706 TargetType *toPositionEnd = toPositionBegin + 1;
3707
3708 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3709 toPositionEnd,
3710 allocator);
3711
3712
3713 destructiveMove(toPositionEnd,
3714 position,
3715 fromEnd,
3716 allocator);
3717
3718 *fromEndPtr = position;
3719 guard.moveEnd(fromEnd - position);
3720
3721
3722 destructiveMove(toBegin,
3723 fromBegin,
3724 position,
3725 allocator);
3726
3727 *fromEndPtr = fromBegin;
3728 guard.release();
3729}
3730#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_D >= 10
3731
3732#else
3733// The generated code below is a workaround for the absence of perfect
3734// forwarding in some compilers.
3735template <class ALLOCATOR, class... ARGS>
3738 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3742 ALLOCATOR allocator,
3743 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS)... arguments)
3744{
3745
3746 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3747
3748 *fromEndPtr = fromEnd;
3749
3750
3751 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3752
3754 allocator,
3755 toPositionBegin,
3756 BSLS_COMPILERFEATURES_FORWARD(ARGS,arguments)...);
3757
3758 TargetType *toPositionEnd = toPositionBegin + 1;
3759
3760 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3761 toPositionEnd,
3762 allocator);
3763
3764
3765 destructiveMove(toPositionEnd,
3766 position,
3767 fromEnd,
3768 allocator);
3769
3770 *fromEndPtr = position;
3771 guard.moveEnd(fromEnd - position);
3772
3773
3774 destructiveMove(toBegin,
3775 fromBegin,
3776 position,
3777 allocator);
3778
3779 *fromEndPtr = fromBegin;
3780 guard.release();
3781}
3782// }}} END GENERATED CODE
3783#endif
3784
3785template <class ALLOCATOR>
3788 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3792 size_type numElements,
3793 ALLOCATOR allocator)
3794{
3795 // Key to the transformation diagrams:
3796 //..
3797 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3798 // v...v default-constructed values ("input")
3799 // ; ... contents of '[toBegin, toEnd)' ("destination")
3800 // ..:.. position of 'fromEndPtr' in the input
3801 // _____ uninitialized array elements
3802 // [...] part of array protected by an exception guard object
3803 //..
3804
3805 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3806
3807 *fromEndPtr = fromEnd;
3808
3809 // Note: Construct default values.
3810 //..
3811 // Transformation: ABCDEFGH: ; _____________[]
3812 // => ABCDEFGH: ; ____[vvvvv]____
3813 //..
3814
3815 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3816 defaultConstruct(toPositionBegin, numElements, allocator);
3817
3818 TargetType *toPositionEnd = toPositionBegin + numElements;
3819
3820 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3821 toPositionEnd,
3822 allocator);
3823
3824 //..
3825 // Transformation: ABCDEFGH: ; ____[vvvvv]____
3826 // => ABCD:____ ; ____[vvvvvEFGH]
3827 //..
3828
3829 destructiveMove(toPositionEnd,
3830 position,
3831 fromEnd,
3832 allocator);
3833
3834 *fromEndPtr = position; // shorten input range after partial destruction
3835 guard.moveEnd(fromEnd - position); // toEnd
3836
3837 //..
3838 // Transformation: ABCD:____ ; ____[vvvvvEFGH]
3839 // => :________ ; ABCDvvvvvEFGH[]
3840 //..
3841
3842 destructiveMove(toBegin,
3843 fromBegin,
3844 position,
3845 allocator);
3846
3847 *fromEndPtr = fromBegin; // empty input range after final destruction
3848 guard.release();
3849}
3850
3851template <class TARGET_TYPE>
3852inline
3854 TARGET_TYPE *toBegin,
3855 TARGET_TYPE **fromEndPtr,
3856 TARGET_TYPE *fromBegin,
3857 TARGET_TYPE *position,
3858 TARGET_TYPE *fromEnd,
3859 size_type numElements,
3860 bslma::Allocator *basicAllocator)
3861{
3862 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
3863 fromEndPtr,
3864 fromBegin,
3865 position,
3866 fromEnd,
3867 numElements,
3868 basicAllocator);
3869}
3870
3871template <class ALLOCATOR>
3874 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3879 size_type numElements,
3880 ALLOCATOR allocator)
3881{
3882 // Key to the transformation diagrams:
3883 //..
3884 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3885 // v...v copies of 'value' ("input")
3886 // ; ... contents of '[toBegin, toEnd)' ("destination")
3887 // ..:.. position of 'fromEndPtr' in the input
3888 // _____ uninitialized array elements
3889 // [...] part of array protected by an exception guard object
3890 //..
3891
3892 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3893
3894 *fromEndPtr = fromEnd;
3895
3896 // Note: Construct copies of 'value' first in case 'value' is a reference
3897 // in the input range, which would be invalidated by any of the following
3898 // moves.
3899 //
3900 //..
3901 // Transformation: ABCDEFGH: ; _____________[]
3902 // => ABCDEFGH: ; ____[vvvvv]____
3903 //..
3904
3905 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3906 uninitializedFillN(toPositionBegin, numElements, value, allocator);
3907
3908 TargetType *toPositionEnd = toPositionBegin + numElements;
3909
3910 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
3911 toPositionEnd,
3912 allocator);
3913
3914 //..
3915 // Transformation: ABCDEFGH: ; ____[vvvvv]____
3916 // => ABCD:____ ; ____[vvvvvEFGH]
3917 //..
3918
3919 destructiveMove(toPositionEnd,
3920 position,
3921 fromEnd,
3922 allocator);
3923
3924 *fromEndPtr = position; // shorten input range after partial destruction
3925 guard.moveEnd(fromEnd - position); // toEnd
3926
3927 //..
3928 // Transformation: ABCD:____ ; ____[vvvvvEFGH]
3929 // => :________ ; ABCDvvvvvEFGH[]
3930 //..
3931
3932 destructiveMove(toBegin,
3933 fromBegin,
3934 position,
3935 allocator);
3936
3937 *fromEndPtr = fromBegin; // empty input range after final destruction
3938 guard.release();
3939}
3940
3941template <class TARGET_TYPE>
3943 TARGET_TYPE *toBegin,
3944 TARGET_TYPE **fromEndPtr,
3945 TARGET_TYPE *fromBegin,
3946 TARGET_TYPE *position,
3947 TARGET_TYPE *fromEnd,
3948 const TARGET_TYPE& value,
3949 size_type numElements,
3950 bslma::Allocator *basicAllocator)
3951{
3952 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
3953 fromEndPtr,
3954 fromBegin,
3955 position,
3956 fromEnd,
3957 value,
3958 numElements,
3959 basicAllocator);
3960}
3961
3962template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
3965 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
3969 FWD_ITER first,
3970 SENTINEL last,
3971 size_type numElements,
3972 ALLOCATOR allocator)
3973{
3974 // Key to the transformation diagrams:
3975 //..
3976 // A...H original contents of '[fromBegin, fromEnd)' ("source")
3977 // t...z original contents of '[first, last)' ("input")
3978 // ; ... contents of '[toBegin, toEnd)' ("destination")
3979 // ..:.. position of 'fromEndPtr' in the input
3980 // _____ uninitialized array elements
3981 // [...] part of array protected by an exception guard object
3982 //..
3983
3984 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
3985
3986 *fromEndPtr = fromEnd;
3987
3988 // Note: Construct copies of 'value' first in case 'value' is a reference
3989 // in the input range, which would be invalidated by any of the following
3990 // moves:
3991 //..
3992 // Transformation: ABCDEFGH: ; _________[]____
3993 // => ABCDEFGH: ; ____[tuvxy]____
3994 //..
3995
3996 TargetType *toPositionBegin = toBegin + (position - fromBegin);
3997 copyConstruct(toPositionBegin, first, last, allocator);
3998
3999 TargetType *toPositionEnd = toPositionBegin + numElements;
4000
4001 AutoArrayDestructor<TargetType, ALLOCATOR> guard(toPositionBegin,
4002 toPositionEnd,
4003 allocator);
4004
4005 //..
4006 // Transformation: ABCDEFGH: ; ____[tuvxy]____
4007 // => ABCD:____ ; ____[tuvxyEFGH]
4008 //..
4009
4010 destructiveMove(toPositionEnd,
4011 position,
4012 fromEnd,
4013 allocator);
4014
4015 *fromEndPtr = position; // shorten input range after partial destruction
4016 guard.moveEnd(fromEnd - position); // toEnd
4017
4018 //..
4019 // Transformation: ABCD:____ ; ____[tuvxyEFGH]
4020 // => :________ ; ABCDtuvxyEFGH[]
4021 //..
4022
4023 destructiveMove(toBegin,
4024 fromBegin,
4025 position,
4026 allocator);
4027
4028 *fromEndPtr = fromBegin; // empty input range after final destruction
4029 guard.release();
4030}
4031
4032template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
4033inline
4035 TARGET_TYPE *toBegin,
4036 TARGET_TYPE **fromEndPtr,
4037 TARGET_TYPE *fromBegin,
4038 TARGET_TYPE *position,
4039 TARGET_TYPE *fromEnd,
4040 FWD_ITER first,
4041 SENTINEL last,
4042 size_type numElements,
4043 bslma::Allocator *basicAllocator)
4044{
4045 destructiveMoveAndInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
4046 fromEndPtr,
4047 fromBegin,
4048 position,
4049 fromEnd,
4050 first,
4051 last,
4052 numElements,
4053 basicAllocator);
4054}
4055
4056template <class ALLOCATOR>
4059 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
4066 size_type numElements,
4067 ALLOCATOR allocator)
4068{
4069 // Key to the transformation diagrams:
4070 //..
4071 // A...H original contents of '[fromBegin, fromEnd)' ("source")
4072 // t...z original contents of '[first, last)' ("input")
4073 // ; ... contents of '[toBegin, toEnd)' ("destination")
4074 // ..:.. position of 'fromEndPtr' in the input
4075 // _____ uninitialized array elements
4076 // [...] part of array protected by an exception guard object
4077 //..
4078
4079 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4080
4081 *lastPtr = last;
4082 *fromEndPtr = fromEnd;
4083
4084 //..
4085 // Transformation: ABCDEFGH: ; _____________[]
4086 // => ABCD:____ ; _________[EFGH]
4087 //..
4088
4089 TargetType *toPositionBegin = toBegin + (position - fromBegin);
4090 TargetType *toPositionEnd = toPositionBegin + numElements;
4091
4092 destructiveMove(toPositionEnd,
4093 position,
4094 fromEnd,
4095 allocator);
4096
4097 *fromEndPtr = position; // shorten input range after partial destruction
4098
4099 AutoArrayDestructor<TargetType, ALLOCATOR>
4100 guard(toPositionEnd,
4101 toPositionEnd + (fromEnd - position),
4102 allocator);
4103
4104 //..
4105 // Transformation: ABCD:____ ; _________[EFGH]
4106 // => ABCD:____ ; _____[tuvwEFGH]
4107 //..
4108
4109 destructiveMove(toPositionBegin,
4110 first,
4111 last,
4112 allocator);
4113
4114 *lastPtr = first;
4115 guard.moveBegin(-static_cast<difference_type>(numElements));
4116
4117 //..
4118 // Transformation: ABCD:____ ; ____[tuvwEFGH]
4119 // => :________ ; ABCDtuvwEFGH[]
4120 //..
4121
4122 destructiveMove(toBegin,
4123 fromBegin,
4124 position,
4125 allocator);
4126
4127 *fromEndPtr = fromBegin; // empty input range after final destruction
4128 guard.release();
4129}
4130
4131template <class TARGET_TYPE>
4132inline
4134 TARGET_TYPE *toBegin,
4135 TARGET_TYPE **fromEndPtr,
4136 TARGET_TYPE **lastPtr,
4137 TARGET_TYPE *fromBegin,
4138 TARGET_TYPE *position,
4139 TARGET_TYPE *fromEnd,
4140 TARGET_TYPE *first,
4141 TARGET_TYPE *last,
4142 size_type numElements,
4143 bslma::Allocator *basicAllocator)
4144{
4145 destructiveMoveAndMoveInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
4146 fromEndPtr,
4147 lastPtr,
4148 fromBegin,
4149 position,
4150 fromEnd,
4151 first,
4152 last,
4153 numElements,
4154 basicAllocator);
4155}
4156
4157#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
4158// {{{ BEGIN GENERATED CODE
4159// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
4160#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
4161#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
4162#endif
4163#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E
4164#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
4165#endif
4166#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4167template <class ALLOCATOR>
4168inline
4172 ALLOCATOR allocator)
4173{
4175 toEnd));
4177
4178 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4179
4180 enum {
4186 };
4187
4189 toBegin,
4190 toEnd,
4191 allocator,
4193}
4194#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4195
4196#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4197template <class ALLOCATOR, class ARGS_01>
4198inline
4202 ALLOCATOR allocator,
4203 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
4204{
4206 toEnd));
4208
4209 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4210
4211 enum {
4217 };
4218
4220 toBegin,
4221 toEnd,
4222 allocator,
4224 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
4225}
4226#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4227
4228#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4229template <class ALLOCATOR, class ARGS_01,
4230 class ARGS_02>
4231inline
4235 ALLOCATOR allocator,
4236 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4237 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
4238{
4240 toEnd));
4242
4243 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4244
4245 enum {
4251 };
4252
4254 toBegin,
4255 toEnd,
4256 allocator,
4258 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4259 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
4260}
4261#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4262
4263#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4264template <class ALLOCATOR, class ARGS_01,
4265 class ARGS_02,
4266 class ARGS_03>
4267inline
4271 ALLOCATOR allocator,
4272 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4273 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4274 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
4275{
4277 toEnd));
4279
4280 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4281
4282 enum {
4288 };
4289
4291 toBegin,
4292 toEnd,
4293 allocator,
4295 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4296 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4297 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
4298}
4299#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4300
4301#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4302template <class ALLOCATOR, class ARGS_01,
4303 class ARGS_02,
4304 class ARGS_03,
4305 class ARGS_04>
4306inline
4310 ALLOCATOR allocator,
4311 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4312 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4313 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4314 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
4315{
4317 toEnd));
4319
4320 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4321
4322 enum {
4328 };
4329
4331 toBegin,
4332 toEnd,
4333 allocator,
4335 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4336 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4337 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4338 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
4339}
4340#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4341
4342#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4343template <class ALLOCATOR, class ARGS_01,
4344 class ARGS_02,
4345 class ARGS_03,
4346 class ARGS_04,
4347 class ARGS_05>
4348inline
4352 ALLOCATOR allocator,
4353 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4354 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4355 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4356 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4357 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
4358{
4360 toEnd));
4362
4363 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4364
4365 enum {
4371 };
4372
4374 toBegin,
4375 toEnd,
4376 allocator,
4378 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4379 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4380 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4381 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4382 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
4383}
4384#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4385
4386#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4387template <class ALLOCATOR, class ARGS_01,
4388 class ARGS_02,
4389 class ARGS_03,
4390 class ARGS_04,
4391 class ARGS_05,
4392 class ARGS_06>
4393inline
4397 ALLOCATOR allocator,
4398 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4399 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4400 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4401 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4402 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
4404{
4406 toEnd));
4408
4409 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4410
4411 enum {
4417 };
4418
4420 toBegin,
4421 toEnd,
4422 allocator,
4424 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4425 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4426 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4427 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4428 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4429 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
4430}
4431#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4432
4433#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4434template <class ALLOCATOR, class ARGS_01,
4435 class ARGS_02,
4436 class ARGS_03,
4437 class ARGS_04,
4438 class ARGS_05,
4439 class ARGS_06,
4440 class ARGS_07>
4441inline
4445 ALLOCATOR allocator,
4446 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4447 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4448 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4449 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4450 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4451 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4452 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
4453{
4455 toEnd));
4457
4458 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4459
4460 enum {
4466 };
4467
4469 toBegin,
4470 toEnd,
4471 allocator,
4473 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4474 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4475 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4476 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4477 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4478 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4479 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
4480}
4481#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4482
4483#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4484template <class ALLOCATOR, class ARGS_01,
4485 class ARGS_02,
4486 class ARGS_03,
4487 class ARGS_04,
4488 class ARGS_05,
4489 class ARGS_06,
4490 class ARGS_07,
4491 class ARGS_08>
4492inline
4496 ALLOCATOR allocator,
4497 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4498 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4499 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4500 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4501 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4502 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4503 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4504 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
4505{
4507 toEnd));
4509
4510 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4511
4512 enum {
4518 };
4519
4521 toBegin,
4522 toEnd,
4523 allocator,
4525 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4526 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4527 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4528 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4529 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4530 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4531 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4532 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
4533}
4534#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4535
4536#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4537template <class ALLOCATOR, class ARGS_01,
4538 class ARGS_02,
4539 class ARGS_03,
4540 class ARGS_04,
4541 class ARGS_05,
4542 class ARGS_06,
4543 class ARGS_07,
4544 class ARGS_08,
4545 class ARGS_09>
4546inline
4550 ALLOCATOR allocator,
4551 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4552 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4553 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4554 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4555 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4556 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4557 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4558 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4559 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
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}
4590#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4591
4592#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4593template <class ALLOCATOR, class ARGS_01,
4594 class ARGS_02,
4595 class ARGS_03,
4596 class ARGS_04,
4597 class ARGS_05,
4598 class ARGS_06,
4599 class ARGS_07,
4600 class ARGS_08,
4601 class ARGS_09,
4602 class ARGS_10>
4603inline
4607 ALLOCATOR allocator,
4608 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4609 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4610 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4611 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4612 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4613 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4614 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4615 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4616 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
4617 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
4618{
4620 toEnd));
4622
4623 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4624
4625 enum {
4631 };
4632
4634 toBegin,
4635 toEnd,
4636 allocator,
4638 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4639 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4640 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4641 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4642 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4643 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4644 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4645 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4646 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
4647 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
4648}
4649#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4650
4651
4652#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4653template <class TARGET_TYPE>
4654inline
4655void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4656 TARGET_TYPE *toEnd,
4657 bslma::Allocator *basicAllocator)
4658{
4659 emplace<bsl::allocator<TARGET_TYPE> >(
4660 toBegin,
4661 toEnd,
4662 basicAllocator);
4663}
4664#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 0
4665
4666#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4667template <class TARGET_TYPE, class ARGS_01>
4668inline
4669void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4670 TARGET_TYPE *toEnd,
4671 bslma::Allocator *basicAllocator,
4672 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
4673{
4674 emplace<bsl::allocator<TARGET_TYPE> >(
4675 toBegin,
4676 toEnd,
4677 basicAllocator,
4678 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
4679}
4680#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 1
4681
4682#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4683template <class TARGET_TYPE, class ARGS_01,
4684 class ARGS_02>
4685inline
4686void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4687 TARGET_TYPE *toEnd,
4688 bslma::Allocator *basicAllocator,
4689 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4690 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
4691{
4692 emplace<bsl::allocator<TARGET_TYPE> >(
4693 toBegin,
4694 toEnd,
4695 basicAllocator,
4696 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4697 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
4698}
4699#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 2
4700
4701#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4702template <class TARGET_TYPE, class ARGS_01,
4703 class ARGS_02,
4704 class ARGS_03>
4705inline
4706void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4707 TARGET_TYPE *toEnd,
4708 bslma::Allocator *basicAllocator,
4709 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4710 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4711 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
4712{
4713 emplace<bsl::allocator<TARGET_TYPE> >(
4714 toBegin,
4715 toEnd,
4716 basicAllocator,
4717 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4718 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4719 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
4720}
4721#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 3
4722
4723#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4724template <class TARGET_TYPE, class ARGS_01,
4725 class ARGS_02,
4726 class ARGS_03,
4727 class ARGS_04>
4728inline
4729void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4730 TARGET_TYPE *toEnd,
4731 bslma::Allocator *basicAllocator,
4732 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4733 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4734 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4735 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
4736{
4737 emplace<bsl::allocator<TARGET_TYPE> >(
4738 toBegin,
4739 toEnd,
4740 basicAllocator,
4741 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4742 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4743 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4744 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
4745}
4746#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 4
4747
4748#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4749template <class TARGET_TYPE, class ARGS_01,
4750 class ARGS_02,
4751 class ARGS_03,
4752 class ARGS_04,
4753 class ARGS_05>
4754inline
4755void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4756 TARGET_TYPE *toEnd,
4757 bslma::Allocator *basicAllocator,
4758 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4759 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4760 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4761 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4762 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
4763{
4764 emplace<bsl::allocator<TARGET_TYPE> >(
4765 toBegin,
4766 toEnd,
4767 basicAllocator,
4768 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4769 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4770 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4771 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4772 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
4773}
4774#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 5
4775
4776#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4777template <class TARGET_TYPE, class ARGS_01,
4778 class ARGS_02,
4779 class ARGS_03,
4780 class ARGS_04,
4781 class ARGS_05,
4782 class ARGS_06>
4783inline
4784void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4785 TARGET_TYPE *toEnd,
4786 bslma::Allocator *basicAllocator,
4787 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4788 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4789 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4790 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4791 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4792 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
4793{
4794 emplace<bsl::allocator<TARGET_TYPE> >(
4795 toBegin,
4796 toEnd,
4797 basicAllocator,
4798 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4799 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4800 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4801 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4802 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4803 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
4804}
4805#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 6
4806
4807#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4808template <class TARGET_TYPE, class ARGS_01,
4809 class ARGS_02,
4810 class ARGS_03,
4811 class ARGS_04,
4812 class ARGS_05,
4813 class ARGS_06,
4814 class ARGS_07>
4815inline
4816void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4817 TARGET_TYPE *toEnd,
4818 bslma::Allocator *basicAllocator,
4819 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4820 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4821 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4822 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4823 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4824 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4825 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
4826{
4827 emplace<bsl::allocator<TARGET_TYPE> >(
4828 toBegin,
4829 toEnd,
4830 basicAllocator,
4831 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4832 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4833 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4834 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4835 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4836 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4837 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
4838}
4839#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 7
4840
4841#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4842template <class TARGET_TYPE, class ARGS_01,
4843 class ARGS_02,
4844 class ARGS_03,
4845 class ARGS_04,
4846 class ARGS_05,
4847 class ARGS_06,
4848 class ARGS_07,
4849 class ARGS_08>
4850inline
4851void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4852 TARGET_TYPE *toEnd,
4853 bslma::Allocator *basicAllocator,
4854 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4855 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4856 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4857 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4858 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4859 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4860 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
4862{
4863 emplace<bsl::allocator<TARGET_TYPE> >(
4864 toBegin,
4865 toEnd,
4866 basicAllocator,
4867 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4868 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4869 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4870 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4871 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4872 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4873 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4874 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
4875}
4876#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 8
4877
4878#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4879template <class TARGET_TYPE, class ARGS_01,
4880 class ARGS_02,
4881 class ARGS_03,
4882 class ARGS_04,
4883 class ARGS_05,
4884 class ARGS_06,
4885 class ARGS_07,
4886 class ARGS_08,
4887 class ARGS_09>
4888inline
4889void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4890 TARGET_TYPE *toEnd,
4891 bslma::Allocator *basicAllocator,
4892 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4893 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4894 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4895 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4896 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4897 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4898 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4899 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4900 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
4901{
4902 emplace<bsl::allocator<TARGET_TYPE> >(
4903 toBegin,
4904 toEnd,
4905 basicAllocator,
4906 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4907 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4908 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4909 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4910 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4911 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4912 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4913 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4914 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
4915}
4916#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 9
4917
4918#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4919template <class TARGET_TYPE, class ARGS_01,
4920 class ARGS_02,
4921 class ARGS_03,
4922 class ARGS_04,
4923 class ARGS_05,
4924 class ARGS_06,
4925 class ARGS_07,
4926 class ARGS_08,
4927 class ARGS_09,
4928 class ARGS_10>
4929inline
4930void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4931 TARGET_TYPE *toEnd,
4932 bslma::Allocator *basicAllocator,
4933 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
4934 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
4935 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
4936 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
4937 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
4938 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
4939 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
4940 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
4941 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
4942 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
4943{
4944 emplace<bsl::allocator<TARGET_TYPE> >(
4945 toBegin,
4946 toEnd,
4947 basicAllocator,
4948 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
4949 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
4950 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
4951 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
4952 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
4953 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
4954 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
4955 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
4956 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
4957 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
4958}
4959#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_E >= 10
4960
4961#else
4962// The generated code below is a workaround for the absence of perfect
4963// forwarding in some compilers.
4964template <class ALLOCATOR, class... ARGS>
4965inline
4969 ALLOCATOR allocator,
4971{
4973 toEnd));
4975
4976 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
4977
4978 enum {
4984 };
4985
4987 toBegin,
4988 toEnd,
4989 allocator,
4991 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
4992}
4993
4994template <class TARGET_TYPE, class... ARGS>
4995inline
4996void ArrayPrimitives::emplace(TARGET_TYPE *toBegin,
4997 TARGET_TYPE *toEnd,
4998 bslma::Allocator *basicAllocator,
5000{
5001 emplace<bsl::allocator<TARGET_TYPE> >(
5002 toBegin,
5003 toEnd,
5004 basicAllocator,
5005 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
5006}
5007
5008// }}} END GENERATED CODE
5009#endif
5010
5011template <class ALLOCATOR>
5012inline
5017 ALLOCATOR allocator)
5018{
5021
5022 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5023
5024 if (first == middle) { // erasing empty range O(1) versus O(N): Do not
5025 // remove!
5026 return; // RETURN
5027 }
5028
5029 enum {
5033 };
5035 middle,
5036 last,
5037 allocator,
5039}
5040
5041template <class TARGET_TYPE>
5042inline
5043void ArrayPrimitives::erase(TARGET_TYPE *first,
5044 TARGET_TYPE *middle,
5045 TARGET_TYPE *last,
5046 bslma::Allocator *basicAllocator)
5047{
5048 erase<bsl::allocator<TARGET_TYPE> >(first,
5049 middle,
5050 last,
5051 basicAllocator);
5052}
5053
5054template <class ALLOCATOR>
5055inline
5061 ALLOCATOR allocator)
5062{
5065
5066 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5067
5068 if (toBegin != toEnd) {
5069 // Insert in the middle. Note that there is no strong exception
5070 // guarantee if copy constructor, move constructor, or assignment
5071 // operator throw.
5072
5073 enum {
5079 };
5080
5082 toBegin,
5083 toEnd,
5085 allocator,
5087 }
5088 else { // toBegin == toEnd
5090 allocator, toBegin, bslmf::MovableRefUtil::move(value));
5091 }
5092}
5093
5094template <class TARGET_TYPE>
5095inline
5096void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5097 TARGET_TYPE *toEnd,
5099 bslma::Allocator *basicAllocator)
5100{
5101 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5102 toEnd,
5104 basicAllocator);
5105}
5106
5107template <class ALLOCATOR>
5112 size_type numElements,
5113 ALLOCATOR allocator)
5114{
5117
5118 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5119
5120 if (0 == numElements) {
5121 return; // RETURN
5122 }
5123
5124 enum {
5130 };
5132 toEnd,
5133 value,
5134 numElements,
5135 allocator,
5137}
5138
5139template <class TARGET_TYPE>
5140inline
5141void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5142 TARGET_TYPE *toEnd,
5143 const TARGET_TYPE& value,
5144 size_type numElements,
5145 bslma::Allocator *basicAllocator)
5146{
5147 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5148 toEnd,
5149 value,
5150 numElements,
5151 basicAllocator);
5152}
5153
5154template <class ALLOCATOR, class FWD_ITER, class SENTINEL>
5158 FWD_ITER fromBegin,
5159 SENTINEL fromEnd,
5160 size_type numElements,
5161 ALLOCATOR allocator)
5162{
5163 if (0 == numElements) {
5164 return; // RETURN
5165 }
5166
5167 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5168
5170
5171 /// Overload resolution will handle the case where `FWD_ITER` is a raw
5172 /// pointer, so we need handle only user-defined iterators. As `bslalg`
5173 /// is levelized below `bslstl` we cannot use `iterator_traits`, but
5174 /// rely on the same property as `iterator_traits` that this typedef
5175 /// must be defined for any standard-conforming iterator, unless the
5176 /// iterator explicitly specialized the `std::iterator_traits` template.
5177 /// In practice, iterators always prefer to provide the member typedef
5178 /// than specialize the traits as it is a much simpler implementation,
5179 /// so this assumption is good enough.
5180 ///
5181 /// Also note that as we know that `FWD_ITER` is not a pointer, then we
5182 /// cannot take advantage of bitwise copying as we do not have pointers
5183 /// to pass to the `memcpy` describing the whole range. It is not worth
5184 /// the effort to try to bitwise copy one element at a time.
5185 typedef typename FWD_ITER::value_type FwdTarget;
5186
5187 /// We want to detect the special case of copying function pointers to
5188 /// `void *` or `const void *` pointers.
5189 typedef typename bsl::remove_pointer<TargetType>::type RemovePtrTarget;
5190
5191 enum {
5192 k_ITER_TO_FUNC_PTRS = bslmf::IsFunctionPointer<FwdTarget>::value,
5193 k_TARGET_IS_VOID_PTR = bsl::is_pointer<TargetType>::value &&
5195
5196 k_VALUE = k_ITER_TO_FUNC_PTRS && k_TARGET_IS_VOID_PTR
5199 };
5201 toEnd,
5202 fromBegin,
5203 fromEnd,
5204 numElements,
5205 allocator,
5207}
5208
5209template <class TARGET_TYPE, class FWD_ITER, class SENTINEL>
5210inline
5211void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5212 TARGET_TYPE *toEnd,
5213 FWD_ITER fromBegin,
5214 SENTINEL fromEnd,
5215 size_type numElements,
5216 bslma::Allocator *basicAllocator)
5217{
5218 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5219 toEnd,
5220 fromBegin,
5221 fromEnd,
5222 numElements,
5223 basicAllocator);
5224}
5225
5226template <class ALLOCATOR, class SOURCE_TYPE>
5230 SOURCE_TYPE *fromBegin,
5231 SOURCE_TYPE *fromEnd,
5232 size_type numElements,
5233 ALLOCATOR allocator)
5234{
5235 if (0 == numElements) {
5236 return; // RETURN
5237 }
5238
5239 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5240
5241 enum {
5242 k_ARE_PTRS_TO_PTRS = bsl::is_pointer<TargetType>::value &&
5244 k_IS_BITWISEMOVEABLE = bslmf::IsBitwiseMoveable<TargetType>::value,
5245 k_IS_BITWISECOPYABLE =
5247 k_VALUE = k_ARE_PTRS_TO_PTRS ? Imp::e_IS_POINTER_TO_POINTER
5248 : k_IS_BITWISECOPYABLE ? Imp::e_BITWISE_COPYABLE_TRAITS
5249 : k_IS_BITWISEMOVEABLE ? Imp::e_BITWISE_MOVEABLE_TRAITS
5251 };
5253 toEnd,
5254 fromBegin,
5255 fromEnd,
5256 numElements,
5257 allocator,
5259}
5260
5261template <class TARGET_TYPE, class SOURCE_TYPE>
5262inline
5263void ArrayPrimitives::insert(TARGET_TYPE *toBegin,
5264 TARGET_TYPE *toEnd,
5265 SOURCE_TYPE *fromBegin,
5266 SOURCE_TYPE *fromEnd,
5267 size_type numElements,
5268 bslma::Allocator *basicAllocator)
5269{
5270 insert<bsl::allocator<TARGET_TYPE> >(toBegin,
5271 toEnd,
5272 fromBegin,
5273 fromEnd,
5274 numElements,
5275 basicAllocator);
5276}
5277
5278template <class ALLOCATOR>
5279inline
5284 ALLOCATOR allocator)
5285{
5286 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5287
5288 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5289
5290 enum {
5294 };
5295
5297 fromBegin,
5298 fromEnd,
5299 allocator,
5301}
5302
5303template <class TARGET_TYPE>
5304inline
5305void ArrayPrimitives::moveConstruct(TARGET_TYPE *toBegin,
5306 TARGET_TYPE *fromBegin,
5307 TARGET_TYPE *fromEnd,
5308 bslma::Allocator *basicAllocator)
5309{
5310 moveConstruct<bsl::allocator<TARGET_TYPE> >(toBegin,
5311 fromBegin,
5312 fromEnd,
5313 basicAllocator);
5314}
5315
5316template <class ALLOCATOR>
5317inline
5321 typename bsl::allocator_traits<ALLOCATOR>::pointer *fromEndPtr,
5324 size_type numElements,
5325 ALLOCATOR allocator)
5326{
5327 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type TargetType;
5328
5329 enum {
5333 };
5335 toEnd,
5336 fromEndPtr,
5337 fromBegin,
5338 fromEnd,
5339 numElements,
5340 allocator,
5342}
5343
5344template <class TARGET_TYPE>
5345inline
5346void ArrayPrimitives::moveInsert(TARGET_TYPE *toBegin,
5347 TARGET_TYPE *toEnd,
5348 TARGET_TYPE **fromEndPtr,
5349 TARGET_TYPE *fromBegin,
5350 TARGET_TYPE *fromEnd,
5351 size_type numElements,
5352 bslma::Allocator *basicAllocator)
5353{
5354 moveInsert<bsl::allocator<TARGET_TYPE> >(toBegin,
5355 toEnd,
5356 fromEndPtr,
5357 fromBegin,
5358 fromEnd,
5359 numElements,
5360 basicAllocator);
5361}
5362
5363template <class TARGET_TYPE>
5364inline
5365void ArrayPrimitives::rotate(TARGET_TYPE *first,
5366 TARGET_TYPE *middle,
5367 TARGET_TYPE *last)
5368{
5370 middle));
5372 last));
5373
5374 enum {
5378 };
5380 middle,
5381 last,
5383}
5384
5385 // --------------------------
5386 // struct ArrayPrimitives_Imp
5387 // --------------------------
5388
5389// CLASS METHODS
5390template <class TARGET_TYPE>
5391inline
5392void ArrayPrimitives_Imp::assign(TARGET_TYPE *srcStart,
5393 TARGET_TYPE *srcEnd,
5394 TARGET_TYPE& value)
5395{
5396 for ( ; srcStart != srcEnd; ++srcStart) {
5397 *srcStart = value;
5398 }
5399}
5400
5401template <class FORWARD_ITERATOR, class SENTINEL>
5402inline
5403bool ArrayPrimitives_Imp::isInvalidRange(FORWARD_ITERATOR, SENTINEL)
5404{
5405 // Ideally would dispatch on random_access_iterator_tag to support
5406 // generalized random access iterators, but we are constrained by 'bsl'
5407 // levelization to not depend on 'bsl_iterator.h'. As the intent is to
5408 // detect invalid ranges in assertions, the conservative choice is to
5409 // return 'false' always. Note that this differs from the pointers case
5410 // below, which also disallows empty ranges.
5411
5412 return false;
5413}
5414
5415template <class TARGET_TYPE>
5416inline
5417bool ArrayPrimitives_Imp::isInvalidRange(TARGET_TYPE *begin,
5418 TARGET_TYPE *end)
5419{
5420 return !begin != !end || begin > end;
5421}
5422
5423template <class TARGET_TYPE>
5424inline
5425void ArrayPrimitives_Imp::reverseAssign(TARGET_TYPE *dest,
5426 TARGET_TYPE *srcStart,
5427 TARGET_TYPE *srcEnd)
5428{
5429 TARGET_TYPE *destEnd = srcEnd - srcStart + dest;
5430 while (srcStart != srcEnd) {
5431 *--destEnd = *--srcEnd;
5432 }
5433}
5434
5435
5436 // *** 'uninitializedFillN' overloads: ***
5437
5438inline
5440 bool *begin,
5441 bool value,
5442 size_type numElements,
5443 void *,
5445{
5446 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5448 BSLMF_ASSERT(sizeof(bool) == 1);
5449
5450 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5451 std::memset(reinterpret_cast<char *>(begin), // odd, why not 'void *'?
5452 static_cast<char>(value),
5453 numElements);
5454 }
5455}
5456
5457inline
5459 char *begin,
5460 char value,
5461 size_type numElements,
5462 void *,
5464{
5465 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5467
5468 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5469 std::memset(begin, value, numElements);
5470 }
5471}
5472
5473inline
5475 unsigned char *begin,
5476 unsigned char value,
5477 size_type numElements,
5478 void *,
5480{
5481 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5483
5484 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5485 std::memset(begin, value, numElements);
5486 }
5487}
5488
5489inline
5491 signed char *begin,
5492 signed char value,
5493 size_type numElements,
5494 void *,
5496{
5497 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5499
5500 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5501 std::memset(begin, value, numElements);
5502 }
5503}
5504
5505inline
5507 wchar_t *begin,
5508 wchar_t value,
5509 size_type numElements,
5510 void *,
5512{
5513 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5515
5516 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5517 std::wmemset(begin, value, numElements);
5518 }
5519}
5520
5521inline
5523 unsigned short *begin,
5524 unsigned short value,
5525 size_type numElements,
5526 void *,
5528{
5529 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5531
5533 reinterpret_cast<short *>(begin),
5534 static_cast<short>(value),
5535 numElements,
5536 (void *)0,
5538}
5539
5540inline
5542 unsigned int *begin,
5543 unsigned int value,
5544 size_type numElements,
5545 void *,
5547{
5548 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5550
5552 reinterpret_cast<int *>(begin),
5553 static_cast<int>(value),
5554 numElements,
5555 (void *)0,
5557}
5558
5559inline
5561 long *begin,
5562 long value,
5563 size_type numElements,
5564 void *,
5566{
5567 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5569
5570#if defined(BSLS_PLATFORM_CPU_64_BIT) && !defined(BSLS_PLATFORM_OS_WINDOWS)
5571 uninitializedFillN(reinterpret_cast<bsls::Types::Int64 *>(begin),
5572 static_cast<bsls::Types::Int64>(value),
5573 numElements);
5574#else
5576 reinterpret_cast<int *>(begin),
5577 static_cast<int>(value),
5578 numElements,
5579 (void *)0,
5581#endif
5582}
5583
5584inline
5586 unsigned long *begin,
5587 unsigned long value,
5588 size_type numElements,
5589 void *,
5591{
5592 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5594
5595#if defined(BSLS_PLATFORM_CPU_64_BIT) && !defined(BSLS_PLATFORM_OS_WINDOWS)
5597 reinterpret_cast<bsls::Types::Int64 *>(begin),
5598 static_cast<bsls::Types::Int64>(value),
5599 numElements,
5600 (void *)0,
5602#else
5604 reinterpret_cast<int *>(begin),
5605 static_cast<int>(value),
5606 numElements,
5607 (void *)0,
5609#endif
5610}
5611
5612inline
5614 bsls::Types::Uint64 *begin,
5615 bsls::Types::Uint64 value,
5616 size_type numElements,
5617 void *,
5619{
5620 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5622
5624 reinterpret_cast<bsls::Types::Int64 *>(begin),
5625 value,
5626 numElements,
5627 (void *)0,
5629}
5630
5631template <class TARGET_TYPE>
5632inline
5634 TARGET_TYPE **begin,
5635 TARGET_TYPE *value,
5636 size_type numElements,
5637 void *,
5639{
5640 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5642
5643 // Note: 'const'-correctness is respected because the next overload picks
5644 // up the 'const TARGET_TYPE' and will be a better match. Note that we
5645 // cannot cast to 'const void **' (one would have to add 'const' at every
5646 // level, not just the innermost; i.e., 'const void *const *' would be
5647 // correct, 'const void **' is not [C++ Standard, 4.4 Qualification
5648 // conversions]).
5649
5651 reinterpret_cast<void **>(begin),
5652 static_cast<void *>(value),
5653 numElements,
5654 (void *)0,
5656}
5657
5658template <class TARGET_TYPE>
5659inline
5661 const TARGET_TYPE **begin,
5662 const TARGET_TYPE *value,
5663 size_type numElements,
5664 void *,
5666{
5667 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5669
5670 // While it seems that this overload is subsumed by the previous template,
5671 // SunPro does not detect it.
5672
5674 reinterpret_cast<const void **>(begin),
5675 static_cast<const void *>(value),
5676 numElements,
5677 (void *)0,
5679}
5680
5681template <class TARGET_TYPE>
5682inline
5684 volatile TARGET_TYPE **begin,
5685 volatile TARGET_TYPE *value,
5686 size_type numElements,
5687 void *,
5689{
5690 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5692
5693 // While it seems that this overload is subsumed by the previous template,
5694 // SunPro does not detect it.
5695
5697 reinterpret_cast<volatile void **>(begin),
5698 static_cast<volatile void *>(value),
5699 numElements,
5700 (void *)0,
5702}
5703
5704template <class TARGET_TYPE>
5705inline
5707 const volatile TARGET_TYPE **begin,
5708 const volatile TARGET_TYPE *value,
5709 size_type numElements,
5710 void *,
5712{
5713 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5715
5716 // While it seems that this overload is subsumed by the previous template,
5717 // SunPro does not detect it.
5718
5720 reinterpret_cast<const volatile void **>(begin),
5721 static_cast<const volatile void *>(value),
5722 numElements,
5723 (void *)0,
5725}
5726
5727template <class TARGET_TYPE, class ALLOCATOR>
5729 TARGET_TYPE *begin,
5730 const TARGET_TYPE& value,
5731 size_type numElements,
5732 ALLOCATOR *,
5734{
5735 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5737
5738 if (0 == numElements) {
5739 return; // RETURN
5740 }
5741
5742 const char *valueBuffer =
5743 reinterpret_cast<const char *>(BSLS_UTIL_ADDRESSOF(value));
5744
5745 std::memcpy((void *)begin, valueBuffer, sizeof(TARGET_TYPE));
5746 bitwiseFillN(reinterpret_cast<char *>(begin),
5747 sizeof(TARGET_TYPE),
5748 sizeof(TARGET_TYPE) * numElements);
5749}
5750
5751template <class TARGET_TYPE, class ALLOCATOR>
5753 TARGET_TYPE *begin,
5754 const TARGET_TYPE& value,
5755 size_type numElements,
5756 ALLOCATOR *allocator,
5758{
5759 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5761 BSLS_ASSERT_SAFE(allocator);
5762
5763 if (0 == numElements) {
5764 return; // RETURN
5765 }
5766 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(begin,
5767 begin,
5768 *allocator);
5769
5770 TARGET_TYPE *end = begin + numElements;
5771 do {
5772 bsl::allocator_traits<ALLOCATOR>::construct(*allocator, begin, value);
5773 begin = guard.moveEnd(1);
5774 } while (begin != end);
5775 guard.release();
5776}
5777
5778 // *** 'copyConstruct' overloads: ***
5779
5780template <class TARGET_TYPE, class FWD_ITER, class SENTINEL, class ALLOCATOR>
5781inline
5783 TARGET_TYPE *toBegin,
5784 FWD_ITER fromBegin,
5785 SENTINEL fromEnd,
5786 ALLOCATOR allocator,
5788{
5789 // We may be casting a function pointer to a 'void *' here, so this won't
5790 // work if we port to an architecture where the two are of different sizes.
5791
5792 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
5793
5794 typedef typename bsl::remove_cv<
5795 typename bsl::remove_pointer<TARGET_TYPE>::type>::type NcPtrType;
5796
5797 typedef typename bsl::remove_cv<
5798 typename bsl::remove_pointer<
5799 typename bsl::remove_pointer<FWD_ITER>::type>::type>::type NcIter;
5800
5801#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
5802 // fall back on traditional C-style casts.
5803 copyConstruct((void * *)toBegin,
5804 (void * const *)fromBegin,
5805 (void * const *)fromEnd,
5806 allocator,
5808#else
5810 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toBegin)),
5811 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromBegin)),
5812 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromEnd)),
5813 allocator,
5815#endif
5816}
5817
5818template <class FWD_ITER, class SENTINEL, class ALLOCATOR>
5820 void **toBegin,
5821 FWD_ITER fromBegin,
5822 SENTINEL fromEnd,
5823 ALLOCATOR,
5825{
5826 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
5827 // We will be casting a function pointer to a 'void *', so this won't
5828 // work if we port to an architecture where the two are of different
5829 // sizes.
5830
5831 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5833
5834 while (fromBegin != fromEnd) {
5835 // 'fromBegin' iterates over pointers to functions, which must be
5836 // @ref reinterpret_cast to 'void *'.
5837
5838 *toBegin = reinterpret_cast<void *>(*fromBegin);
5839 ++fromBegin;
5840 ++toBegin;
5841 }
5842}
5843
5844template <class TARGET_TYPE, class ALLOCATOR>
5845inline
5847 TARGET_TYPE *toBegin,
5848 const TARGET_TYPE *fromBegin,
5849 const TARGET_TYPE *fromEnd,
5850 ALLOCATOR,
5852{
5853 BSLS_ASSERT_SAFE(toBegin);
5855 fromEnd));
5856
5857 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
5858 - reinterpret_cast<const char*>(fromBegin);
5859 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
5860 std::memcpy((void *)toBegin, fromBegin, numBytes);
5861 }
5862}
5863
5864template <class TARGET_TYPE, class FWD_ITER, class SENTINEL, class ALLOCATOR>
5866 TARGET_TYPE *toBegin,
5867 FWD_ITER fromBegin,
5868 SENTINEL fromEnd,
5869 ALLOCATOR allocator,
5871{
5872 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5874 fromEnd));
5875
5876 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5877 allocator);
5878
5879 while (fromBegin != fromEnd) {
5880 // Note: We are not sure the value type of 'FWD_ITER' is convertible to
5881 // 'TARGET_TYPE'. Use 'construct' instead.
5882
5884 toBegin,
5885 *fromBegin);
5886 ++fromBegin;
5887 toBegin = guard.moveEnd(1);
5888 }
5889 guard.release();
5890}
5891
5892 // *** 'moveConstruct' overloads: ***
5893template <class TARGET_TYPE, class ALLOCATOR>
5894inline
5896 TARGET_TYPE *toBegin,
5897 TARGET_TYPE *fromBegin,
5898 TARGET_TYPE *fromEnd,
5899 ALLOCATOR,
5901{
5902 BSLS_ASSERT_SAFE(toBegin);
5904 fromEnd));
5905
5906 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
5907 - reinterpret_cast<const char*>(fromBegin);
5908 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
5909 std::memcpy((void *)toBegin, fromBegin, numBytes);
5910 }
5911}
5912
5913template <class TARGET_TYPE, class ALLOCATOR>
5915 TARGET_TYPE *toBegin,
5916 TARGET_TYPE *fromBegin,
5917 TARGET_TYPE *fromEnd,
5918 ALLOCATOR allocator,
5920{
5921 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5923 fromEnd));
5924
5925 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5926 allocator);
5927
5928 while (fromBegin != fromEnd) {
5930 allocator,
5931 toBegin,
5932 bslmf::MovableRefUtil::move(*fromBegin));
5933 ++fromBegin;
5934 toBegin = guard.moveEnd(1);
5935 }
5936 guard.release();
5937}
5938
5939template <class TARGET_TYPE, class ALLOCATOR>
5941 TARGET_TYPE *toBegin,
5942 TARGET_TYPE *fromBegin,
5943 TARGET_TYPE *fromEnd,
5944 ALLOCATOR allocator,
5946{
5947 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
5949 fromEnd));
5950
5951 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin, toBegin,
5952 allocator);
5953
5954 while (fromBegin != fromEnd) {
5956 allocator,
5957 toBegin,
5959 ++fromBegin;
5960 toBegin = guard.moveEnd(1);
5961 }
5962 guard.release();
5963}
5964
5965
5966 // *** 'defaultConstruct' overloads: ***
5967
5968template <class TARGET_TYPE, class ALLOCATOR>
5969inline
5971 TARGET_TYPE *begin,
5972 size_type numElements,
5973 ALLOCATOR,
5975{
5976 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5978
5979 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
5980 std::memset(static_cast<void *>(begin),
5981 0,
5982 sizeof(TARGET_TYPE) * numElements);
5983 }
5984}
5985
5986template <class TARGET_TYPE, class ALLOCATOR>
5987inline
5989 TARGET_TYPE *begin,
5990 size_type numElements,
5991 ALLOCATOR allocator,
5993{
5994 BSLS_ASSERT_SAFE(begin || 0 == numElements);
5996
5997 if (0 < numElements) {
5999 bitwiseFillN(reinterpret_cast<char *>(begin),
6000 sizeof(TARGET_TYPE),
6001 numElements * sizeof(TARGET_TYPE));
6002 }
6003}
6004
6005template <class TARGET_TYPE, class ALLOCATOR>
6007 TARGET_TYPE *begin,
6008 size_type numElements,
6009 ALLOCATOR allocator,
6011{
6012 BSLS_ASSERT_SAFE(begin || 0 == numElements);
6014
6015 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(begin, begin, allocator);
6016
6017 const TARGET_TYPE *end = begin + numElements;
6018 while (begin != end) {
6020 begin = guard.moveEnd(1);
6021 }
6022 guard.release();
6023}
6024
6025 // *** 'destructiveMove' overloads: ***
6026
6027template <class TARGET_TYPE, class ALLOCATOR>
6028inline
6030 TARGET_TYPE *toBegin,
6031 TARGET_TYPE *fromBegin,
6032 TARGET_TYPE *fromEnd,
6033 ALLOCATOR,
6035{
6036 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
6038 fromEnd));
6039
6040 const size_type numBytes = reinterpret_cast<const char*>(fromEnd)
6041 - reinterpret_cast<const char*>(fromBegin);
6042 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
6043 std::memcpy((void *)toBegin, fromBegin, numBytes);
6044 }
6045}
6046
6047template <class TARGET_TYPE, class ALLOCATOR>
6048inline
6050 TARGET_TYPE *toBegin,
6051 TARGET_TYPE *fromBegin,
6052 TARGET_TYPE *fromEnd,
6053 ALLOCATOR allocator,
6055{
6056 BSLS_ASSERT_SAFE(toBegin || fromBegin == fromEnd);
6058 fromEnd));
6059
6060 // 'TARGET_TYPE' certainly cannot be bit-wise copyable, so we can save the
6061 // compiler some work.
6062
6063 moveIfNoexcept(toBegin, fromBegin, fromEnd, allocator,
6065 ArrayDestructionPrimitives::destroy(fromBegin, fromEnd, allocator);
6066}
6067
6068 // *** 'emplace' with 'args' overloads: ***
6069
6070#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
6071// {{{ BEGIN GENERATED CODE
6072// Command line: sim_cpp11_features.pl bslalg_arrayprimitives.h
6073#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
6074#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT 10
6075#endif
6076#ifndef BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F
6077#define BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT
6078#endif
6079#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6080template <class TARGET_TYPE, class ALLOCATOR>
6081inline
6083 TARGET_TYPE *toBegin,
6084 TARGET_TYPE *toEnd,
6085 ALLOCATOR allocator,
6087{
6088
6090 toBegin,
6091 toEnd,
6092 allocator,
6094}
6095#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6096
6097#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6098template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
6099inline
6101 TARGET_TYPE *toBegin,
6102 TARGET_TYPE *toEnd,
6103 ALLOCATOR allocator,
6105 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
6106{
6107
6109 toBegin,
6110 toEnd,
6111 allocator,
6113 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
6114}
6115#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6116
6117#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6118template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6119 class ARGS_02>
6120inline
6122 TARGET_TYPE *toBegin,
6123 TARGET_TYPE *toEnd,
6124 ALLOCATOR allocator,
6126 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6127 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
6128{
6129
6131 toBegin,
6132 toEnd,
6133 allocator,
6135 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6136 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
6137}
6138#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6139
6140#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6141template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6142 class ARGS_02,
6143 class ARGS_03>
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{
6154
6156 toBegin,
6157 toEnd,
6158 allocator,
6160 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6161 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6162 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
6163}
6164#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6165
6166#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6167template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6168 class ARGS_02,
6169 class ARGS_03,
6170 class ARGS_04>
6171inline
6173 TARGET_TYPE *toBegin,
6174 TARGET_TYPE *toEnd,
6175 ALLOCATOR allocator,
6177 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6178 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6179 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6180 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
6181{
6182
6184 toBegin,
6185 toEnd,
6186 allocator,
6188 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6189 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6190 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6191 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
6192}
6193#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6194
6195#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6196template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6197 class ARGS_02,
6198 class ARGS_03,
6199 class ARGS_04,
6200 class ARGS_05>
6201inline
6203 TARGET_TYPE *toBegin,
6204 TARGET_TYPE *toEnd,
6205 ALLOCATOR allocator,
6207 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6208 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6209 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6210 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6211 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
6212{
6213
6215 toBegin,
6216 toEnd,
6217 allocator,
6219 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6220 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6221 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6222 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6223 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
6224}
6225#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6226
6227#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6228template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6229 class ARGS_02,
6230 class ARGS_03,
6231 class ARGS_04,
6232 class ARGS_05,
6233 class ARGS_06>
6234inline
6236 TARGET_TYPE *toBegin,
6237 TARGET_TYPE *toEnd,
6238 ALLOCATOR allocator,
6240 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6241 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6242 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6243 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6244 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6245 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
6246{
6247
6249 toBegin,
6250 toEnd,
6251 allocator,
6253 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6254 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6255 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6256 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6257 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6258 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
6259}
6260#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6261
6262#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6263template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6264 class ARGS_02,
6265 class ARGS_03,
6266 class ARGS_04,
6267 class ARGS_05,
6268 class ARGS_06,
6269 class ARGS_07>
6270inline
6272 TARGET_TYPE *toBegin,
6273 TARGET_TYPE *toEnd,
6274 ALLOCATOR allocator,
6276 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6277 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6278 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6279 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6280 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6281 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6282 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
6283{
6284
6286 toBegin,
6287 toEnd,
6288 allocator,
6290 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6291 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6292 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6293 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6294 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6295 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6296 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
6297}
6298#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6299
6300#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
6301template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6302 class ARGS_02,
6303 class ARGS_03,
6304 class ARGS_04,
6305 class ARGS_05,
6306 class ARGS_06,
6307 class ARGS_07,
6308 class ARGS_08>
6309inline
6311 TARGET_TYPE *toBegin,
6312 TARGET_TYPE *toEnd,
6313 ALLOCATOR allocator,
6315 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6316 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6317 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6318 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6319 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6320 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6321 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6322 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
6323{
6324
6326 toBegin,
6327 toEnd,
6328 allocator,
6330 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6331 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6332 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6333 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6334 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6335 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6336 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6337 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
6338}
6339#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
6340
6341#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
6342template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6343 class ARGS_02,
6344 class ARGS_03,
6345 class ARGS_04,
6346 class ARGS_05,
6347 class ARGS_06,
6348 class ARGS_07,
6349 class ARGS_08,
6350 class ARGS_09>
6351inline
6353 TARGET_TYPE *toBegin,
6354 TARGET_TYPE *toEnd,
6355 ALLOCATOR allocator,
6357 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6358 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6359 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6360 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6361 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6362 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6363 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6364 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
6365 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
6366{
6367
6369 toBegin,
6370 toEnd,
6371 allocator,
6373 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6374 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6375 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6376 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6377 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6378 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6379 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6380 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
6381 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
6382}
6383#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
6384
6385#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
6386template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6387 class ARGS_02,
6388 class ARGS_03,
6389 class ARGS_04,
6390 class ARGS_05,
6391 class ARGS_06,
6392 class ARGS_07,
6393 class ARGS_08,
6394 class ARGS_09,
6395 class ARGS_10>
6396inline
6398 TARGET_TYPE *toBegin,
6399 TARGET_TYPE *toEnd,
6400 ALLOCATOR allocator,
6402 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6403 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6404 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6405 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6406 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6407 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6408 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
6409 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
6410 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
6411 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
6412{
6413
6415 toBegin,
6416 toEnd,
6417 allocator,
6419 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6420 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6421 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6422 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6423 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6424 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6425 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
6426 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
6427 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
6428 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
6429}
6430#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
6431
6432
6433#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6434template <class TARGET_TYPE, class ALLOCATOR>
6436 TARGET_TYPE *toBegin,
6437 TARGET_TYPE *toEnd,
6438 ALLOCATOR allocator,
6440{
6442 toEnd));
6444
6445 size_type numElements = 1;
6446
6447
6448 size_type tailLen = toEnd - toBegin;
6449 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6450
6451
6452 TARGET_TYPE *destBegin = toBegin + numElements;
6453 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6454 std::memmove((void *)destBegin,
6455 toBegin,
6456 tailLen * sizeof(TARGET_TYPE));
6457 }
6458
6459
6460 TARGET_TYPE *destEnd = toEnd + numElements;
6461
6462 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6463 destEnd - numGuarded,
6464 destEnd - numGuarded,
6465 destEnd,
6466 allocator);
6467
6468 while (guard.middle() != guard.end()) {
6470 guard.destination());
6471 guard.advance();
6472 }
6473
6474
6475 if (tailLen < numElements) {
6476
6477 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6478 destEnd,
6479 allocator);
6480
6481
6482 while (toEnd != destBegin) {
6484 --destBegin);
6485
6486 endGuard.moveBegin(-1);
6487 }
6488 endGuard.release();
6489 }
6490}
6491#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
6492
6493#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6494template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
6496 TARGET_TYPE *toBegin,
6497 TARGET_TYPE *toEnd,
6498 ALLOCATOR allocator,
6500 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
6501{
6503 toEnd));
6505
6506 size_type numElements = 1;
6507
6508
6509 size_type tailLen = toEnd - toBegin;
6510 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6511
6512
6513 TARGET_TYPE *destBegin = toBegin + numElements;
6514 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6515 std::memmove((void *)destBegin,
6516 toBegin,
6517 tailLen * sizeof(TARGET_TYPE));
6518 }
6519
6520
6521 TARGET_TYPE *destEnd = toEnd + numElements;
6522
6523 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6524 destEnd - numGuarded,
6525 destEnd - numGuarded,
6526 destEnd,
6527 allocator);
6528
6529 while (guard.middle() != guard.end()) {
6531 guard.destination(),
6532 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
6533 guard.advance();
6534 }
6535
6536
6537 if (tailLen < numElements) {
6538
6539 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6540 destEnd,
6541 allocator);
6542
6543
6544 while (toEnd != destBegin) {
6546 --destBegin,
6547 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01));
6548
6549 endGuard.moveBegin(-1);
6550 }
6551 endGuard.release();
6552 }
6553}
6554#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
6555
6556#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6557template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6558 class ARGS_02>
6560 TARGET_TYPE *toBegin,
6561 TARGET_TYPE *toEnd,
6562 ALLOCATOR allocator,
6564 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6565 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
6566{
6568 toEnd));
6570
6571 size_type numElements = 1;
6572
6573
6574 size_type tailLen = toEnd - toBegin;
6575 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6576
6577
6578 TARGET_TYPE *destBegin = toBegin + numElements;
6579 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6580 std::memmove((void *)destBegin,
6581 toBegin,
6582 tailLen * sizeof(TARGET_TYPE));
6583 }
6584
6585
6586 TARGET_TYPE *destEnd = toEnd + numElements;
6587
6588 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6589 destEnd - numGuarded,
6590 destEnd - numGuarded,
6591 destEnd,
6592 allocator);
6593
6594 while (guard.middle() != guard.end()) {
6596 guard.destination(),
6597 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6598 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
6599 guard.advance();
6600 }
6601
6602
6603 if (tailLen < numElements) {
6604
6605 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6606 destEnd,
6607 allocator);
6608
6609
6610 while (toEnd != destBegin) {
6612 --destBegin,
6613 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6614 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02));
6615
6616 endGuard.moveBegin(-1);
6617 }
6618 endGuard.release();
6619 }
6620}
6621#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
6622
6623#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6624template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6625 class ARGS_02,
6626 class ARGS_03>
6628 TARGET_TYPE *toBegin,
6629 TARGET_TYPE *toEnd,
6630 ALLOCATOR allocator,
6632 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6633 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6634 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
6635{
6637 toEnd));
6639
6640 size_type numElements = 1;
6641
6642
6643 size_type tailLen = toEnd - toBegin;
6644 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6645
6646
6647 TARGET_TYPE *destBegin = toBegin + numElements;
6648 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6649 std::memmove((void *)destBegin,
6650 toBegin,
6651 tailLen * sizeof(TARGET_TYPE));
6652 }
6653
6654
6655 TARGET_TYPE *destEnd = toEnd + numElements;
6656
6657 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6658 destEnd - numGuarded,
6659 destEnd - numGuarded,
6660 destEnd,
6661 allocator);
6662
6663 while (guard.middle() != guard.end()) {
6665 guard.destination(),
6666 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6667 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6668 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
6669 guard.advance();
6670 }
6671
6672
6673 if (tailLen < numElements) {
6674
6675 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6676 destEnd,
6677 allocator);
6678
6679
6680 while (toEnd != destBegin) {
6682 --destBegin,
6683 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6684 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6685 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03));
6686
6687 endGuard.moveBegin(-1);
6688 }
6689 endGuard.release();
6690 }
6691}
6692#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
6693
6694#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6695template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6696 class ARGS_02,
6697 class ARGS_03,
6698 class ARGS_04>
6700 TARGET_TYPE *toBegin,
6701 TARGET_TYPE *toEnd,
6702 ALLOCATOR allocator,
6704 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6705 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6706 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6707 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
6708{
6710 toEnd));
6712
6713 size_type numElements = 1;
6714
6715
6716 size_type tailLen = toEnd - toBegin;
6717 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6718
6719
6720 TARGET_TYPE *destBegin = toBegin + numElements;
6721 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6722 std::memmove((void *)destBegin,
6723 toBegin,
6724 tailLen * sizeof(TARGET_TYPE));
6725 }
6726
6727
6728 TARGET_TYPE *destEnd = toEnd + numElements;
6729
6730 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6731 destEnd - numGuarded,
6732 destEnd - numGuarded,
6733 destEnd,
6734 allocator);
6735
6736 while (guard.middle() != guard.end()) {
6738 guard.destination(),
6739 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6740 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6741 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6742 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
6743 guard.advance();
6744 }
6745
6746
6747 if (tailLen < numElements) {
6748
6749 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6750 destEnd,
6751 allocator);
6752
6753
6754 while (toEnd != destBegin) {
6756 --destBegin,
6757 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6758 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6759 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6760 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04));
6761
6762 endGuard.moveBegin(-1);
6763 }
6764 endGuard.release();
6765 }
6766}
6767#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
6768
6769#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6770template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6771 class ARGS_02,
6772 class ARGS_03,
6773 class ARGS_04,
6774 class ARGS_05>
6776 TARGET_TYPE *toBegin,
6777 TARGET_TYPE *toEnd,
6778 ALLOCATOR allocator,
6780 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6781 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6782 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6783 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6784 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
6785{
6787 toEnd));
6789
6790 size_type numElements = 1;
6791
6792
6793 size_type tailLen = toEnd - toBegin;
6794 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6795
6796
6797 TARGET_TYPE *destBegin = toBegin + numElements;
6798 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6799 std::memmove((void *)destBegin,
6800 toBegin,
6801 tailLen * sizeof(TARGET_TYPE));
6802 }
6803
6804
6805 TARGET_TYPE *destEnd = toEnd + numElements;
6806
6807 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6808 destEnd - numGuarded,
6809 destEnd - numGuarded,
6810 destEnd,
6811 allocator);
6812
6813 while (guard.middle() != guard.end()) {
6815 guard.destination(),
6816 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6817 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6818 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6819 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6820 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
6821 guard.advance();
6822 }
6823
6824
6825 if (tailLen < numElements) {
6826
6827 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6828 destEnd,
6829 allocator);
6830
6831
6832 while (toEnd != destBegin) {
6834 --destBegin,
6835 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6836 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6837 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6838 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6839 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05));
6840
6841 endGuard.moveBegin(-1);
6842 }
6843 endGuard.release();
6844 }
6845}
6846#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
6847
6848#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6849template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6850 class ARGS_02,
6851 class ARGS_03,
6852 class ARGS_04,
6853 class ARGS_05,
6854 class ARGS_06>
6856 TARGET_TYPE *toBegin,
6857 TARGET_TYPE *toEnd,
6858 ALLOCATOR allocator,
6860 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6861 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6862 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6863 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6864 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6865 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
6866{
6868 toEnd));
6870
6871 size_type numElements = 1;
6872
6873
6874 size_type tailLen = toEnd - toBegin;
6875 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6876
6877
6878 TARGET_TYPE *destBegin = toBegin + numElements;
6879 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6880 std::memmove((void *)destBegin,
6881 toBegin,
6882 tailLen * sizeof(TARGET_TYPE));
6883 }
6884
6885
6886 TARGET_TYPE *destEnd = toEnd + numElements;
6887
6888 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6889 destEnd - numGuarded,
6890 destEnd - numGuarded,
6891 destEnd,
6892 allocator);
6893
6894 while (guard.middle() != guard.end()) {
6896 guard.destination(),
6897 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6898 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6899 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6900 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6901 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6902 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
6903 guard.advance();
6904 }
6905
6906
6907 if (tailLen < numElements) {
6908
6909 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6910 destEnd,
6911 allocator);
6912
6913
6914 while (toEnd != destBegin) {
6916 --destBegin,
6917 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
6918 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
6919 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
6920 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
6921 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
6922 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06));
6923
6924 endGuard.moveBegin(-1);
6925 }
6926 endGuard.release();
6927 }
6928}
6929#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
6930
6931#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
6932template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
6933 class ARGS_02,
6934 class ARGS_03,
6935 class ARGS_04,
6936 class ARGS_05,
6937 class ARGS_06,
6938 class ARGS_07>
6940 TARGET_TYPE *toBegin,
6941 TARGET_TYPE *toEnd,
6942 ALLOCATOR allocator,
6944 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
6945 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
6946 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
6947 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
6948 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
6949 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
6950 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
6951{
6953 toEnd));
6955
6956 size_type numElements = 1;
6957
6958
6959 size_type tailLen = toEnd - toBegin;
6960 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
6961
6962
6963 TARGET_TYPE *destBegin = toBegin + numElements;
6964 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
6965 std::memmove((void *)destBegin,
6966 toBegin,
6967 tailLen * sizeof(TARGET_TYPE));
6968 }
6969
6970
6971 TARGET_TYPE *destEnd = toEnd + numElements;
6972
6973 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
6974 destEnd - numGuarded,
6975 destEnd - numGuarded,
6976 destEnd,
6977 allocator);
6978
6979 while (guard.middle() != guard.end()) {
6981 guard.destination(),
6982 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
6983 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
6984 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
6985 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
6986 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
6987 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
6988 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
6989 guard.advance();
6990 }
6991
6992
6993 if (tailLen < numElements) {
6994
6995 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
6996 destEnd,
6997 allocator);
6998
6999
7000 while (toEnd != destBegin) {
7002 --destBegin,
7003 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7004 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7005 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7006 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7007 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7008 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7009 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07));
7010
7011 endGuard.moveBegin(-1);
7012 }
7013 endGuard.release();
7014 }
7015}
7016#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
7017
7018#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7019template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7020 class ARGS_02,
7021 class ARGS_03,
7022 class ARGS_04,
7023 class ARGS_05,
7024 class ARGS_06,
7025 class ARGS_07,
7026 class ARGS_08>
7028 TARGET_TYPE *toBegin,
7029 TARGET_TYPE *toEnd,
7030 ALLOCATOR allocator,
7032 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7033 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7034 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7035 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7036 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7037 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7038 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7039 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
7040{
7042 toEnd));
7044
7045 size_type numElements = 1;
7046
7047
7048 size_type tailLen = toEnd - toBegin;
7049 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
7050
7051
7052 TARGET_TYPE *destBegin = toBegin + numElements;
7053 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
7054 std::memmove((void *)destBegin,
7055 toBegin,
7056 tailLen * sizeof(TARGET_TYPE));
7057 }
7058
7059
7060 TARGET_TYPE *destEnd = toEnd + numElements;
7061
7062 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7063 destEnd - numGuarded,
7064 destEnd - numGuarded,
7065 destEnd,
7066 allocator);
7067
7068 while (guard.middle() != guard.end()) {
7070 guard.destination(),
7071 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7072 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7073 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7074 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7075 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7076 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7077 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7078 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7079 guard.advance();
7080 }
7081
7082
7083 if (tailLen < numElements) {
7084
7085 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7086 destEnd,
7087 allocator);
7088
7089
7090 while (toEnd != destBegin) {
7092 --destBegin,
7093 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7094 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7095 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7096 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7097 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7098 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7099 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7100 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08));
7101
7102 endGuard.moveBegin(-1);
7103 }
7104 endGuard.release();
7105 }
7106}
7107#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7108
7109#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7110template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7111 class ARGS_02,
7112 class ARGS_03,
7113 class ARGS_04,
7114 class ARGS_05,
7115 class ARGS_06,
7116 class ARGS_07,
7117 class ARGS_08,
7118 class ARGS_09>
7120 TARGET_TYPE *toBegin,
7121 TARGET_TYPE *toEnd,
7122 ALLOCATOR allocator,
7124 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7125 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7126 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7127 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7128 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7129 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7130 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7131 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7132 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7133{
7135 toEnd));
7137
7138 size_type numElements = 1;
7139
7140
7141 size_type tailLen = toEnd - toBegin;
7142 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
7143
7144
7145 TARGET_TYPE *destBegin = toBegin + numElements;
7146 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
7147 std::memmove((void *)destBegin,
7148 toBegin,
7149 tailLen * sizeof(TARGET_TYPE));
7150 }
7151
7152
7153 TARGET_TYPE *destEnd = toEnd + numElements;
7154
7155 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7156 destEnd - numGuarded,
7157 destEnd - numGuarded,
7158 destEnd,
7159 allocator);
7160
7161 while (guard.middle() != guard.end()) {
7163 guard.destination(),
7164 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7165 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7166 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7167 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7168 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7169 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7170 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7171 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7172 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7173 guard.advance();
7174 }
7175
7176
7177 if (tailLen < numElements) {
7178
7179 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7180 destEnd,
7181 allocator);
7182
7183
7184 while (toEnd != destBegin) {
7186 --destBegin,
7187 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7188 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7189 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7190 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7191 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7192 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7193 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7194 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7195 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09));
7196
7197 endGuard.moveBegin(-1);
7198 }
7199 endGuard.release();
7200 }
7201}
7202#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7203
7204#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7205template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7206 class ARGS_02,
7207 class ARGS_03,
7208 class ARGS_04,
7209 class ARGS_05,
7210 class ARGS_06,
7211 class ARGS_07,
7212 class ARGS_08,
7213 class ARGS_09,
7214 class ARGS_10>
7216 TARGET_TYPE *toBegin,
7217 TARGET_TYPE *toEnd,
7218 ALLOCATOR allocator,
7220 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7221 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7222 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7223 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7224 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7225 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7226 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7227 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7228 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
7229 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
7230{
7232 toEnd));
7234
7235 size_type numElements = 1;
7236
7237
7238 size_type tailLen = toEnd - toBegin;
7239 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
7240
7241
7242 TARGET_TYPE *destBegin = toBegin + numElements;
7243 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
7244 std::memmove((void *)destBegin,
7245 toBegin,
7246 tailLen * sizeof(TARGET_TYPE));
7247 }
7248
7249
7250 TARGET_TYPE *destEnd = toEnd + numElements;
7251
7252 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
7253 destEnd - numGuarded,
7254 destEnd - numGuarded,
7255 destEnd,
7256 allocator);
7257
7258 while (guard.middle() != guard.end()) {
7260 guard.destination(),
7261 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7262 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7263 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7264 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7265 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7266 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7267 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7268 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7269 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
7270 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
7271 guard.advance();
7272 }
7273
7274
7275 if (tailLen < numElements) {
7276
7277 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
7278 destEnd,
7279 allocator);
7280
7281
7282 while (toEnd != destBegin) {
7284 --destBegin,
7285 BSLS_COMPILERFEATURES_FORWARD(ARGS_01,args_01),
7286 BSLS_COMPILERFEATURES_FORWARD(ARGS_02,args_02),
7287 BSLS_COMPILERFEATURES_FORWARD(ARGS_03,args_03),
7288 BSLS_COMPILERFEATURES_FORWARD(ARGS_04,args_04),
7289 BSLS_COMPILERFEATURES_FORWARD(ARGS_05,args_05),
7290 BSLS_COMPILERFEATURES_FORWARD(ARGS_06,args_06),
7291 BSLS_COMPILERFEATURES_FORWARD(ARGS_07,args_07),
7292 BSLS_COMPILERFEATURES_FORWARD(ARGS_08,args_08),
7293 BSLS_COMPILERFEATURES_FORWARD(ARGS_09,args_09),
7294 BSLS_COMPILERFEATURES_FORWARD(ARGS_10,args_10));
7295
7296 endGuard.moveBegin(-1);
7297 }
7298 endGuard.release();
7299 }
7300}
7301#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7302
7303
7304#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
7305template <class TARGET_TYPE, class ALLOCATOR>
7307 TARGET_TYPE *toBegin,
7308 TARGET_TYPE *toEnd,
7309 ALLOCATOR allocator,
7311{
7313 toEnd));
7315
7316
7317 if (toEnd > toBegin) {
7318
7321 allocator,
7322 BSLS_UTIL_ADDRESSOF(space.object()));
7324 BSLS_UTIL_ADDRESSOF(space.object()));
7325
7326
7328 allocator,
7329 toEnd,
7331
7332 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7333 toEnd + 1,
7334 allocator);
7335
7336
7337 TARGET_TYPE *destEnd = toEnd;
7338 TARGET_TYPE *srcEnd = toEnd - 1;
7339 while (toBegin != srcEnd) {
7340 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7341 }
7342
7343
7345
7346 guard.release();
7347 }
7348 else {
7349
7351 allocator, toEnd);
7352 }
7353}
7354#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 0
7355
7356#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
7357template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01>
7359 TARGET_TYPE *toBegin,
7360 TARGET_TYPE *toEnd,
7361 ALLOCATOR allocator,
7363 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01)
7364{
7366 toEnd));
7368
7369
7370 if (toEnd > toBegin) {
7371
7374 allocator,
7375 BSLS_UTIL_ADDRESSOF(space.object()),
7376 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01));
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 }
7407}
7408#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 1
7409
7410#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
7411template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7412 class ARGS_02>
7414 TARGET_TYPE *toBegin,
7415 TARGET_TYPE *toEnd,
7416 ALLOCATOR allocator,
7418 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7419 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02)
7420{
7422 toEnd));
7424
7425
7426 if (toEnd > toBegin) {
7427
7430 allocator,
7431 BSLS_UTIL_ADDRESSOF(space.object()),
7432 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7433 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
7435 BSLS_UTIL_ADDRESSOF(space.object()));
7436
7437
7439 allocator,
7440 toEnd,
7442
7443 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7444 toEnd + 1,
7445 allocator);
7446
7447
7448 TARGET_TYPE *destEnd = toEnd;
7449 TARGET_TYPE *srcEnd = toEnd - 1;
7450 while (toBegin != srcEnd) {
7451 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7452 }
7453
7454
7456
7457 guard.release();
7458 }
7459 else {
7460
7462 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7463 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02));
7464 }
7465}
7466#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 2
7467
7468#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
7469template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7470 class ARGS_02,
7471 class ARGS_03>
7473 TARGET_TYPE *toBegin,
7474 TARGET_TYPE *toEnd,
7475 ALLOCATOR allocator,
7477 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7478 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7479 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03)
7480{
7482 toEnd));
7484
7485
7486 if (toEnd > toBegin) {
7487
7490 allocator,
7491 BSLS_UTIL_ADDRESSOF(space.object()),
7492 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7493 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7494 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
7496 BSLS_UTIL_ADDRESSOF(space.object()));
7497
7498
7500 allocator,
7501 toEnd,
7503
7504 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7505 toEnd + 1,
7506 allocator);
7507
7508
7509 TARGET_TYPE *destEnd = toEnd;
7510 TARGET_TYPE *srcEnd = toEnd - 1;
7511 while (toBegin != srcEnd) {
7512 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7513 }
7514
7515
7517
7518 guard.release();
7519 }
7520 else {
7521
7523 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7524 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7525 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03));
7526 }
7527}
7528#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 3
7529
7530#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
7531template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7532 class ARGS_02,
7533 class ARGS_03,
7534 class ARGS_04>
7536 TARGET_TYPE *toBegin,
7537 TARGET_TYPE *toEnd,
7538 ALLOCATOR allocator,
7540 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7541 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7542 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7543 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04)
7544{
7546 toEnd));
7548
7549
7550 if (toEnd > toBegin) {
7551
7554 allocator,
7555 BSLS_UTIL_ADDRESSOF(space.object()),
7556 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7557 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7558 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7559 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
7561 BSLS_UTIL_ADDRESSOF(space.object()));
7562
7563
7565 allocator,
7566 toEnd,
7568
7569 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7570 toEnd + 1,
7571 allocator);
7572
7573
7574 TARGET_TYPE *destEnd = toEnd;
7575 TARGET_TYPE *srcEnd = toEnd - 1;
7576 while (toBegin != srcEnd) {
7577 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7578 }
7579
7580
7582
7583 guard.release();
7584 }
7585 else {
7586
7588 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7589 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7590 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7591 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04));
7592 }
7593}
7594#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 4
7595
7596#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
7597template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7598 class ARGS_02,
7599 class ARGS_03,
7600 class ARGS_04,
7601 class ARGS_05>
7603 TARGET_TYPE *toBegin,
7604 TARGET_TYPE *toEnd,
7605 ALLOCATOR allocator,
7607 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7608 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7609 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7610 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7611 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05)
7612{
7614 toEnd));
7616
7617
7618 if (toEnd > toBegin) {
7619
7622 allocator,
7623 BSLS_UTIL_ADDRESSOF(space.object()),
7624 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7625 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7626 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7627 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7628 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
7630 BSLS_UTIL_ADDRESSOF(space.object()));
7631
7632
7634 allocator,
7635 toEnd,
7637
7638 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7639 toEnd + 1,
7640 allocator);
7641
7642
7643 TARGET_TYPE *destEnd = toEnd;
7644 TARGET_TYPE *srcEnd = toEnd - 1;
7645 while (toBegin != srcEnd) {
7646 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7647 }
7648
7649
7651
7652 guard.release();
7653 }
7654 else {
7655
7657 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7658 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7659 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7660 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7661 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05));
7662 }
7663}
7664#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 5
7665
7666#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
7667template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7668 class ARGS_02,
7669 class ARGS_03,
7670 class ARGS_04,
7671 class ARGS_05,
7672 class ARGS_06>
7674 TARGET_TYPE *toBegin,
7675 TARGET_TYPE *toEnd,
7676 ALLOCATOR allocator,
7678 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7679 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7680 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7681 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7682 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7683 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06)
7684{
7686 toEnd));
7688
7689
7690 if (toEnd > toBegin) {
7691
7694 allocator,
7695 BSLS_UTIL_ADDRESSOF(space.object()),
7696 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7697 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7698 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7699 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7700 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7701 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
7703 BSLS_UTIL_ADDRESSOF(space.object()));
7704
7705
7707 allocator,
7708 toEnd,
7710
7711 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7712 toEnd + 1,
7713 allocator);
7714
7715
7716 TARGET_TYPE *destEnd = toEnd;
7717 TARGET_TYPE *srcEnd = toEnd - 1;
7718 while (toBegin != srcEnd) {
7719 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7720 }
7721
7722
7724
7725 guard.release();
7726 }
7727 else {
7728
7730 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7731 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7732 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7733 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7734 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7735 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06));
7736 }
7737}
7738#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 6
7739
7740#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
7741template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7742 class ARGS_02,
7743 class ARGS_03,
7744 class ARGS_04,
7745 class ARGS_05,
7746 class ARGS_06,
7747 class ARGS_07>
7749 TARGET_TYPE *toBegin,
7750 TARGET_TYPE *toEnd,
7751 ALLOCATOR allocator,
7753 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7754 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7755 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7756 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7757 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7758 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7759 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07)
7760{
7762 toEnd));
7764
7765
7766 if (toEnd > toBegin) {
7767
7770 allocator,
7771 BSLS_UTIL_ADDRESSOF(space.object()),
7772 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7773 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7774 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7775 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7776 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7777 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7778 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
7780 BSLS_UTIL_ADDRESSOF(space.object()));
7781
7782
7784 allocator,
7785 toEnd,
7787
7788 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7789 toEnd + 1,
7790 allocator);
7791
7792
7793 TARGET_TYPE *destEnd = toEnd;
7794 TARGET_TYPE *srcEnd = toEnd - 1;
7795 while (toBegin != srcEnd) {
7796 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7797 }
7798
7799
7801
7802 guard.release();
7803 }
7804 else {
7805
7807 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7808 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7809 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7810 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7811 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7812 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7813 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07));
7814 }
7815}
7816#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 7
7817
7818#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7819template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7820 class ARGS_02,
7821 class ARGS_03,
7822 class ARGS_04,
7823 class ARGS_05,
7824 class ARGS_06,
7825 class ARGS_07,
7826 class ARGS_08>
7828 TARGET_TYPE *toBegin,
7829 TARGET_TYPE *toEnd,
7830 ALLOCATOR allocator,
7832 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7833 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7834 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7835 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7836 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7837 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7838 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7839 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08)
7840{
7842 toEnd));
7844
7845
7846 if (toEnd > toBegin) {
7847
7850 allocator,
7851 BSLS_UTIL_ADDRESSOF(space.object()),
7852 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7853 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7854 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7855 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7856 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7857 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7858 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7859 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7861 BSLS_UTIL_ADDRESSOF(space.object()));
7862
7863
7865 allocator,
7866 toEnd,
7868
7869 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7870 toEnd + 1,
7871 allocator);
7872
7873
7874 TARGET_TYPE *destEnd = toEnd;
7875 TARGET_TYPE *srcEnd = toEnd - 1;
7876 while (toBegin != srcEnd) {
7877 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7878 }
7879
7880
7882
7883 guard.release();
7884 }
7885 else {
7886
7888 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7889 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7890 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7891 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7892 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7893 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7894 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7895 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08));
7896 }
7897}
7898#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 8
7899
7900#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7901template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7902 class ARGS_02,
7903 class ARGS_03,
7904 class ARGS_04,
7905 class ARGS_05,
7906 class ARGS_06,
7907 class ARGS_07,
7908 class ARGS_08,
7909 class ARGS_09>
7911 TARGET_TYPE *toBegin,
7912 TARGET_TYPE *toEnd,
7913 ALLOCATOR allocator,
7915 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
7916 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
7917 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
7918 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
7919 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
7920 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
7921 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
7922 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
7923 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09)
7924{
7926 toEnd));
7928
7929
7930 if (toEnd > toBegin) {
7931
7934 allocator,
7935 BSLS_UTIL_ADDRESSOF(space.object()),
7936 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7937 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7938 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7939 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7940 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7941 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7942 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7943 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7944 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7946 BSLS_UTIL_ADDRESSOF(space.object()));
7947
7948
7950 allocator,
7951 toEnd,
7953
7954 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
7955 toEnd + 1,
7956 allocator);
7957
7958
7959 TARGET_TYPE *destEnd = toEnd;
7960 TARGET_TYPE *srcEnd = toEnd - 1;
7961 while (toBegin != srcEnd) {
7962 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
7963 }
7964
7965
7967
7968 guard.release();
7969 }
7970 else {
7971
7973 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
7974 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
7975 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
7976 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
7977 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
7978 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
7979 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
7980 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
7981 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09));
7982 }
7983}
7984#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 9
7985
7986#if BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
7987template <class TARGET_TYPE, class ALLOCATOR, class ARGS_01,
7988 class ARGS_02,
7989 class ARGS_03,
7990 class ARGS_04,
7991 class ARGS_05,
7992 class ARGS_06,
7993 class ARGS_07,
7994 class ARGS_08,
7995 class ARGS_09,
7996 class ARGS_10>
7998 TARGET_TYPE *toBegin,
7999 TARGET_TYPE *toEnd,
8000 ALLOCATOR allocator,
8002 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_01) args_01,
8003 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_02) args_02,
8004 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_03) args_03,
8005 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_04) args_04,
8006 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_05) args_05,
8007 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_06) args_06,
8008 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_07) args_07,
8009 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_08) args_08,
8010 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_09) args_09,
8011 BSLS_COMPILERFEATURES_FORWARD_REF(ARGS_10) args_10)
8012{
8014 toEnd));
8016
8017
8018 if (toEnd > toBegin) {
8019
8022 allocator,
8023 BSLS_UTIL_ADDRESSOF(space.object()),
8024 BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8025 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8026 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8027 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8028 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8029 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8030 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8031 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8032 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
8033 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
8035 BSLS_UTIL_ADDRESSOF(space.object()));
8036
8037
8039 allocator,
8040 toEnd,
8042
8043 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8044 toEnd + 1,
8045 allocator);
8046
8047
8048 TARGET_TYPE *destEnd = toEnd;
8049 TARGET_TYPE *srcEnd = toEnd - 1;
8050 while (toBegin != srcEnd) {
8051 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
8052 }
8053
8054
8056
8057 guard.release();
8058 }
8059 else {
8060
8062 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS_01, args_01),
8063 BSLS_COMPILERFEATURES_FORWARD(ARGS_02, args_02),
8064 BSLS_COMPILERFEATURES_FORWARD(ARGS_03, args_03),
8065 BSLS_COMPILERFEATURES_FORWARD(ARGS_04, args_04),
8066 BSLS_COMPILERFEATURES_FORWARD(ARGS_05, args_05),
8067 BSLS_COMPILERFEATURES_FORWARD(ARGS_06, args_06),
8068 BSLS_COMPILERFEATURES_FORWARD(ARGS_07, args_07),
8069 BSLS_COMPILERFEATURES_FORWARD(ARGS_08, args_08),
8070 BSLS_COMPILERFEATURES_FORWARD(ARGS_09, args_09),
8071 BSLS_COMPILERFEATURES_FORWARD(ARGS_10, args_10));
8072 }
8073}
8074#endif // BSLALG_ARRAYPRIMITIVES_VARIADIC_LIMIT_F >= 10
8075
8076#else
8077// The generated code below is a workaround for the absence of perfect
8078// forwarding in some compilers.
8079template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8080inline
8082 TARGET_TYPE *toBegin,
8083 TARGET_TYPE *toEnd,
8084 ALLOCATOR allocator,
8087{
8088
8090 toBegin,
8091 toEnd,
8092 allocator,
8094 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8095}
8096
8097template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8099 TARGET_TYPE *toBegin,
8100 TARGET_TYPE *toEnd,
8101 ALLOCATOR allocator,
8104{
8106 toEnd));
8108
8109 size_type numElements = 1;
8110
8111
8112 size_type tailLen = toEnd - toBegin;
8113 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8114
8115
8116 TARGET_TYPE *destBegin = toBegin + numElements;
8117 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8118 std::memmove((void *)destBegin,
8119 toBegin,
8120 tailLen * sizeof(TARGET_TYPE));
8121 }
8122
8123
8124 TARGET_TYPE *destEnd = toEnd + numElements;
8125
8126 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8127 destEnd - numGuarded,
8128 destEnd - numGuarded,
8129 destEnd,
8130 allocator);
8131
8132 while (guard.middle() != guard.end()) {
8134 guard.destination(),
8135 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8136 guard.advance();
8137 }
8138
8139
8140 if (tailLen < numElements) {
8141
8142 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
8143 destEnd,
8144 allocator);
8145
8146
8147 while (toEnd != destBegin) {
8149 --destBegin,
8150 BSLS_COMPILERFEATURES_FORWARD(ARGS,args)...);
8151
8152 endGuard.moveBegin(-1);
8153 }
8154 endGuard.release();
8155 }
8156}
8157
8158template <class TARGET_TYPE, class ALLOCATOR, class... ARGS>
8160 TARGET_TYPE *toBegin,
8161 TARGET_TYPE *toEnd,
8162 ALLOCATOR allocator,
8165{
8167 toEnd));
8169
8170
8171 if (toEnd > toBegin) {
8172
8175 allocator,
8176 BSLS_UTIL_ADDRESSOF(space.object()),
8177 BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8179 BSLS_UTIL_ADDRESSOF(space.object()));
8180
8181
8183 allocator,
8184 toEnd,
8186
8187 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8188 toEnd + 1,
8189 allocator);
8190
8191
8192 TARGET_TYPE *destEnd = toEnd;
8193 TARGET_TYPE *srcEnd = toEnd - 1;
8194 while (toBegin != srcEnd) {
8195 *--destEnd = bslmf::MovableRefUtil::move_if_noexcept(*--srcEnd);
8196 }
8197
8198
8200
8201 guard.release();
8202 }
8203 else {
8204
8206 allocator, toEnd, BSLS_COMPILERFEATURES_FORWARD(ARGS, args)...);
8207 }
8208}
8209// }}} END GENERATED CODE
8210#endif
8211
8212 // *** 'erase' overloads: ***
8213
8214template <class TARGET_TYPE, class ALLOCATOR>
8216 TARGET_TYPE *first,
8217 TARGET_TYPE *middle,
8218 TARGET_TYPE *last,
8219 ALLOCATOR allocator,
8221{
8224
8225 // Key to the transformation diagrams:
8226 //..
8227 // t...z Original contents of '[first, middle)'
8228 // A...G Original contents of '[middle, last)'
8229 // _ Destroyed array element
8230 //..
8231
8232 //..
8233 // Transformation: tuvABCDEFG => ___ABCDEFG (no throw)
8234 //..
8235 ArrayDestructionPrimitives::destroy(first, middle, allocator);
8236
8237 //..
8238 // Transformation: ___ABCDEFG => ABCDEFG___ (might overlap, but no throw)
8239 //..
8240 size_type numBytes = reinterpret_cast<const char *>(last)
8241 - reinterpret_cast<const char *>(middle);
8242 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8243 std::memmove((void *)first, middle, numBytes);
8244 }
8245}
8246
8247template <class TARGET_TYPE, class ALLOCATOR>
8249 TARGET_TYPE *first,
8250 TARGET_TYPE *middle,
8251 TARGET_TYPE *last,
8252 ALLOCATOR allocator,
8254{
8257
8258 // Key to the transformation diagrams:
8259 //..
8260 // t...z Original contents of '[first, middle)'
8261 // A...G Original contents of '[middle, last)'
8262 // _ Destructed array element
8263 //..
8264
8265 //..
8266 // Transformation: tuvABCDEFG => ABCDEFGEFG.
8267 //..
8268
8269 while (middle != last) {
8270 *first++ = bslmf::MovableRefUtil::move_if_noexcept(*middle++);
8271 }
8272
8273 //..
8274 // Transformation: ABCDEFGEFG => ABCDEFG___.
8275 //..
8276
8277 ArrayDestructionPrimitives::destroy(first, middle, allocator);
8278}
8279
8280 // *** 'insert' with 'value' overloads: ***
8281
8282template <class TARGET_TYPE, class ALLOCATOR>
8283inline
8285 TARGET_TYPE *toBegin,
8286 TARGET_TYPE *toEnd,
8287 const TARGET_TYPE& value,
8288 size_type numElements,
8289 ALLOCATOR allocator,
8291{
8294
8295 // Key to the transformation diagrams:
8296 //..
8297 // A...G original contents of '[toBegin, toEnd)' ("tail")
8298 // v...v contents of '[fromBegin, fromEnd)' ("input")
8299 // _____ uninitialized array element
8300 //..
8301
8302 // ALIASING: If 'value' is a reference into the array 'toBegin..toEnd',
8303 // then moving the array first might introduce a change in 'value'. Since
8304 // type is bitwise copyable, then no memory changes outside the array, so
8305 // the test below is sufficient to discover all the possible aliasing.
8306 // Note that we never make a copy.
8307
8308 const TARGET_TYPE *tempValuePtr = BSLS_UTIL_ADDRESSOF(value);
8309 if (toBegin <= tempValuePtr && tempValuePtr < toEnd ) {
8310 // Adjust pointer for shifting after the move.
8311
8312 tempValuePtr += numElements;
8313 }
8314
8315 //..
8316 // Transformation: ABCDE___ => ___ABCDE (might overlap).
8317 //..
8318
8319 const size_type numBytes = reinterpret_cast<const char*>(toEnd)
8320 - reinterpret_cast<const char*>(toBegin);
8321 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8322 std::memmove((void *)(toBegin + numElements), toBegin, numBytes);
8323 }
8324
8325 //..
8326 // Transformation: ___ABCDE => v__ABCDE (no overlap).
8327 //..
8328
8329 // Use 'copyConstruct' instead of 'memcpy' because the former optimizes for
8330 // fundamental types using 'operator=' instead, which avoid the 'memcpy'
8331 // function call.
8332
8334 toBegin,
8335 *tempValuePtr);
8336 //..
8337 // Transformation: v__ABCDE => vvvABCDE.
8338 //..
8339
8340 bitwiseFillN(reinterpret_cast<char *>(toBegin),
8341 sizeof value,
8342 numElements * sizeof value);
8343}
8344
8345template <class TARGET_TYPE, class ALLOCATOR>
8347 TARGET_TYPE *toBegin,
8348 TARGET_TYPE *toEnd,
8349 const TARGET_TYPE& value,
8350 size_type numElements,
8351 ALLOCATOR allocator,
8353{
8356
8357 // Key to the transformation diagrams:
8358 //..
8359 // A...G original contents of '[toBegin, toEnd)' ("tail")
8360 // v...v contents of '[fromBegin, fromEnd)' ("input")
8361 // _____ uninitialized array element
8362 // [...] part of an array guarded by an exception guard object
8363 // |.(.,.) part of array guarded by move guard
8364 // (middle indicated by ',' and dest by '|')
8365 //..
8366
8367 const TARGET_TYPE *tempValuePtr = BSLS_UTIL_ADDRESSOF(value);
8368 if (toBegin <= tempValuePtr && tempValuePtr < toEnd + numElements) {
8369 // Adjust pointer for shifting after the move.
8370
8371 tempValuePtr += numElements;
8372 }
8373
8374 size_type tailLen = toEnd - toBegin;
8375 size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8376
8377 //..
8378 // Transformation: ABCDE_______ => _______ABCDE (might overlap)
8379 //..
8380
8381 TARGET_TYPE *destBegin = toBegin + numElements;
8382 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8383 std::memmove((void *)destBegin,
8384 toBegin,
8385 tailLen * sizeof(TARGET_TYPE));
8386 }
8387
8388 //..
8389 // Transformation: |_______(,ABCDE) => vvvvv|__(ABCDE,)
8390 //..
8391
8392 TARGET_TYPE *destEnd = toEnd + numElements;
8393
8394 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8395 destEnd - numGuarded,
8396 destEnd - numGuarded,
8397 destEnd,
8398 allocator);
8399
8400 while (guard.middle() != guard.end()) {
8402 guard.destination(),
8403 *tempValuePtr);
8404 guard.advance();
8405 }
8406
8407 // The bitwise 'guard' is now inactive, since 'middle() == end()' and
8408 // 'guard.destination()' is the smaller of 'destBegin' or 'toEnd'.
8409
8410 if (tailLen < numElements) {
8411 // There still is a gap of 'numElements - tailLen' to fill in between
8412 // 'toEnd' and 'destBegin'. The elements that have been 'memmove'-ed
8413 // need to be guarded, we fill the gap backward from there to keep
8414 // guarded portion in one piece.
8415
8416 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard(destBegin,
8417 destEnd,
8418 allocator);
8419
8420 //..
8421 // Transformation: vvvvv__[ABCDE] => vvvvv[vvABCDE]
8422 //..
8423
8424 while (toEnd != destBegin) {
8426 --destBegin,
8427 *tempValuePtr);
8428
8429 endGuard.moveBegin(-1);
8430 }
8431 endGuard.release();
8432 }
8433}
8434
8435template <class TARGET_TYPE, class ALLOCATOR>
8437 TARGET_TYPE *toBegin,
8438 TARGET_TYPE *toEnd,
8439 const TARGET_TYPE& value,
8440 size_type numElements,
8441 ALLOCATOR allocator,
8443{
8446
8447 // Aliasing: Make a temp copy of 'value' (always). The reason is that
8448 // 'value' could be a reference inside the input range, or even outside
8449 // but with lifetime controlled by one of these values, and so the next
8450 // transformation could invalidate 'value'. Note: One cannot rely on
8451 // 'TARGET_TYPE' to have a single-argument copy constructor (i.e.,
8452 // default allocator argument to 0) if it takes an allocator; hence the
8453 // constructor proxy.
8454
8458 value);
8460 BSLS_UTIL_ADDRESSOF(space.object()));
8461
8462 // Key to the transformation diagrams:
8463 //..
8464 // A...G original contents of '[toBegin, toEnd)' ("tail")
8465 // v...v copies of 'value' ("input")
8466 // _____ uninitialized array elements
8467 // [...] part of array protected by an exception guard object
8468 //..
8469
8470 const size_type tailLen = toEnd - toBegin;
8471 if (tailLen >= numElements) {
8472 // Tail is not shorter than input.
8473
8474 //..
8475 // Transformation: ABCDEFG___[] => ABCDEFG[EFG].
8476 //..
8477
8478 moveIfNoexcept(toEnd, // destination
8479 toEnd - numElements, // source
8480 toEnd, // end source
8481 allocator,
8483
8484 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8485 toEnd + numElements,
8486 allocator);
8487
8488 // TBD: this does the same thing as the old code - don't like that we
8489 // circumvent the whole allocator thing, but for now, let's keep it
8490 // consistent.
8491 // ConstructorProxy<TARGET_TYPE>
8492 // tempValue(value, bslma::Default::allocator());
8493
8494 //..
8495 // Transformation: ABCDEFG[EFG] => ABCABCD[EFG].
8496 //..
8497
8498 TARGET_TYPE *src = toEnd - numElements;
8499 TARGET_TYPE *dest = toEnd;
8500 while (toBegin != src) {
8502 }
8503
8504 //..
8505 // Transformation: ABCABCD[EFG] => vvvABCD[EFG].
8506 //..
8507
8508 for ( ; toBegin != dest; ++toBegin) {
8509 *toBegin = space.object();
8510 }
8511 // TBD: this can't be good
8512 guard.release();
8513 }
8514 else {
8515 // Tail is shorter than input. We can avoid the temp copy of value
8516 // since there will be space to make a first copy after the tail, and
8517 // use that to make the subsequent copies.
8518 //
8519 // TBD: Update comment now that the assumption is no longer true, and
8520 // we make a copy at the top of the call, regardless. We could
8521 // restore this optimization if we use metaprogramming to check if
8522 // 'moveIfNoexcept' will move or copy, but not convinced it is worth
8523 // the complexity.
8524
8525 difference_type remElements = numElements - tailLen;
8526
8527 //..
8528 // Transformation: ABC_______[] => ABC____[ABC].
8529 //..
8530
8531 moveIfNoexcept(toBegin + numElements, // destination
8532 toBegin, // source
8533 toEnd, // end source
8534 allocator,
8536
8537 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd + remElements,
8538 toEnd + numElements,
8539 allocator);
8540
8541 //..
8542 // Transformation: ABC____[ABC] => ABC[vvvvABC].
8543 //..
8544
8545 uninitializedFillN(toEnd,
8546 space.object(),
8547 remElements,
8548 &allocator,
8550 guard.moveBegin(-remElements);
8551
8552 //..
8553 // Transformation: ABC[vvvvABC] => vvv[vvvvABC].
8554 //..
8555
8556 for ( ; toBegin != toEnd; ++toBegin) {
8557 *toBegin = space.object();
8558 }
8559
8560 guard.release();
8561 }
8562}
8563
8564 // *** 'insert' with 'FWD_ITER' overloads: ***
8565
8566
8567template <class TARGET_TYPE, class FWD_ITER, class SENTINEL, class ALLOCATOR>
8568inline
8570 TARGET_TYPE *toBegin,
8571 TARGET_TYPE *toEnd,
8572 FWD_ITER fromBegin,
8573 SENTINEL fromEnd,
8574 size_type numElements,
8575 ALLOCATOR allocator,
8577{
8578 // We may be casting a function pointer to a 'void *' here, so this won't
8579 // work if we port to an architecture where the two are of different sizes.
8580
8581 BSLMF_ASSERT(sizeof(void *) == sizeof(void (*)()));
8582
8583#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
8584 // fall back on traditional C-style casts.
8585 insert((void * *)toBegin,
8586 (void * *)toEnd,
8587 (void * const *)fromBegin,
8588 (void * const *)fromEnd,
8589 numElements,
8590 allocator,
8592#else
8593 typedef typename bsl::remove_cv<
8594 typename bsl::remove_pointer<TARGET_TYPE>::type>::type NcPtrType;
8595
8596 typedef typename bsl::remove_cv<
8597 typename bsl::remove_pointer<
8598 typename bsl::remove_pointer<FWD_ITER>::type>::type>::type NcIter;
8599
8600 insert(
8601 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toBegin)),
8602 reinterpret_cast<void * *>(const_cast<NcPtrType **>(toEnd)),
8603 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromBegin)),
8604 reinterpret_cast<void * const *>(const_cast<NcIter * const *>(fromEnd)),
8605 numElements,
8606 allocator,
8608#endif
8609}
8610
8611template <class TARGET_TYPE, class ALLOCATOR>
8612inline
8614 TARGET_TYPE *toBegin,
8615 TARGET_TYPE *toEnd,
8616 const TARGET_TYPE *fromBegin,
8617 const TARGET_TYPE *fromEnd,
8618 size_type numElements,
8619 ALLOCATOR,
8621{
8623
8624 // 'FWD_ITER' has been converted to a 'const TARGET_TYPE *' and
8625 // 'TARGET_TYPE' is bit-wise copyable.
8628 BSLS_ASSERT_SAFE(fromBegin || 0 == numElements);
8629
8630 BSLS_ASSERT_SAFE(fromBegin + numElements == fromEnd);
8631 BSLS_ASSERT_SAFE(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8632
8633 (void) fromEnd; // quell warning when 'BSLS_ASSERT_SAFE' is compiled out
8634
8635 // Key to the transformation diagrams:
8636 //..
8637 // A...G original contents of '[toBegin, toEnd)' ("tail")
8638 // t...z contents of '[fromBegin, fromEnd)' ("input")
8639 // _____ uninitialized array element
8640 //..
8641
8642 //..
8643 // Transformation: ABCDE_______ => _______ABCDE (might overlap).
8644 //..
8645
8646 const size_type numBytes = reinterpret_cast<const char*>(toEnd)
8647 - reinterpret_cast<const char*>(toBegin);
8648 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numBytes != 0)) {
8649 std::memmove((void *)(toBegin + numElements), toBegin, numBytes);
8650 }
8651
8652 //..
8653 // Transformation: _______ABCDE => tuvwxyzABCDE (no overlap).
8654 //..
8655
8656 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(numElements != 0)) {
8657 std::memcpy((void *)toBegin,
8658 fromBegin,
8659 numElements * sizeof(TARGET_TYPE));
8660 }
8661}
8662
8663template <class TARGET_TYPE, class FWD_ITER, class SENTINEL, class ALLOCATOR>
8665 TARGET_TYPE *toBegin,
8666 TARGET_TYPE *toEnd,
8667 FWD_ITER fromBegin,
8668 SENTINEL,
8669 size_type numElements,
8670 ALLOCATOR allocator,
8672{
8673 // 'TARGET_TYPE' is bit-wise moveable.
8676
8677 if (0 == numElements) {
8678 return; // RETURN
8679 }
8680
8681 // The following assertions make sense only if 'FWD_ITER' is a pointer to a
8682 // possibly cv-qualified 'TARGET_TYPE', and are tested in that overload
8683 // (see above).
8684 //..
8685 // BSLS_ASSERT(fromBegin + numElements == fromEnd);
8686 // BSLS_ASSERT(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8687 //..
8688
8689 // Key to the transformation diagrams:
8690 //..
8691 // A...G original contents of '[toBegin, toEnd)' ("tail")
8692 // t...z contents of '[fromBegin, fromEnd)' ("input")
8693 // _____ uninitialized array element
8694 // [...] part of array guarded by exception guard
8695 // |.(.,.) part of array guarded by move guard
8696 // (middle indicated by ',' and dest by '|')
8697 //..
8698
8699 const size_type tailLen = toEnd - toBegin;
8700 const size_type numGuarded = tailLen < numElements ? tailLen : numElements;
8701
8702 //..
8703 // Transformation: ABCDE____ => ____ABCDE (might overlap).
8704 //..
8705
8706 TARGET_TYPE *destBegin = toBegin + numElements;
8707 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8708 std::memmove((void *)destBegin,
8709 toBegin,
8710 tailLen * sizeof(TARGET_TYPE));
8711 }
8712
8713 //..
8714 // Transformation: |_______(,ABCDE) => tuvwx|__(ABCDE,).
8715 //..
8716
8717 TARGET_TYPE *destEnd = toEnd + numElements;
8718
8719 AutoArrayMoveDestructor<TARGET_TYPE, ALLOCATOR> guard(toBegin,
8720 destEnd - numGuarded,
8721 destEnd - numGuarded,
8722 destEnd,
8723 allocator);
8724
8725 for (; guard.middle() != guard.end(); ++fromBegin) {
8727 guard.destination(),
8728 *fromBegin);
8729 guard.advance();
8730 }
8731
8732 // The bitwise 'guard' is now inactive, since 'middle() == end()', and
8733 // 'guard.destination()' is the smaller of 'destBegin' or 'toEnd'.
8734
8735 if (tailLen < numElements) {
8736 // There still is a gap of 'numElements - tailLen' to fill in between
8737 // 'toEnd' and 'destBegin'. The elements that have been 'memmove'-ed
8738 // need to be guarded, and we need to continue to fill the hole at the
8739 // same guarding the copied elements as well.
8740
8741 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard1(toEnd,
8742 toEnd,
8743 allocator);
8744 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> endGuard2(destBegin,
8745 destEnd,
8746 allocator);
8747
8748 //..
8749 // Transformation: tuvwx[]__[ABCDE] => tuvwx[yz][ABCDE].
8750 //..
8751
8752 for (; toEnd != destBegin; ++fromBegin) {
8754 toEnd,
8755 *fromBegin);
8756 toEnd = endGuard1.moveEnd(1);
8757 }
8758 endGuard1.release();
8759 endGuard2.release();
8760 }
8761}
8762
8763template <class TARGET_TYPE, class FWD_ITER, class SENTINEL, class ALLOCATOR>
8765 TARGET_TYPE *toBegin,
8766 TARGET_TYPE *toEnd,
8767 FWD_ITER fromBegin,
8768 SENTINEL fromEnd,
8769 size_type numElements,
8770 ALLOCATOR allocator,
8772{
8775
8776 if (0 == numElements) {
8777 return; // RETURN
8778 }
8779
8780 // Key to the transformation diagrams:
8781 //..
8782 // A...G original contents of '[toBegin, toEnd)' ("tail")
8783 // t...z contents of '[fromBegin, fromEnd)' ("input")
8784 // _____ uninitialized array elements
8785 // [...] part of array protected by a guard object
8786 //..
8787
8788 const size_type tailLen = toEnd - toBegin;
8789 if (tailLen > numElements) {
8790 // Tail is longer than input.
8791
8792 //..
8793 // Transformation: ABCDEFG___[] => ABCDEFG[EFG].
8794 //..
8795
8796 moveIfNoexcept(toEnd, // destination
8797 toEnd - numElements, // source
8798 toEnd, // end source
8799 allocator,
8801
8802 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd,
8803 toEnd + numElements,
8804 allocator);
8805
8806 //..
8807 // Transformation: ABCDEFG[EFG] => ABCABCD[EFG].
8808 //..
8809
8810 TARGET_TYPE *src = toEnd - numElements;
8811 TARGET_TYPE *dest = toEnd;
8812 while (toBegin != src) {
8814 }
8815
8816 //..
8817 // Transformation: ABCABCD[EFG] => tuvABCD[EFG].
8818 //..
8819
8820 for (; toBegin != dest; ++toBegin, ++fromBegin) {
8821 *toBegin = *fromBegin;
8822 }
8823
8824 guard.release();
8825 }
8826 else {
8827 // Tail is not longer than input (numElements).
8828
8829 difference_type remElements = numElements - tailLen;
8830
8831 //..
8832 // Transformation: ABC_______[] => ABC____[ABC]
8833 //..
8834
8835 moveIfNoexcept(toBegin + numElements, // destination
8836 toBegin, // source
8837 toEnd, // end source
8838 allocator,
8840
8841 AutoArrayDestructor<TARGET_TYPE, ALLOCATOR> guard(toEnd + remElements,
8842 toEnd + numElements,
8843 allocator);
8844
8845 //..
8846 // Transformation: ABC____[ABC] => tuv____[ABC].
8847 //..
8848
8849 for (; toBegin != toEnd; ++fromBegin, ++toBegin) {
8850 *toBegin = *fromBegin;
8851 }
8852
8853 //..
8854 // Transformation: tuv____[ABC] => tuvwxyzABC[].
8855 //..
8856 copyConstruct(toBegin,
8857 fromBegin,
8858 fromEnd,
8859 allocator,
8861
8862 guard.release();
8863 }
8864}
8865
8866template <class FWD_ITER, class SENTINEL, class ALLOCATOR>
8868 void **toBegin,
8869 void **toEnd,
8870 FWD_ITER fromBegin,
8871 SENTINEL,
8872 size_type numElements,
8873 ALLOCATOR,
8875{
8876 // This very specific overload is required for the case that 'FWD_ITER' is
8877 // an iterator that is not a pointer, iterating over a sequence of function
8878 // pointers. The implementation relies on the conditionally-supported
8879 // behavior that any function pointer can be @ref reinterpret_cast to
8880 // 'void *'.
8881
8882 // 'TARGET_TYPE' is bit-wise moveable.
8885
8886 if (0 == numElements) {
8887 return; // RETURN
8888 }
8889
8890 // The following assertions make sense only if 'FWD_ITER' is a pointer to a
8891 // possibly cv-qualified 'TARGET_TYPE', and are tested in that overload
8892 // (see above).
8893 //..
8894 // BSLS_ASSERT(fromBegin + numElements == fromEnd);
8895 // BSLS_ASSERT(fromEnd <= toBegin || toEnd + numElements <= fromBegin);
8896 //..
8897
8898 // Key to the transformation diagrams:
8899 //..
8900 // A...G original contents of '[toBegin, toEnd)' ("tail")
8901 // t...z contents of '[fromBegin, fromEnd)' ("input")
8902 // _____ uninitialized array element
8903 // [...] part of array guarded by exception guard
8904 // |.(.,.) part of array guarded by move guard
8905 // (middle indicated by ',' and dest by '|')
8906 //..
8907
8908 const size_type tailLen = toEnd - toBegin;
8909
8910 //..
8911 // Transformation: ABCDE____ => ____ABCDE (might overlap).
8912 //..
8913
8914 void **destBegin = toBegin + numElements;
8915
8916 if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(tailLen != 0)) {
8917 std::memmove(destBegin, toBegin, tailLen * sizeof(void **));
8918 }
8919
8920 for (size_type i = 0; i < numElements; ++i) {
8921 *toBegin = reinterpret_cast<void *>(*fromBegin);
8922
8923 ++fromBegin;
8924 ++toBegin;
8925 }
8926}
8927
8928 // *** 'moveInsert' overloads: ***
8929
8930template <class TARGET_TYPE, class ALLOCATOR>
8931inline
8933 TARGET_TYPE *toBegin,
8934 TARGET_TYPE *toEnd,
8935 TARGET_TYPE **lastPtr,
8936 TARGET_TYPE *first,
8937 TARGET_TYPE *last,
8938 size_type numElements,
8939 ALLOCATOR allocator,
8941{
8944 BSLS_ASSERT_SAFE(first || 0 == numElements);
8946 BSLS_ASSERT_SAFE(lastPtr);
8947
8948 // Functionally indistinguishable from this:
8949
8950 *lastPtr = last;
8951 insert(toBegin, toEnd, first, last, numElements, allocator,
8953 *lastPtr = first;
8954}
8955
8956template <class TARGET_TYPE, class ALLOCATOR>
8957inline
8959 TARGET_TYPE *toBegin,
8960 TARGET_TYPE *toEnd,
8961 TARGET_TYPE **lastPtr,
8962 TARGET_TYPE *first,
8963 TARGET_TYPE *last,
8964 size_type numElements,
8965 ALLOCATOR allocator,
8967{
8970 BSLS_ASSERT_SAFE(first || 0 == numElements);
8972 BSLS_ASSERT_SAFE(lastPtr);
8973
8974 // There isn't any advantage at destroying [first,last) one by one as we're
8975 // moving it, except perhaps for slightly better memory usage.
8976
8977 *lastPtr = last;
8978 insert(toBegin, toEnd, first, last, numElements, allocator,
8980 ArrayDestructionPrimitives::destroy(first, last, allocator);
8981 *lastPtr = first;
8982}
8983
8984 // *** 'rotate' overloads: ***
8985
8986template <class TARGET_TYPE>
8987inline
8989 TARGET_TYPE *begin,
8990 TARGET_TYPE *middle,
8991 TARGET_TYPE *end,
8993{
8996
8997 bitwiseRotate(reinterpret_cast<char *>(begin),
8998 reinterpret_cast<char *>(middle),
8999 reinterpret_cast<char *>(end));
9000}
9001
9002template <class TARGET_TYPE>
9004 TARGET_TYPE *begin,
9005 TARGET_TYPE *middle,
9006 TARGET_TYPE *end,
9008{
9011
9012 if (begin == middle || middle == end) {
9013 // This test changes into O(1) what would otherwise be O(N): Do not
9014 // remove!
9015
9016 return; // RETURN
9017 }
9018
9019 // This case is simple enough, it should be taken care of on its own.
9020
9021 const std::size_t numElements = middle - begin;
9022 const std::size_t remElements = end - middle;
9023
9024 if (numElements == remElements) {
9025 for (; middle != end; ++begin, ++middle) {
9026 TARGET_TYPE tmp(*middle);
9027 *middle = *begin;
9028 *begin = tmp;
9029 }
9030 return; // RETURN
9031 }
9032
9033 // This algorithm proceeds by decomposing the rotation into cycles, which
9034 // can then be rotated using a single element buffer. First we compute the
9035 // 'gcd(end - begin, numElements)' which is the number of cycles in the
9036 // rotation.
9037
9038 std::size_t numCycles = end - begin;
9039 std::size_t remainder = numElements;
9040 while (remainder != 0) {
9041 std::size_t t = numCycles % remainder;
9042 numCycles = remainder;
9043 remainder = t;
9044 }
9045
9046 // Key to the transformation diagrams:
9047 //..
9048 // A...D Contents of the current cycle
9049 // W...Z Contents of another cycle
9050 // _ Elements not in the current cycle
9051 //..
9052
9053 for (std::size_t i = 0; i < numCycles; ++i) {
9054 // Let the current cycle be initially 'A__B__C__D__', (note that its
9055 // stride is 'length / numCycles') and let (*) denote the current
9056 // position of 'ptr'.
9057
9058 TARGET_TYPE *ptr = begin; // seed for current cycle: A(*)__B__C__D__
9059 TARGET_TYPE tmp = *ptr; // value held at the seed: tmp == A
9060
9061 if (numElements < remElements) {
9062 // Rotate the cycle forward by numElements positions (or backward
9063 // by -(length-numElements)=-remElements positions if crossing the
9064 // boundary forward). The transformation is:
9065 //..
9066 // A(*)__B__C__D__ => B__B(*)__C__D__
9067 // => B__C__C(*)__D__
9068 // => B__C__D__D(*)__
9069 //..
9070 // The length of the cycle is always 'length / numCycles', but it
9071 // crosses the range boundaries 'numElements / numCycles' times,
9072 // each triggering an extra assignment in the 'if' clause below, so
9073 // the loop must only be executed:
9074 //..
9075 // (length - numElements) / numCycles = remElements / numCycles
9076 //..
9077 // times.
9078
9079 std::size_t cycleSize = remElements / numCycles;
9080
9081 for (std::size_t j = 0; j < cycleSize; ++j) {
9082 if (ptr > begin + remElements) {
9083 // Wrap around the range boundaries. (Note that
9084 // '-remElements == numElements - (end - begin)'.)
9085
9086 *ptr = *(ptr - remElements);
9087 ptr -= remElements;
9088 }
9089
9090 *ptr = *(ptr + numElements);
9091 ptr += numElements;
9092 }
9093 }
9094 else {
9095 // Rotate the cycle backward by '-remElements' positions (or
9096 // forward by 'numElements' positions if crossing the boundary
9097 // backward). The transformation is:
9098 //..
9099 // A(*)__B__C__D__ => D__B__C__D(*)__
9100 // => D__B__C(*)__C__
9101 // => D__B(*)__B__C__
9102 //..
9103 // The length of the cycle is always 'length/numCycles', but going
9104 // backward (which adds an initial extra crossing) crosses the
9105 // range boundaries 'remElements/numCycles+1' times each of which
9106 // trigger an extra assignment in the 'if' clause below, so the
9107 // loop must only be executed:
9108 //..
9109 // (length - remElements) / numCycles - 1 =
9110 // numElements / numCycles - 1
9111 //..
9112 // times.
9113
9114 std::size_t cycleSize = numElements / numCycles - 1;
9115
9116 for (std::size_t j = 0; j < cycleSize; ++j) {
9117 if (ptr < end - numElements) {
9118 *ptr = *(ptr + numElements);
9119 ptr += numElements;
9120 }
9121
9122 *ptr = *(ptr - remElements);
9123 ptr -= remElements;
9124 }
9125 }
9126
9127 *ptr = tmp; // Close the cycle, e.g.:
9128 //..
9129 // (first case): B__C__D__D(*)__ => B__C__D__A__
9130 // (second case): D__D(*)__B__C__ => D__A__B__C__
9131 //..
9132 ++begin; // and move on to the next cycle:
9133 //..
9134 // => _W__X__Y__Z_
9135 //..
9136 }
9137}
9138
9139 // *** 'shiftAndInsert' overloads: ***
9140
9141template <class ALLOCATOR>
9142inline
9148 ALLOCATOR allocator,
9150{
9151 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9152
9153 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9154
9155 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9156 // then moving the array first might introduce a change in 'value'.
9157 // Fortunately we can easily predict its new position after the shift.
9158
9159 ValueType *valuePtr =
9161 if (begin <= valuePtr && valuePtr < end) {
9162 valuePtr += 1; // new address after the shift
9163 }
9164
9165#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9166// clang does not support this pragma
9167#pragma GCC diagnostic push
9168#pragma GCC diagnostic ignored "-Wclass-memaccess"
9169#endif
9170
9171 // shift
9172 std::memmove(static_cast<void *>(begin + 1),
9173 begin,
9174 (end - begin) * sizeof(ValueType));
9175
9176 // insert
9178 allocator,
9179 begin,
9181
9182#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9183#pragma GCC diagnostic pop
9184#endif
9185}
9186
9187template <class ALLOCATOR>
9188inline
9194 ALLOCATOR allocator,
9196{
9197 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9198
9199 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9200
9201 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9202 // then moving the array first might introduce a change in 'value'.
9203 // Fortunately we can easily predict its new position after the shift.
9204
9205 ValueType *valuePtr =
9207 if (begin <= valuePtr && valuePtr < end) {
9208 valuePtr += 1; // new address after the shift
9209 }
9210
9211 // shift
9212 size_t bytesNum = (end - begin) * sizeof(ValueType);
9213
9214
9215#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9216// clang does not support this pragma
9217#pragma GCC diagnostic push
9218#pragma GCC diagnostic ignored "-Wclass-memaccess"
9219#endif
9220
9221 std::memmove(static_cast<void *>(begin + 1), begin, bytesNum);
9222
9223
9224 /// Moves the elements back if `construct` throws.
9225 ///
9226 /// See @ref bslalg_arrayprimitives_cpp03
9227 class ElementsProctor {
9228
9229 // DATA
9230 ValueType *d_begin;
9231 size_t d_bytesNum;
9232 public:
9233 // CREATORS
9234 ElementsProctor(ValueType *p, size_t n) : d_begin(p), d_bytesNum(n) {}
9235 ~ElementsProctor()
9236 {
9237 if(d_bytesNum) std::memmove(static_cast<void *>(d_begin),
9238 d_begin + 1,
9239 d_bytesNum);
9240 }
9241 // MANIPULATORS
9242 void release() { d_bytesNum = 0; }
9243 } proctor(begin, bytesNum);
9244
9245
9246 // insert
9248 allocator,
9249 begin,
9251 proctor.release();
9252#if defined(BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC)
9253#pragma GCC diagnostic pop
9254#endif
9255}
9256
9257template <class ALLOCATOR>
9258inline
9264 ALLOCATOR allocator,
9266{
9267 BSLS_ASSERT_SAFE(begin != end); // the range is non-empty
9268
9269 typedef typename bsl::allocator_traits<ALLOCATOR>::value_type ValueType;
9270
9271 // ALIASING: If 'value' is a reference into the array '[begin, end)',
9272 // then moving the array first might introduce a change in 'value'.
9273 // Fortunately we can easily predict its new position after the shift.
9274
9275 ValueType *valuePtr =
9277 if (begin <= valuePtr && valuePtr < end) {
9278 valuePtr += 1; // new address after the shift
9279 }
9280
9281 // Key to the transformation diagrams:
9282 //..
9283 // A...G original contents of '[toBegin, toEnd)' ("tail")
9284 // a...g moved-from or copied values
9285 // v moved 'value' ("input")
9286 // _____ uninitialized array elements
9287 // [...] part of array protected by an exception guard object
9288 //..
9289
9290 //..
9291 // Transformation: ABCDEFG_[] => ABCDEFg[G].
9292 //..
9293
9295 allocator,
9296 end,
9298
9300 end, end + 1, allocator);
9301
9302 //..
9303 // Transformation: ABCDEFg[G] => aABCDEF[G].
9304 //..
9305
9306 ValueType *dst = end;
9307 ValueType *src = end - 1;
9308 while (src != begin) {
9310 }
9311
9312 //..
9313 // Transformation: aABCDEFG[G] => vABCDEF[G].
9314 //..
9315
9317
9318 guard.release();
9319}
9320
9321} // close package namespace
9322
9323#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
9324// ============================================================================
9325// BACKWARD COMPATIBILITY
9326// ============================================================================
9327
9328/// This alias is defined for backward compatibility.
9330#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
9331
9332
9333
9334#if defined(BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER)
9335# undef BSLALG_ARRAYPRIMITIVES_CANNOT_REMOVE_POINTER_FROM_FUNCTION_POINTER
9336#endif
9337
9338#else // if ! defined(DEFINED_BSLALG_ARRAYPRIMITIVES_H)
9339# error Not valid except when included from bslalg_arrayprimitives.h
9340#endif // ! defined(COMPILING_BSLALG_ARRAYPRIMITIVES_H)
9341
9342#endif // ! defined(INCLUDED_BSLALG_ARRAYPRIMITIVES_CPP03)
9343
9344// ----------------------------------------------------------------------------
9345// Copyright 2013 Bloomberg Finance L.P.
9346//
9347// Licensed under the Apache License, Version 2.0 (the "License");
9348// you may not use this file except in compliance with the License.
9349// You may obtain a copy of the License at
9350//
9351// http://www.apache.org/licenses/LICENSE-2.0
9352//
9353// Unless required by applicable law or agreed to in writing, software
9354// distributed under the License is distributed on an "AS IS" BASIS,
9355// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9356// See the License for the specific language governing permissions and
9357// limitations under the License.
9358// ----------------------------- END-OF-FILE ----------------------------------
9359
9360/** @} */
9361/** @} */
9362/** @} */
Definition bslalg_autoarraydestructor.h:232
Definition bslma_allocator.h:545
Definition bslma_destructorproctor.h:259
Definition bslmf_movableref.h:752
bslalg::ArrayPrimitives bslalg_ArrayPrimitives
This alias is defined for backward compatibility.
Definition bslalg_arrayprimitives.h:5061
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_PERFORMANCEHINT_PREDICT_LIKELY(expr)
Definition bsls_performancehint.h:451
#define BSLS_UTIL_ADDRESSOF(OBJ)
Definition bsls_util.h:296
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
Definition bdlc_flathashmap.h:2218
static void construct(ALLOCATOR_TYPE &basicAllocator, ELEMENT_TYPE *elementAddr, Args &&... arguments)
Definition bslma_allocatortraits.h:1527
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR_TYPE >::type pointer
Definition bslma_allocatortraits.h:1180
ALLOCATOR_TYPE::value_type value_type
Definition bslma_allocatortraits.h:1176
Definition bslmf_integralconstant.h:261
Definition bslmf_isenum.h:272
Definition bslmf_isfundamental.h:330
Definition bslmf_ismemberpointer.h:143
Definition bslmf_ispointer.h:138
Definition bslmf_issame.h:146
Definition bslmf_istriviallydefaultconstructible.h:296
Definition bslmf_isvoid.h:138
Definition bslmf_removecv.h:120
Definition bslmf_removepointer.h:262
BloombergLP::bslmf::RemovePointer_Imp< t_TYPE >::Type type
Definition bslmf_removepointer.h:274
static void destroy(TARGET_TYPE *begin, TARGET_TYPE *end, ALLOCATOR allocator, bsl::true_type)
Definition bslalg_arraydestructionprimitives.h:238
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:3762
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:3584
static void bitwiseRotateBackward(char *begin, char *middle, char *end)
static void bitwiseRotate(char *begin, char *middle, char *end)
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:4875
@ k_INPLACE_BUFFER_SIZE
Definition bslalg_arrayprimitives.h:1298
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:3128
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:4664
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:3629
ArrayPrimitives::difference_type difference_type
Definition bslalg_arrayprimitives.h:1277
static void bitwiseRotateForward(char *begin, char *middle, char *end)
@ e_BITWISE_MOVEABLE_TRAITS
Definition bslalg_arrayprimitives.h:1290
@ e_HAS_TRIVIAL_DEFAULT_CTOR_TRAITS
Definition bslalg_arrayprimitives.h:1288
@ e_NIL_TRAITS
Definition bslalg_arrayprimitives.h:1291
@ e_BITWISE_COPYABLE_TRAITS
Definition bslalg_arrayprimitives.h:1289
@ e_IS_FUNDAMENTAL_OR_POINTER
Definition bslalg_arrayprimitives.h:1287
@ e_IS_ITERATOR_TO_FUNCTION_POINTER
Definition bslalg_arrayprimitives.h:1285
@ e_IS_POINTER_TO_POINTER
Definition bslalg_arrayprimitives.h:1286
ArrayPrimitives::size_type size_type
Definition bslalg_arrayprimitives.h:1276
static bool isInvalidRange(FORWARD_ITERATOR begin, SENTINEL end)
Definition bslalg_arrayprimitives.h:3092
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:3718
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:3947
static void rotate(TARGET_TYPE *begin, TARGET_TYPE *middle, TARGET_TYPE *end, bsl::integral_constant< int, e_BITWISE_MOVEABLE_TRAITS >)
Definition bslalg_arrayprimitives.h:4720
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:4016
static void copyConstruct(TARGET_TYPE *toBegin, FWD_ITER fromBegin, SENTINEL fromEnd, ALLOCATOR allocator, bsl::integral_constant< int, e_IS_POINTER_TO_POINTER >)
Definition bslalg_arrayprimitives.h:3471
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:3659
Definition bslalg_arrayprimitives.h:424
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:2553
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:2211
ArrayPrimitives_Imp Imp
Definition bslalg_arrayprimitives.h:428
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:2745
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:2172
static void defaultConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer begin, size_type numElements, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2129
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:3007
static void copyConstruct(typename bsl::allocator_traits< ALLOCATOR >::pointer toBegin, FWD_ITER fromBegin, SENTINEL fromEnd, ALLOCATOR allocator)
Definition bslalg_arrayprimitives.h:2024
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:2656
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:2969
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:2282
std::ptrdiff_t difference_type
Definition bslalg_arrayprimitives.h:430
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:2702
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:1970
std::size_t size_type
Definition bslalg_arrayprimitives.h:429
static void rotate(TARGET_TYPE *first, TARGET_TYPE *middle, TARGET_TYPE *last)
Definition bslalg_arrayprimitives.h:3054
static void construct(TARGET_TYPE *address, const ALLOCATOR &allocator)
Definition bslma_constructionutil.h:1244
static Allocator * allocator(Allocator *basicAllocator=0)
Definition bslma_default.h:913
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_functionpointertraits.h:163
static MovableRef< t_TYPE > move(t_TYPE &reference) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1067
static t_TYPE & access(t_TYPE &ref) BSLS_KEYWORD_NOEXCEPT
Definition bslmf_movableref.h:1039
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:919
@ BSLS_MAX_ALIGNMENT
Definition bsls_alignmentutil.h:300
unsigned long long Uint64
Definition bsls_types.h:139
long long Int64
Definition bsls_types.h:134
Definition bsls_objectbuffer.h:277
TYPE & object()
Definition bsls_objectbuffer.h:352