BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsltf_stdtestallocator_cpp03.h
Go to the documentation of this file.
1/// @file bsltf_stdtestallocator_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsltf_stdtestallocator_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
12#define INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03
13
14/// @defgroup bsltf_stdtestallocator_cpp03 bsltf_stdtestallocator_cpp03
15/// @brief Provide C++03 implementation for bsltf_stdtestallocator.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsltf
19/// @{
20/// @addtogroup bsltf_stdtestallocator_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsltf_stdtestallocator_cpp03-purpose"> Purpose</a>
25/// * <a href="#bsltf_stdtestallocator_cpp03-classes"> Classes </a>
26/// * <a href="#bsltf_stdtestallocator_cpp03-description"> Description </a>
27///
28/// # Purpose {#bsltf_stdtestallocator_cpp03-purpose}
29/// Provide C++03 implementation for bsltf_stdtestallocator.h
30///
31/// # Classes {#bsltf_stdtestallocator_cpp03-classes}
32/// See bsltf_stdtestallocator.h for list of classes
33///
34/// @see bsltf_stdtestallocator
35///
36/// # Description {#bsltf_stdtestallocator_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Sun Sep 1 05:38:52 2024
48/// Command line: sim_cpp11_features.pl bsltf_stdtestallocator.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bsltf
57 * @{
58 */
59/** @addtogroup bsltf_stdtestallocator_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLTF_STDTESTALLOCATOR_H
64
65
66namespace bsltf {
67
68 // ===================================
69 // class StdTestAllocatorConfiguration
70 // ===================================
71
72/// This `struct` provides a namespace for functions that manipulate and
73/// access the *delegate allocator* for `StdTestAllocator`. The delegate
74/// allocator is the allocator to which `StdTestAllocator` objects delegate
75/// their operations. The provided operations are *not* thread-safe. Note
76/// that this allocator is configured globally as C++03 standard compliant
77/// allocators cannot have individually identifiable state.
78struct StdTestAllocatorConfiguration {
79
80 public:
81 // CLASS METHODS
82
83 /// Set the address of the delegate allocator to the specified
84 /// `basicAllocator`.
85 static void setDelegateAllocatorRaw(bslma::Allocator *basicAllocator);
86
87 /// Return the address of the delegate allocator. Note that, this
88 /// method will initially return
89 /// `&bslma_NewDeleteAllocator::singleton()` if the
90 /// `setDelegatingAllocator` class method has not been called.
92};
93
94 // ========================================
95 // class StdTestAllocatorConfigurationGuard
96 // ========================================
97
98/// Upon construction, an object of this class saves the current *delegate
99/// allocator* for `StdTestAllocator` and and installs the user-specified
100/// allocator as the delegate allocator. The delegate allocator is the
101/// globally configured allocator to which an `StdTestAllocator` objects
102/// delegate their operations. On destruction, the original delegate
103/// allocator is restored.
104///
105/// See @ref bsltf_stdtestallocator_cpp03
106class StdTestAllocatorConfigurationGuard {
107
108 bslma::Allocator *d_original_p; // original (restore at destruction)
109
110 private:
111 // NOT IMPLEMENTED
112 StdTestAllocatorConfigurationGuard(
113 const StdTestAllocatorConfigurationGuard&);
114 StdTestAllocatorConfigurationGuard& operator=(
115 const StdTestAllocatorConfigurationGuard&);
116
117 public:
118 // CREATORS
119
120 /// Create a scoped guard that installs the specified
121 /// `temporaryAllocator` as the delegate allocator.
122 explicit
123 StdTestAllocatorConfigurationGuard(bslma::Allocator *temporaryAllocator);
124
125 /// Restore the delegate allocator that was in place when this scoped
126 /// guard was created and destroy this guard.
128};
129
130
131 // ======================
132 // class StdTestAllocator
133 // ======================
134
135/// This allocator implements the minimal interface to comply with section
136/// 20.1.5 ([lib.allocator.requirements]) of the C++03 standard. Instances
137/// of this allocator delegate their operations to a globally configured
138/// delegate allocator as C++03 compliant allocators cannot have
139/// individually identifiable state (see `StdTestAllocatorConfiguration` and
140/// 'StdTestAllocatorConfigurationGuard).
141///
142/// See @ref bsltf_stdtestallocator_cpp03
143template <class TYPE>
144class StdTestAllocator {
145
146 public:
147 // TRAITS
149
150 // PUBLIC TYPES
151 // Deliberately use types that will *not* have the same representation as
152 // the default 'size_t/ptrdiff_t' on most 64-bit platforms, yet will be
153 // wide enough to support our regular testing, as verified on 32-bit
154 // platforms.
157 typedef TYPE *pointer;
158 typedef const TYPE *const_pointer;
159 typedef TYPE& reference;
160 typedef const TYPE& const_reference;
161 typedef TYPE value_type;
162
163 /// This nested `struct` template, parameterized by some
164 /// `BDE_OTHER_TYPE`, provides a namespace for an `other` type alias,
165 /// which is an allocator type following the same template as this one
166 /// but that allocates elements of `BDE_OTHER_TYPE`. Note that this
167 /// allocator type is convertible to and from `other` for any
168 /// `BDE_OTHER_TYPE` including `void`.
169 template <class BDE_OTHER_TYPE>
170 struct rebind
171 {
172
173 typedef StdTestAllocator<BDE_OTHER_TYPE> other;
174 };
175
176 // CREATORS
177
178 /// Create a `StdTestAllocator` object.
180
181 // StdTestAllocator(const StdTestAllocator& original) = default;
182 // Create a 'StdTestAllocator' object. Note that this object will
183 // compare equal to the default constructed object, because this type
184 // has no state.
185
186 /// Create a `StdTestAllocator` object. Note that this object will
187 /// compare equal to the default constructed object, because this type
188 /// has no state.
189 template <class BDE_OTHER_TYPE>
190 StdTestAllocator(const StdTestAllocator<BDE_OTHER_TYPE>&);
191
192 // ~StdTestAllocator() = default;
193 // Destroy this object.
194
195 // MANIPULATORS
196 // StdTestAllocator& operator=(const StdTestAllocator& rhs) = default;
197 // Assign to this object the value of the specified 'rhs' object, and
198 // return a reference providing modifiable access to this object.
199
200 /// Allocate enough (properly aligned) space for the specified
201 /// `numElements` of type `T`. If the configured delegate allocator is
202 /// unable to fulfill the allocation request, an exception (typically
203 /// `bsl::bad_alloc`) will be thrown. The behavior is undefined unless
204 /// `numElements <= max_size()`.
205 pointer allocate(size_type numElements);
206
207 /// Return memory previously at the specified `address` for
208 /// `numElements` back to this allocator. The `numElements` argument is
209 /// ignored by this allocator type. The behavior is undefined unless
210 /// `address` was allocated using this allocator object and has not
211 /// already been deallocated.
212 void deallocate(pointer address, size_type numElements = 1);
213
214#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
215// {{{ BEGIN GENERATED CODE
216// Command line: sim_cpp11_features.pl bsltf_stdtestallocator.h
217#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
218#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
219#endif
220#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A
221#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
222#endif
223
224#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 0
225 template <class ELEMENT_TYPE>
226 void construct(ELEMENT_TYPE *address);
227#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 0
228
229#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 1
230 template <class ELEMENT_TYPE, class Args_01>
231 void construct(ELEMENT_TYPE *address,
232 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
233#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 1
234
235#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 2
236 template <class ELEMENT_TYPE, class Args_01,
237 class Args_02>
238 void construct(ELEMENT_TYPE *address,
239 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
240 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
241#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 2
242
243#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 3
244 template <class ELEMENT_TYPE, class Args_01,
245 class Args_02,
246 class Args_03>
247 void construct(ELEMENT_TYPE *address,
248 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
249 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
250 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
251#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 3
252
253#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 4
254 template <class ELEMENT_TYPE, class Args_01,
255 class Args_02,
256 class Args_03,
257 class Args_04>
258 void construct(ELEMENT_TYPE *address,
259 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
260 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
261 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
262 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
263#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 4
264
265#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 5
266 template <class ELEMENT_TYPE, class Args_01,
267 class Args_02,
268 class Args_03,
269 class Args_04,
270 class Args_05>
271 void construct(ELEMENT_TYPE *address,
272 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
273 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
274 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
275 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
276 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
277#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 5
278
279#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 6
280 template <class ELEMENT_TYPE, class Args_01,
281 class Args_02,
282 class Args_03,
283 class Args_04,
284 class Args_05,
285 class Args_06>
286 void construct(ELEMENT_TYPE *address,
287 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
288 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
289 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
290 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
291 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
292 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
293#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 6
294
295#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 7
296 template <class ELEMENT_TYPE, class Args_01,
297 class Args_02,
298 class Args_03,
299 class Args_04,
300 class Args_05,
301 class Args_06,
302 class Args_07>
303 void construct(ELEMENT_TYPE *address,
304 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
305 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
306 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
307 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
308 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
309 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
310 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
311#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 7
312
313#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 8
314 template <class ELEMENT_TYPE, class Args_01,
315 class Args_02,
316 class Args_03,
317 class Args_04,
318 class Args_05,
319 class Args_06,
320 class Args_07,
321 class Args_08>
322 void construct(ELEMENT_TYPE *address,
323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
324 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
325 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
326 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
327 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
328 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
329 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
330 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
331#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 8
332
333#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 9
334 template <class ELEMENT_TYPE, class Args_01,
335 class Args_02,
336 class Args_03,
337 class Args_04,
338 class Args_05,
339 class Args_06,
340 class Args_07,
341 class Args_08,
342 class Args_09>
343 void construct(ELEMENT_TYPE *address,
344 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
345 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
346 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
347 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
348 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
349 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
350 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
351 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
352 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
353#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 9
354
355#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 10
356 template <class ELEMENT_TYPE, class Args_01,
357 class Args_02,
358 class Args_03,
359 class Args_04,
360 class Args_05,
361 class Args_06,
362 class Args_07,
363 class Args_08,
364 class Args_09,
365 class Args_10>
366 void construct(ELEMENT_TYPE *address,
367 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
368 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
369 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
370 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
371 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
372 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
373 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
374 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
375 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
376 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
377#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 10
378
379#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 11
380 template <class ELEMENT_TYPE, class Args_01,
381 class Args_02,
382 class Args_03,
383 class Args_04,
384 class Args_05,
385 class Args_06,
386 class Args_07,
387 class Args_08,
388 class Args_09,
389 class Args_10,
390 class Args_11>
391 void construct(ELEMENT_TYPE *address,
392 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
393 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
394 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
395 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
396 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
397 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
398 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
399 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
400 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
401 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
402 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11);
403#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 11
404
405#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 12
406 template <class ELEMENT_TYPE, class Args_01,
407 class Args_02,
408 class Args_03,
409 class Args_04,
410 class Args_05,
411 class Args_06,
412 class Args_07,
413 class Args_08,
414 class Args_09,
415 class Args_10,
416 class Args_11,
417 class Args_12>
418 void construct(ELEMENT_TYPE *address,
419 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
420 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
421 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
422 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
423 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
424 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
425 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
426 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
427 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
428 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
429 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
430 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12);
431#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 12
432
433#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 13
434 template <class ELEMENT_TYPE, class Args_01,
435 class Args_02,
436 class Args_03,
437 class Args_04,
438 class Args_05,
439 class Args_06,
440 class Args_07,
441 class Args_08,
442 class Args_09,
443 class Args_10,
444 class Args_11,
445 class Args_12,
446 class Args_13>
447 void construct(ELEMENT_TYPE *address,
448 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
449 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
450 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
451 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
452 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
453 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
454 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
455 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
456 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
457 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
458 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
459 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12,
460 BSLS_COMPILERFEATURES_FORWARD_REF(Args_13) arguments_13);
461#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 13
462
463#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 14
464 template <class ELEMENT_TYPE, class Args_01,
465 class Args_02,
466 class Args_03,
467 class Args_04,
468 class Args_05,
469 class Args_06,
470 class Args_07,
471 class Args_08,
472 class Args_09,
473 class Args_10,
474 class Args_11,
475 class Args_12,
476 class Args_13,
477 class Args_14>
478 void construct(ELEMENT_TYPE *address,
479 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
480 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
481 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
482 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
483 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
484 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
485 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
486 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
487 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
488 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
489 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
490 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12,
491 BSLS_COMPILERFEATURES_FORWARD_REF(Args_13) arguments_13,
492 BSLS_COMPILERFEATURES_FORWARD_REF(Args_14) arguments_14);
493#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_A >= 14
494
495#else
496// The generated code below is a workaround for the absence of perfect
497// forwarding in some compilers.
498
499 template <class ELEMENT_TYPE, class... Args>
500 void construct(ELEMENT_TYPE *address,
501 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
502// }}} END GENERATED CODE
503#endif
504
505 /// Call the `ELEMENT_TYPE` destructor for the object at the specified
506 /// `address` but do not deallocate the memory at `address`.
507 template <class ELEMENT_TYPE>
508 void destroy(ELEMENT_TYPE *address);
509
510 // ACCESSORS
511
512 /// Return the address providing modifiable access to `object`.
513 pointer address(reference object) const;
514
515 /// Return the address providing non-modifiable access to `object`.
517
518 /// Return the maximum number of elements of type `TYPE` that can be
519 /// allocated using this allocator in a single call to the `allocate`
520 /// method. Note that there is no guarantee that attempts at allocating
521 /// less elements than the value returned by @ref max_size will not throw.
522 size_type max_size() const;
523};
524
525 // ============================
526 // class StdTestAllocator<void>
527 // ============================
528
529/// This specialization of `StdTestAllocator` for `void` type as the
530/// parameterized `TYPE` does not contain members that are unrepresentable
531/// for `void`.
532template <>
533class StdTestAllocator<void> {
534
535 public:
536 // PUBLIC TYPES
537
538 // 'size_type' and @ref difference_type were deliberately changed from fixed
539 // 32 bit types to being the size of a pointer, to avoid a cascade of
540 // warnings on 64-bit builds.
541
544 typedef void *pointer;
545 typedef const void *const_pointer;
546 typedef void value_type;
547
548 /// This nested `struct` template, parameterized by some
549 /// `BDE_OTHER_TYPE`, provides a namespace for an `other` type alias,
550 /// which is an allocator type following the same template as this one
551 /// but that allocates elements of `BDE_OTHER_TYPE`. Note that this
552 /// allocator type is convertible to and from `other` for any
553 /// `BDE_OTHER_TYPE` including `void`.
554 template <class BDE_OTHER_TYPE>
555 struct rebind
556 {
557
558 typedef StdTestAllocator<BDE_OTHER_TYPE> other;
559 };
560
561 // CREATORS
562
563 /// Create a `StdTestAllocator` object.
565
566 // StdTestAllocator(const StdTestAllocator& original) = default;
567 // Create a 'StdTestAllocator' object. Note that this object will
568 // compare equal to the default constructed object because, because
569 // this type has no state.
570
571 /// Create a `StdTestAllocator` object. Note that this object will
572 /// compare equal to the default constructed object because, because
573 /// this type has no state.
574 template <class BDE_OTHER_TYPE>
575 StdTestAllocator(const StdTestAllocator<BDE_OTHER_TYPE>&);
576
577 // ~StdTestAllocator() = default;
578 // Destroy this object.
579
580 // MANIPULATORS
581 // StdTestAllocator& operator=(
582 // const StdTestAllocator& rhs) = default;
583 // Assign to this object the value of the specified 'rhs' object, and
584 // return a reference providing modifiable access to this object.
585};
586
587// FREE OPERATORS
588
589/// Return `true` because `StdTestAllocator` does not hold a state.
590template <class TYPE1, class TYPE2>
591bool operator==(const StdTestAllocator<TYPE1>& lhs,
592 const StdTestAllocator<TYPE2>& rhs);
593
594/// Return `false` because `StdTestAllocator` does not hold a state.
595template <class TYPE1, class TYPE2>
596bool operator!=(const StdTestAllocator<TYPE1>& lhs,
597 const StdTestAllocator<TYPE2>& rhs);
598
599
600 // ======================
601 // class StdTestAllocator
602 // ======================
603
604/// This `struct` provides a namespace for utilities that are common to
605/// all instantiations of the `StdTestAllocator` class template.
606struct StdTestAllocator_CommonUtil {
607
608 // CLASS METHODS
609
610 /// Return the maximum number of objects, each taking the specified
611 /// `elementSize` bytes of storage, that can potentially be allocated by
612 /// a `StdTestAllocator`. Note that this function is mostly about
613 /// insulating consumers of this component from a standard header, so
614 /// that this test component does not hide missing header dependencies
615 /// in testing scenarios.
616 static size_t maxSize(size_t elementSize);
617};
618
619// ============================================================================
620// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
621// ============================================================================
622
623 // ----------------------------------------
624 // class StdTestAllocatorConfigurationGuard
625 // ----------------------------------------
626
627// CREATORS
628inline
629StdTestAllocatorConfigurationGuard::StdTestAllocatorConfigurationGuard(
630 bslma::Allocator *temporaryAllocator)
631: d_original_p(StdTestAllocatorConfiguration::delegateAllocator())
632{
633 BSLS_ASSERT(temporaryAllocator);
634
635 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(temporaryAllocator);
636}
637
638inline
639StdTestAllocatorConfigurationGuard::~StdTestAllocatorConfigurationGuard()
640{
641 BSLS_ASSERT(d_original_p);
642
643 StdTestAllocatorConfiguration::setDelegateAllocatorRaw(d_original_p);
644}
645
646 // ----------------------
647 // class StdTestAllocator
648 // ----------------------
649
650// CREATORS
651template <class TYPE>
652inline
653StdTestAllocator<TYPE>::StdTestAllocator()
654{
655}
656
657template <class TYPE>
658template <class BDE_OTHER_TYPE>
659StdTestAllocator<TYPE>::StdTestAllocator(
660 const StdTestAllocator<BDE_OTHER_TYPE>&)
661{
662}
663
664// MANIPULATORS
665template <class TYPE>
666inline
667typename StdTestAllocator<TYPE>::pointer
668StdTestAllocator<TYPE>::allocate(typename StdTestAllocator<TYPE>::size_type
669 numElements)
670{
671 if (numElements > this->max_size()) {
672 BloombergLP::bsls::BslExceptionUtil::throwBadAlloc();
673 }
674
675 return
676 static_cast<pointer>(StdTestAllocatorConfiguration::delegateAllocator()->
677 allocate(bslma::Allocator::size_type(numElements * sizeof(TYPE))));
678}
679
680template <class TYPE>
681inline
682void StdTestAllocator<TYPE>::deallocate(pointer address, size_type)
683{
684 StdTestAllocatorConfiguration::delegateAllocator()->deallocate(address);
685}
686
687#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
688// {{{ BEGIN GENERATED CODE
689// Command line: sim_cpp11_features.pl bsltf_stdtestallocator.h
690#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
691#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT 14
692#endif
693#ifndef BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B
694#define BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT
695#endif
696#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 0
697template <class TYPE>
698template <class ELEMENT_TYPE>
699inline void
700StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address)
701{
702 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
703 );
704}
705#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 0
706
707#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 1
708template <class TYPE>
709template <class ELEMENT_TYPE, class Args_01>
710inline void
711StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
712 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
713{
714 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
715 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01));
716}
717#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 1
718
719#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 2
720template <class TYPE>
721template <class ELEMENT_TYPE, class Args_01,
722 class Args_02>
723inline void
724StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
725 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
726 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
727{
728 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
729 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
730 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02));
731}
732#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 2
733
734#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 3
735template <class TYPE>
736template <class ELEMENT_TYPE, class Args_01,
737 class Args_02,
738 class Args_03>
739inline void
740StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
741 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
742 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
743 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
744{
745 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
746 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
747 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
748 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03));
749}
750#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 3
751
752#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 4
753template <class TYPE>
754template <class ELEMENT_TYPE, class Args_01,
755 class Args_02,
756 class Args_03,
757 class Args_04>
758inline void
759StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
760 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
761 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
762 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
763 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
764{
765 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
766 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
767 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
768 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
769 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04));
770}
771#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 4
772
773#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 5
774template <class TYPE>
775template <class ELEMENT_TYPE, class Args_01,
776 class Args_02,
777 class Args_03,
778 class Args_04,
779 class Args_05>
780inline void
781StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
782 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
783 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
784 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
785 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
786 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
787{
788 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
789 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
790 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
791 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
792 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
793 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05));
794}
795#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 5
796
797#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 6
798template <class TYPE>
799template <class ELEMENT_TYPE, class Args_01,
800 class Args_02,
801 class Args_03,
802 class Args_04,
803 class Args_05,
804 class Args_06>
805inline void
806StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
807 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
808 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
809 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
810 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
811 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
812 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
813{
814 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
815 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
816 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
817 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
818 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
819 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
820 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06));
821}
822#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 6
823
824#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 7
825template <class TYPE>
826template <class ELEMENT_TYPE, class Args_01,
827 class Args_02,
828 class Args_03,
829 class Args_04,
830 class Args_05,
831 class Args_06,
832 class Args_07>
833inline void
834StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
835 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
836 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
837 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
838 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
839 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
840 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
841 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
842{
843 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
844 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
845 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
846 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
847 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
848 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
849 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
850 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07));
851}
852#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 7
853
854#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 8
855template <class TYPE>
856template <class ELEMENT_TYPE, class Args_01,
857 class Args_02,
858 class Args_03,
859 class Args_04,
860 class Args_05,
861 class Args_06,
862 class Args_07,
863 class Args_08>
864inline void
865StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
866 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
867 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
868 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
869 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
870 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
871 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
872 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
873 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
874{
875 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
876 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
877 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
878 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
879 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
880 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
881 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
882 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
883 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08));
884}
885#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 8
886
887#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 9
888template <class TYPE>
889template <class ELEMENT_TYPE, class Args_01,
890 class Args_02,
891 class Args_03,
892 class Args_04,
893 class Args_05,
894 class Args_06,
895 class Args_07,
896 class Args_08,
897 class Args_09>
898inline void
899StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
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 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
909{
910 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
911 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
912 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
913 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
914 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
915 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
916 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
917 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
918 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
919 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09));
920}
921#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 9
922
923#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 10
924template <class TYPE>
925template <class ELEMENT_TYPE, class Args_01,
926 class Args_02,
927 class Args_03,
928 class Args_04,
929 class Args_05,
930 class Args_06,
931 class Args_07,
932 class Args_08,
933 class Args_09,
934 class Args_10>
935inline void
936StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
937 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
938 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
939 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
940 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
941 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
942 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
943 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
944 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
945 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
946 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
947{
948 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
949 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
950 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
951 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
952 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
953 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
954 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
955 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
956 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
957 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
958 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10));
959}
960#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 10
961
962#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 11
963template <class TYPE>
964template <class ELEMENT_TYPE, class Args_01,
965 class Args_02,
966 class Args_03,
967 class Args_04,
968 class Args_05,
969 class Args_06,
970 class Args_07,
971 class Args_08,
972 class Args_09,
973 class Args_10,
974 class Args_11>
975inline void
976StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
977 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
978 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
979 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
980 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
981 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
982 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
983 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
984 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
985 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
986 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
987 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11)
988{
989 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
990 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
991 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
992 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
993 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
994 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
995 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
996 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
997 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
998 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
999 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10),
1000 BSLS_COMPILERFEATURES_FORWARD(Args_11,arguments_11));
1001}
1002#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 11
1003
1004#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 12
1005template <class TYPE>
1006template <class ELEMENT_TYPE, class Args_01,
1007 class Args_02,
1008 class Args_03,
1009 class Args_04,
1010 class Args_05,
1011 class Args_06,
1012 class Args_07,
1013 class Args_08,
1014 class Args_09,
1015 class Args_10,
1016 class Args_11,
1017 class Args_12>
1018inline void
1019StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1020 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1021 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1022 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1023 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1024 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1027 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1028 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1029 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
1030 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
1031 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12)
1032{
1033 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
1034 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
1035 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
1036 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
1037 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
1038 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
1039 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
1040 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
1041 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
1042 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
1043 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10),
1044 BSLS_COMPILERFEATURES_FORWARD(Args_11,arguments_11),
1045 BSLS_COMPILERFEATURES_FORWARD(Args_12,arguments_12));
1046}
1047#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 12
1048
1049#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 13
1050template <class TYPE>
1051template <class ELEMENT_TYPE, class Args_01,
1052 class Args_02,
1053 class Args_03,
1054 class Args_04,
1055 class Args_05,
1056 class Args_06,
1057 class Args_07,
1058 class Args_08,
1059 class Args_09,
1060 class Args_10,
1061 class Args_11,
1062 class Args_12,
1063 class Args_13>
1064inline void
1065StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1066 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1067 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1068 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1069 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1070 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1071 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1072 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1073 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1074 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1075 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
1076 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
1077 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12,
1078 BSLS_COMPILERFEATURES_FORWARD_REF(Args_13) arguments_13)
1079{
1080 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
1081 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
1082 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
1083 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
1084 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
1085 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
1086 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
1087 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
1088 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
1089 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
1090 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10),
1091 BSLS_COMPILERFEATURES_FORWARD(Args_11,arguments_11),
1092 BSLS_COMPILERFEATURES_FORWARD(Args_12,arguments_12),
1093 BSLS_COMPILERFEATURES_FORWARD(Args_13,arguments_13));
1094}
1095#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 13
1096
1097#if BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 14
1098template <class TYPE>
1099template <class ELEMENT_TYPE, class Args_01,
1100 class Args_02,
1101 class Args_03,
1102 class Args_04,
1103 class Args_05,
1104 class Args_06,
1105 class Args_07,
1106 class Args_08,
1107 class Args_09,
1108 class Args_10,
1109 class Args_11,
1110 class Args_12,
1111 class Args_13,
1112 class Args_14>
1113inline void
1114StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1115 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
1116 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
1117 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
1118 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
1119 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
1120 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
1121 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
1122 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
1123 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
1124 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10,
1125 BSLS_COMPILERFEATURES_FORWARD_REF(Args_11) arguments_11,
1126 BSLS_COMPILERFEATURES_FORWARD_REF(Args_12) arguments_12,
1127 BSLS_COMPILERFEATURES_FORWARD_REF(Args_13) arguments_13,
1128 BSLS_COMPILERFEATURES_FORWARD_REF(Args_14) arguments_14)
1129{
1130 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
1131 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
1132 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
1133 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
1134 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
1135 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
1136 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
1137 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
1138 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
1139 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
1140 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10),
1141 BSLS_COMPILERFEATURES_FORWARD(Args_11,arguments_11),
1142 BSLS_COMPILERFEATURES_FORWARD(Args_12,arguments_12),
1143 BSLS_COMPILERFEATURES_FORWARD(Args_13,arguments_13),
1144 BSLS_COMPILERFEATURES_FORWARD(Args_14,arguments_14));
1145}
1146#endif // BSLTF_STDTESTALLOCATOR_VARIADIC_LIMIT_B >= 14
1147
1148#else
1149// The generated code below is a workaround for the absence of perfect
1150// forwarding in some compilers.
1151template <class TYPE>
1152template <class ELEMENT_TYPE, class... Args>
1153inline void
1154StdTestAllocator<TYPE>::construct(ELEMENT_TYPE *address,
1155 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments)
1156{
1157 ::new (static_cast<void*>(address)) ELEMENT_TYPE(
1158 BSLS_COMPILERFEATURES_FORWARD(Args,arguments)...);
1159}
1160// }}} END GENERATED CODE
1161#endif
1162
1163template <class TYPE>
1164template <class ELEMENT_TYPE>
1165inline
1166void StdTestAllocator<TYPE>::destroy(ELEMENT_TYPE *address)
1167{
1168 address->~ELEMENT_TYPE();
1169}
1170
1171template <class TYPE>
1172inline
1173typename StdTestAllocator<TYPE>::pointer
1174StdTestAllocator<TYPE>::address(reference object) const
1175{
1176 return bsls::Util::addressOf(object);
1177}
1178
1179template <class TYPE>
1180inline
1181typename StdTestAllocator<TYPE>::const_pointer
1182StdTestAllocator<TYPE>::address(const_reference object) const
1183{
1184 return bsls::Util::addressOf(object);
1185}
1186
1187template <class TYPE>
1188inline
1189typename StdTestAllocator<TYPE>::size_type
1190StdTestAllocator<TYPE>::max_size() const
1191{
1192 return StdTestAllocator_CommonUtil::maxSize(sizeof(TYPE));
1193}
1194
1195 // ----------------------------
1196 // class StdTestAllocator<void>
1197 // ----------------------------
1198
1199// CREATORS
1200inline
1201StdTestAllocator<void>::StdTestAllocator()
1202{
1203}
1204
1205template <class BDE_OTHER_TYPE>
1206StdTestAllocator<void>::StdTestAllocator(
1207 const StdTestAllocator<BDE_OTHER_TYPE>&)
1208{
1209}
1210
1211// FREE OPERATORS
1212template <class TYPE1, class TYPE2>
1213inline
1216{
1217 return true;
1218}
1219
1220template <class TYPE1, class TYPE2>
1221inline
1224{
1225 return false;
1226}
1227
1228} // close package namespace
1229
1230
1231#else // if ! defined(DEFINED_BSLTF_STDTESTALLOCATOR_H)
1232# error Not valid except when included from bsltf_stdtestallocator.h
1233#endif // ! defined(COMPILING_BSLTF_STDTESTALLOCATOR_H)
1234
1235#endif // ! defined(INCLUDED_BSLTF_STDTESTALLOCATOR_CPP03)
1236
1237// ----------------------------------------------------------------------------
1238// Copyright 2013 Bloomberg Finance L.P.
1239//
1240// Licensed under the Apache License, Version 2.0 (the "License");
1241// you may not use this file except in compliance with the License.
1242// You may obtain a copy of the License at
1243//
1244// http://www.apache.org/licenses/LICENSE-2.0
1245//
1246// Unless required by applicable law or agreed to in writing, software
1247// distributed under the License is distributed on an "AS IS" BASIS,
1248// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1249// See the License for the specific language governing permissions and
1250// limitations under the License.
1251// ----------------------------- END-OF-FILE ----------------------------------
1252
1253/** @} */
1254/** @} */
1255/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
Definition bslma_allocator.h:457
std::size_t size_type
Definition bslma_allocator.h:499
~StdTestAllocatorConfigurationGuard()
Definition bsltf_stdtestallocator.h:484
Definition bsltf_stdtestallocator.h:267
const TYPE * const_pointer
Definition bsltf_stdtestallocator.h:281
pointer address(reference object) const
Return the address providing modifiable access to object.
Definition bsltf_stdtestallocator.h:554
pointer allocate(size_type numElements)
bsls::Types::UintPtr size_type
Definition bsltf_stdtestallocator.h:278
StdTestAllocator()
Create a StdTestAllocator object.
Definition bsltf_stdtestallocator.h:498
bsls::Types::IntPtr difference_type
Definition bsltf_stdtestallocator.h:279
const TYPE & const_reference
Definition bsltf_stdtestallocator.h:283
TYPE * pointer
Definition bsltf_stdtestallocator.h:280
void construct(ELEMENT_TYPE *address, Args &&... arguments)
Definition bsltf_stdtestallocator.h:536
size_type max_size() const
Definition bsltf_stdtestallocator.h:570
TYPE value_type
Definition bsltf_stdtestallocator.h:284
void deallocate(pointer address, size_type numElements=1)
Definition bsltf_stdtestallocator.h:527
TYPE & reference
Definition bsltf_stdtestallocator.h:282
void destroy(ELEMENT_TYPE *address)
Definition bsltf_stdtestallocator.h:546
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
Definition bsltf_allocargumenttype.h:92
Definition bslma_isstdallocator.h:201
std::size_t UintPtr
Definition bsls_types.h:126
std::ptrdiff_t IntPtr
Definition bsls_types.h:130
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:305
static void setDelegateAllocatorRaw(bslma::Allocator *basicAllocator)
static bslma::Allocator * delegateAllocator()
StdTestAllocator< BDE_OTHER_TYPE > other
Definition bsltf_stdtestallocator.h:296
static size_t maxSize(size_t elementSize)