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