BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_bidirectionalnodepool_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_bidirectionalnodepool_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_bidirectionalnodepool_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_BIDIRECTIONALNODEPOOL_CPP03
12#define INCLUDED_BSLSTL_BIDIRECTIONALNODEPOOL_CPP03
13
14/// @defgroup bslstl_bidirectionalnodepool_cpp03 bslstl_bidirectionalnodepool_cpp03
15/// @brief Provide C++03 implementation for bslstl_bidirectionalnodepool.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_bidirectionalnodepool_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_bidirectionalnodepool_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_bidirectionalnodepool_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_bidirectionalnodepool_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_bidirectionalnodepool_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_bidirectionalnodepool.h
30///
31/// # Classes {#bslstl_bidirectionalnodepool_cpp03-classes}
32/// See bslstl_bidirectionalnodepool.h for list of classes
33///
34/// @see bslstl_bidirectionalnodepool
35///
36/// # Description {#bslstl_bidirectionalnodepool_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 15:18:45 2024
48/// Command line: sim_cpp11_features.pl bslstl_bidirectionalnodepool.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_bidirectionalnodepool_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_BIDIRECTIONALNODEPOOL_H
64
65
66namespace bslstl {
67
68 // ===========================
69 // class BidirectionalNodePool
70 // ===========================
71
72/// This class provides methods for creating and destroying nodes using the
73/// appropriate allocator-traits of the (template parameter) type
74/// `ALLOCATOR`.
75///
76/// See @ref bslstl_bidirectionalnodepool_cpp03
77template <class VALUE, class ALLOCATOR>
78class BidirectionalNodePool {
79
80 // PRIVATE TYPES
81
82 /// This `typedef` is an alias for the memory pool allocator.
83 typedef SimplePool<bslalg::BidirectionalNode<VALUE>, ALLOCATOR> Pool;
84
85 /// This `typedef` is an alias for the allocator traits defined by
86 /// `SimplePool`.
87 typedef typename Pool::AllocatorTraits AllocatorTraits;
88
89 /// This typedef is a convenient alias for the utility associated with
90 /// movable references.
91 typedef bslmf::MovableRefUtil MoveUtil;
92
93 // DATA
94 Pool d_pool; // pool for allocating memory
95
96 private:
97 // NOT IMPLEMENTED
98 BidirectionalNodePool& operator=(const BidirectionalNodePool&);
99 BidirectionalNodePool(const BidirectionalNodePool&);
100
101 public:
102 // PUBLIC TYPE
103
104 /// Alias for the allocator type defined by `SimplePool`.
105 typedef typename Pool::AllocatorType AllocatorType;
106
107 /// Alias for the `size_type` of the allocator defined by `SimplePool`.
108 typedef typename AllocatorTraits::size_type size_type;
109
110 public:
111 // CREATORS
112
113 /// Create a `BidirectionalNodePool` object that will use the specified
114 /// `allocator` to supply memory for allocated node objects. If the
115 /// (template parameter) `ALLOCATOR` is `bsl::allocator`, then
116 /// `allocator` shall be convertible to `bslma::Allocator *`.
117 explicit BidirectionalNodePool(const ALLOCATOR& allocator);
118
119 /// Create a bidirectional node-pool, adopting all outstanding memory
120 /// allocations associated with the specified `original` node-pool, that
121 /// will use the allocator associated with `original` to supply memory
122 /// for allocated node objects. `original` is left in a valid but
123 /// unspecified state.
124 BidirectionalNodePool(bslmf::MovableRef<BidirectionalNodePool> original);
125
126 /// Destroy the memory pool maintained by this object, releasing all
127 /// memory used by the nodes of the type `BidirectionalNode<VALUE>` in
128 /// the pool. Any memory allocated for the nodes` `value` attribute of
129 /// the (template parameter) type `VALUE` will be leaked unless the
130 /// nodes are explicitly destroyed via the `destroyNode` method.
131 ~BidirectionalNodePool() = default;
132
133 // MANIPULATORS
134
135 /// Adopt all outstanding memory allocations associated with the
136 /// specified node `pool`. The behavior is undefined unless this pool
137 /// uses the same allocator as that associated with `pool`. The
138 /// behavior is also undefined unless this pool is in the
139 /// default-constructed state.
141
142 /// Return a reference providing modifiable access to the allocator
143 /// supplying memory for the memory pool maintained by this object. The
144 /// behavior is undefined if the allocator used by this object is
145 /// changed with this method. Note that this method provides modifiable
146 /// access to enable a client to call non-`const` methods on the
147 /// allocator.
149
150 /// Allocate a node of the type `BidirectionalNode<VALUE>`, and
151 /// copy-construct an object of the (template parameter) type `VALUE`
152 /// having the same value as the specified `original` at the `value`
153 /// attribute of the node. Return the address of the node. Note that
154 /// the `next` and `prev` attributes of the returned node will be
155 /// uninitialized.
157 const bslalg::BidirectionalLink& original);
158
159 /// Destroy the `VALUE` attribute of the specified `linkNode` and return
160 /// the memory footprint of `linkNode` to this pool for potential reuse.
161 /// The behavior is undefined unless `node` refers to a
162 /// `bslalg::BidirectionalNode<VALUE>` that was allocated by this pool.
164
165#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
166// {{{ BEGIN GENERATED CODE
167// Command line: sim_cpp11_features.pl bslstl_bidirectionalnodepool.h
168#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
169#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT 10
170#endif
171#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A
172#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
173#endif
174#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 0
176 );
177#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 0
178
179#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 1
180 template <class Args_01>
182 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
183#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 1
184
185#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 2
186 template <class Args_01,
187 class Args_02>
189 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
190 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
191#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 2
192
193#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 3
194 template <class Args_01,
195 class Args_02,
196 class Args_03>
198 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
199 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
200 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
201#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 3
202
203#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 4
204 template <class Args_01,
205 class Args_02,
206 class Args_03,
207 class Args_04>
209 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
210 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
211 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
212 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
213#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 4
214
215#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 5
216 template <class Args_01,
217 class Args_02,
218 class Args_03,
219 class Args_04,
220 class Args_05>
222 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
223 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
224 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
225 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
226 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
227#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 5
228
229#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 6
230 template <class Args_01,
231 class Args_02,
232 class Args_03,
233 class Args_04,
234 class Args_05,
235 class Args_06>
237 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
238 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
239 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
240 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
241 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
242 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
243#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 6
244
245#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 7
246 template <class Args_01,
247 class Args_02,
248 class Args_03,
249 class Args_04,
250 class Args_05,
251 class Args_06,
252 class Args_07>
254 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
255 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
256 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
257 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
258 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
259 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
260 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
261#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 7
262
263#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 8
264 template <class Args_01,
265 class Args_02,
266 class Args_03,
267 class Args_04,
268 class Args_05,
269 class Args_06,
270 class Args_07,
271 class Args_08>
273 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
274 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
275 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
276 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
277 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
278 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
279 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
280 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
281#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 8
282
283#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 9
284 template <class Args_01,
285 class Args_02,
286 class Args_03,
287 class Args_04,
288 class Args_05,
289 class Args_06,
290 class Args_07,
291 class Args_08,
292 class Args_09>
294 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
295 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
296 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
297 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
298 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
299 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
300 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
301 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
302 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
303#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 9
304
305#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 10
306 template <class Args_01,
307 class Args_02,
308 class Args_03,
309 class Args_04,
310 class Args_05,
311 class Args_06,
312 class Args_07,
313 class Args_08,
314 class Args_09,
315 class Args_10>
317 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
318 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
319 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
320 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
321 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
322 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
324 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
325 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
326 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
327#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 10
328
329#else
330// The generated code below is a workaround for the absence of perfect
331// forwarding in some compilers.
332 template <class... Args>
334 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
335// }}} END GENERATED CODE
336#endif
337
338 /// Allocate a node of the type `BidirectionalNode<VALUE>`, and
339 /// move-construct an object of the (template parameter) type `VALUE`
340 /// with the (explicitly moved) value indicated by the `value` attribute
341 /// of the specified `original` link. Return the address of the node.
342 /// Note that the `next` and `prev` attributes of the returned node will
343 /// be uninitialized. Also note that the `value` attribute of
344 /// `original` is left in a valid but unspecified state.
346 bslalg::BidirectionalLink *original);
347
348 /// Relinquish all memory currently allocated with the memory pool
349 /// maintained by this object.
350 void release();
351
352 /// Add to this pool sufficient memory to satisfy memory requests for at
353 /// least the specified `numNodes` before the pool replenishes. The
354 /// additional memory is added irrespective of the amount of free memory
355 /// when called. The behavior is undefined unless `0 < numNodes`.
356 void reserveNodes(size_type numNodes);
357
358 /// Efficiently exchange the nodes of this object with those of the
359 /// specified `other` object. This method provides the no-throw
360 /// exception-safety guarantee. The behavior is undefined unless
361 /// `allocator() == other.allocator()`.
362 void swapRetainAllocators(BidirectionalNodePool& other);
363
364 /// Efficiently exchange the nodes and the allocator of this object with
365 /// those of the specified `other` object. This method provides the
366 /// no-throw exception-safety guarantee.
367 void swapExchangeAllocators(BidirectionalNodePool& other);
368
369 // ACCESSORS
370
371 /// Return a reference providing non-modifiable access to the allocator
372 /// supplying memory for the memory pool maintained by this object.
373 const AllocatorType& allocator() const;
374};
375
376// FREE FUNCTIONS
377
378/// Efficiently exchange the nodes of the specified `a` object with those of
379/// the specified `b` object. This method provides the no-throw
380/// exception-safety guarantee. The behavior is undefined unless
381/// `a.allocator() == b.allocator()`.
382template <class VALUE, class ALLOCATOR>
383void swap(BidirectionalNodePool<VALUE, ALLOCATOR>& a,
384 BidirectionalNodePool<VALUE, ALLOCATOR>& b);
385
386} // close package namespace
387
388
389// ============================================================================
390// TYPE TRAITS
391// ============================================================================
392
393// Type traits for HashTable:
394//: o A HashTable is bitwise moveable if the allocator is bitwise moveable.
395
396namespace bslmf {
397
398template <class VALUE, class ALLOCATOR>
399struct IsBitwiseMoveable<bslstl::BidirectionalNodePool<VALUE, ALLOCATOR> >
400: bsl::integral_constant<bool, bslmf::IsBitwiseMoveable<ALLOCATOR>::value>
401{};
402
403} // close namespace bslmf
404
405// ============================================================================
406// TEMPLATE AND INLINE FUNCTION DEFINITIONS
407// ============================================================================
408
409namespace bslstl {
410
411// CREATORS
412template <class VALUE, class ALLOCATOR>
413inline
414BidirectionalNodePool<VALUE, ALLOCATOR>::BidirectionalNodePool(
415 const ALLOCATOR& allocator)
416: d_pool(allocator)
417{
418}
419
420template <class VALUE, class ALLOCATOR>
421inline
422BidirectionalNodePool<VALUE, ALLOCATOR>::BidirectionalNodePool(
424: d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
425{
426}
427
428// MANIPULATORS
429template <class VALUE, class ALLOCATOR>
430inline
431void BidirectionalNodePool<VALUE, ALLOCATOR>::adopt(
433{
434 BidirectionalNodePool& lvalue = pool;
435 d_pool.adopt(MoveUtil::move(lvalue.d_pool));
436}
437
438template <class VALUE, class ALLOCATOR>
439inline
440typename
441SimplePool<bslalg::BidirectionalNode<VALUE>, ALLOCATOR>::AllocatorType&
442BidirectionalNodePool<VALUE, ALLOCATOR>::allocator()
443{
444 return d_pool.allocator();
445}
446
447template <class VALUE, class ALLOCATOR>
448inline
450BidirectionalNodePool<VALUE, ALLOCATOR>::cloneNode(
451 const bslalg::BidirectionalLink& original)
452{
453 return emplaceIntoNewNode(
454 static_cast<const bslalg::BidirectionalNode<VALUE>&>(original).value());
455}
456
457#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
458// {{{ BEGIN GENERATED CODE
459// Command line: sim_cpp11_features.pl bslstl_bidirectionalnodepool.h
460#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
461#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT 10
462#endif
463#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B
464#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
465#endif
466#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 0
467template <class VALUE, class ALLOCATOR>
468inline
470BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
471 )
472{
473 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
474 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
475
476 AllocatorTraits::construct(
477 allocator(),
479 proctor.release();
480 return node;
481}
482#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 0
483
484#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 1
485template <class VALUE, class ALLOCATOR>
486template <class Args_01>
487inline
489BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
490 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
491{
492 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
493 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
494
495 AllocatorTraits::construct(
496 allocator(),
498 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01));
499 proctor.release();
500 return node;
501}
502#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 1
503
504#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 2
505template <class VALUE, class ALLOCATOR>
506template <class Args_01,
507 class Args_02>
508inline
510BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
511 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
512 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
513{
514 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
515 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
516
517 AllocatorTraits::construct(
518 allocator(),
520 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
521 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02));
522 proctor.release();
523 return node;
524}
525#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 2
526
527#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 3
528template <class VALUE, class ALLOCATOR>
529template <class Args_01,
530 class Args_02,
531 class Args_03>
532inline
534BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
535 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
536 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
537 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
538{
539 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
540 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
541
542 AllocatorTraits::construct(
543 allocator(),
545 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
546 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
547 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03));
548 proctor.release();
549 return node;
550}
551#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 3
552
553#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 4
554template <class VALUE, class ALLOCATOR>
555template <class Args_01,
556 class Args_02,
557 class Args_03,
558 class Args_04>
559inline
561BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
562 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
563 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
564 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
565 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
566{
567 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
568 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
569
570 AllocatorTraits::construct(
571 allocator(),
573 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
574 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
575 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
576 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04));
577 proctor.release();
578 return node;
579}
580#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 4
581
582#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 5
583template <class VALUE, class ALLOCATOR>
584template <class Args_01,
585 class Args_02,
586 class Args_03,
587 class Args_04,
588 class Args_05>
589inline
591BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
592 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
593 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
594 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
595 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
596 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
597{
598 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
599 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
600
601 AllocatorTraits::construct(
602 allocator(),
604 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
605 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
606 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
607 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
608 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05));
609 proctor.release();
610 return node;
611}
612#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 5
613
614#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 6
615template <class VALUE, class ALLOCATOR>
616template <class Args_01,
617 class Args_02,
618 class Args_03,
619 class Args_04,
620 class Args_05,
621 class Args_06>
622inline
624BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
625 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
626 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
627 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
628 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
629 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
630 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
631{
632 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
633 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
634
635 AllocatorTraits::construct(
636 allocator(),
638 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
639 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
640 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
641 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
642 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
643 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06));
644 proctor.release();
645 return node;
646}
647#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 6
648
649#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 7
650template <class VALUE, class ALLOCATOR>
651template <class Args_01,
652 class Args_02,
653 class Args_03,
654 class Args_04,
655 class Args_05,
656 class Args_06,
657 class Args_07>
658inline
660BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
661 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
662 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
663 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
664 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
665 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
666 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
667 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
668{
669 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
670 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
671
672 AllocatorTraits::construct(
673 allocator(),
675 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
676 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
677 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
678 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
679 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
680 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
681 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07));
682 proctor.release();
683 return node;
684}
685#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 7
686
687#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 8
688template <class VALUE, class ALLOCATOR>
689template <class Args_01,
690 class Args_02,
691 class Args_03,
692 class Args_04,
693 class Args_05,
694 class Args_06,
695 class Args_07,
696 class Args_08>
697inline
699BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
700 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
701 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
702 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
703 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
704 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
705 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
706 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
707 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
708{
709 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
710 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
711
712 AllocatorTraits::construct(
713 allocator(),
715 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
716 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
717 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
718 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
719 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
720 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
721 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
722 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08));
723 proctor.release();
724 return node;
725}
726#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 8
727
728#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 9
729template <class VALUE, class ALLOCATOR>
730template <class Args_01,
731 class Args_02,
732 class Args_03,
733 class Args_04,
734 class Args_05,
735 class Args_06,
736 class Args_07,
737 class Args_08,
738 class Args_09>
739inline
741BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
742 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
743 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
744 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
745 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
746 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
747 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
748 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
749 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
750 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
751{
752 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
753 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
754
755 AllocatorTraits::construct(
756 allocator(),
758 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
759 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
760 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
761 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
762 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
763 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
764 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
765 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
766 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09));
767 proctor.release();
768 return node;
769}
770#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 9
771
772#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 10
773template <class VALUE, class ALLOCATOR>
774template <class Args_01,
775 class Args_02,
776 class Args_03,
777 class Args_04,
778 class Args_05,
779 class Args_06,
780 class Args_07,
781 class Args_08,
782 class Args_09,
783 class Args_10>
784inline
786BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
787 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
788 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
789 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
790 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
791 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
792 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
793 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
794 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
795 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
796 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
797{
798 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
799 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
800
801 AllocatorTraits::construct(
802 allocator(),
804 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
805 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
806 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
807 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
808 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
809 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
810 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
811 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
812 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
813 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10));
814 proctor.release();
815 return node;
816}
817#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 10
818
819#else
820// The generated code below is a workaround for the absence of perfect
821// forwarding in some compilers.
822template <class VALUE, class ALLOCATOR>
823template <class... Args>
824inline
826BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
827 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments)
828{
829 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
830 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
831
832 AllocatorTraits::construct(
833 allocator(),
835 BSLS_COMPILERFEATURES_FORWARD(Args,arguments)...);
836 proctor.release();
837 return node;
838}
839// }}} END GENERATED CODE
840#endif
841
842template <class VALUE, class ALLOCATOR>
843inline
845BidirectionalNodePool<VALUE, ALLOCATOR>::moveIntoNewNode(
847{
848 return emplaceIntoNewNode(MoveUtil::move(
849 static_cast<bslalg::BidirectionalNode<VALUE> *>(original)->value()));
850}
851
852template <class VALUE, class ALLOCATOR>
853void BidirectionalNodePool<VALUE, ALLOCATOR>::deleteNode(
855{
856 BSLS_ASSERT(linkNode);
857
859 static_cast<bslalg::BidirectionalNode<VALUE> *>(linkNode);
860 AllocatorTraits::destroy(allocator(),
862 d_pool.deallocate(node);
863}
864
865template <class VALUE, class ALLOCATOR>
866inline
867void BidirectionalNodePool<VALUE, ALLOCATOR>::release()
868{
869 d_pool.release();
870}
871
872template <class VALUE, class ALLOCATOR>
873inline
874void BidirectionalNodePool<VALUE, ALLOCATOR>::reserveNodes(size_type numNodes)
875{
876 BSLS_ASSERT_SAFE(0 < numNodes);
877
878 d_pool.reserve(numNodes);
879}
880
881template <class VALUE, class ALLOCATOR>
882inline
883void BidirectionalNodePool<VALUE, ALLOCATOR>::swapRetainAllocators(
884 BidirectionalNodePool<VALUE, ALLOCATOR>& other)
885{
886 BSLS_ASSERT_SAFE(allocator() == other.allocator());
887
888 d_pool.quickSwapRetainAllocators(other.d_pool);
889}
890
891template <class VALUE, class ALLOCATOR>
892inline
893void BidirectionalNodePool<VALUE, ALLOCATOR>::swapExchangeAllocators(
894 BidirectionalNodePool<VALUE, ALLOCATOR>& other)
895{
896 d_pool.quickSwapExchangeAllocators(other.d_pool);
897}
898
899// ACCESSORS
900template <class VALUE, class ALLOCATOR>
901inline
902const typename
903 SimplePool<bslalg::BidirectionalNode<VALUE>, ALLOCATOR>::
904 AllocatorType&
905BidirectionalNodePool<VALUE, ALLOCATOR>::allocator() const
906{
907 return d_pool.allocator();
908}
909
910} // close package namespace
911
912template <class VALUE, class ALLOCATOR>
913inline
916{
918}
919
920
921
922#else // if ! defined(DEFINED_BSLSTL_BIDIRECTIONALNODEPOOL_H)
923# error Not valid except when included from bslstl_bidirectionalnodepool.h
924#endif // ! defined(COMPILING_BSLSTL_BIDIRECTIONALNODEPOOL_H)
925
926#endif // ! defined(INCLUDED_BSLSTL_BIDIRECTIONALNODEPOOL_CPP03)
927
928// ----------------------------------------------------------------------------
929// Copyright 2019 Bloomberg Finance L.P.
930//
931// Licensed under the Apache License, Version 2.0 (the "License");
932// you may not use this file except in compliance with the License.
933// You may obtain a copy of the License at
934//
935// http://www.apache.org/licenses/LICENSE-2.0
936//
937// Unless required by applicable law or agreed to in writing, software
938// distributed under the License is distributed on an "AS IS" BASIS,
939// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
940// See the License for the specific language governing permissions and
941// limitations under the License.
942// ----------------------------- END-OF-FILE ----------------------------------
943
944/** @} */
945/** @} */
946/** @} */
Definition bslalg_bidirectionalnode.h:357
ValueType & value()
Definition bslalg_bidirectionalnode.h:404
Definition bslma_deallocatorproctor.h:312
Definition bslmf_movableref.h:751
Definition bslstl_bidirectionalnodepool.h:270
void release()
Definition bslstl_bidirectionalnodepool.h:531
bslalg::BidirectionalLink * cloneNode(const bslalg::BidirectionalLink &original)
Definition bslstl_bidirectionalnodepool.h:479
AllocatorType & allocator()
Definition bslstl_bidirectionalnodepool.h:471
void adopt(bslmf::MovableRef< BidirectionalNodePool > pool)
Definition bslstl_bidirectionalnodepool.h:460
void swapRetainAllocators(BidirectionalNodePool &other)
Definition bslstl_bidirectionalnodepool.h:547
bslalg::BidirectionalLink * emplaceIntoNewNode(Args &&... arguments)
Definition bslstl_bidirectionalnodepool.h:491
AllocatorTraits::size_type size_type
Alias for the size_type of the allocator defined by SimplePool.
Definition bslstl_bidirectionalnodepool.h:300
void swapExchangeAllocators(BidirectionalNodePool &other)
Definition bslstl_bidirectionalnodepool.h:557
Pool::AllocatorType AllocatorType
Alias for the allocator type defined by SimplePool.
Definition bslstl_bidirectionalnodepool.h:297
void deleteNode(bslalg::BidirectionalLink *linkNode)
Definition bslstl_bidirectionalnodepool.h:517
bslalg::BidirectionalLink * moveIntoNewNode(bslalg::BidirectionalLink *original)
Definition bslstl_bidirectionalnodepool.h:509
void reserveNodes(size_type numNodes)
Definition bslstl_bidirectionalnodepool.h:538
Types::AllocatorType AllocatorType
Definition bslstl_simplepool.h:341
Types::AllocatorTraits AllocatorTraits
Definition bslstl_simplepool.h:345
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
void swap(OptionValue &a, OptionValue &b)
Definition bdlbb_blob.h:576
Definition bslstl_algorithm.h:82
void swap(BidirectionalNodePool< VALUE, ALLOCATOR > &a, BidirectionalNodePool< VALUE, ALLOCATOR > &b)
Definition bslmf_integralconstant.h:244
Definition bslmf_movableref.h:791
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:305