BDE 4.39.x 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 specified node `pool`.
136 ///
137 /// \pre The behavior is undefined unless this pool
138 /// uses the same allocator as that associated with `pool`. The
139 /// behavior is also undefined unless this pool is in the
140 /// default-constructed state.
142
143 /// Return a reference providing modifiable access to the allocator
144 /// supplying memory for the memory pool maintained by this object.
145 ///
146 /// \pre The behavior is undefined if the allocator used by this object is changed with this method.
147 ///
148 /// \note Note that this method provides modifiable
149 /// access to enable a client to call non-`const` methods on the
150 /// allocator.
152
153 /// Allocate a node of the type `BidirectionalNode<VALUE>`, and
154 /// copy-construct an object of the (template parameter) type `VALUE`
155 /// having the same value as the specified `original` at the `value`
156 /// attribute of the node. Return the address of the node.
157 ///
158 /// \note Note that the `next` and `prev` attributes of the returned node will be
159 /// uninitialized.
161 const bslalg::BidirectionalLink& original);
162
163 /// Destroy the `VALUE` attribute of the specified `linkNode` and return
164 /// the memory footprint of `linkNode` to this pool for potential reuse.
165 ///
166 /// \pre The behavior is undefined unless `node` refers to a
167 /// `bslalg::BidirectionalNode<VALUE>` that was allocated by this pool.
169
170#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
171// {{{ BEGIN GENERATED CODE
172// Command line: sim_cpp11_features.pl bslstl_bidirectionalnodepool.h
173#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
174#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT 10
175#endif
176#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A
177#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
178#endif
179#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 0
181 );
182#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 0
183
184#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 1
185 template <class Args_01>
187 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01);
188#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 1
189
190#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 2
191 template <class Args_01,
192 class Args_02>
194 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
195 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02);
196#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 2
197
198#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 3
199 template <class Args_01,
200 class Args_02,
201 class Args_03>
203 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
204 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
205 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03);
206#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 3
207
208#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 4
209 template <class Args_01,
210 class Args_02,
211 class Args_03,
212 class Args_04>
214 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
215 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
216 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
217 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04);
218#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 4
219
220#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 5
221 template <class Args_01,
222 class Args_02,
223 class Args_03,
224 class Args_04,
225 class Args_05>
227 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
228 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
229 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
230 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
231 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05);
232#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 5
233
234#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 6
235 template <class Args_01,
236 class Args_02,
237 class Args_03,
238 class Args_04,
239 class Args_05,
240 class Args_06>
242 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
243 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
244 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
245 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
246 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
247 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06);
248#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 6
249
250#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 7
251 template <class Args_01,
252 class Args_02,
253 class Args_03,
254 class Args_04,
255 class Args_05,
256 class Args_06,
257 class Args_07>
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 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
264 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
265 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07);
266#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 7
267
268#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 8
269 template <class Args_01,
270 class Args_02,
271 class Args_03,
272 class Args_04,
273 class Args_05,
274 class Args_06,
275 class Args_07,
276 class Args_08>
278 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
279 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
280 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
281 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
282 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
283 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
284 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
285 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08);
286#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 8
287
288#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 9
289 template <class Args_01,
290 class Args_02,
291 class Args_03,
292 class Args_04,
293 class Args_05,
294 class Args_06,
295 class Args_07,
296 class Args_08,
297 class Args_09>
299 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
300 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
301 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
302 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
303 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
304 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
305 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
306 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
307 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09);
308#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 9
309
310#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 10
311 template <class Args_01,
312 class Args_02,
313 class Args_03,
314 class Args_04,
315 class Args_05,
316 class Args_06,
317 class Args_07,
318 class Args_08,
319 class Args_09,
320 class Args_10>
322 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
323 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
324 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
325 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
326 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
327 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
328 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
329 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
330 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
331 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10);
332#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_A >= 10
333
334#else
335// The generated code below is a workaround for the absence of perfect
336// forwarding in some compilers.
337 template <class... Args>
339 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments);
340// }}} END GENERATED CODE
341#endif
342
343 /// Allocate a node of the type `BidirectionalNode<VALUE>`, and
344 /// move-construct an object of the (template parameter) type `VALUE`
345 /// with the (explicitly moved) value indicated by the `value` attribute
346 /// of the specified `original` link. Return the address of the node.
347 ///
348 /// \note Note that the `next` and `prev` attributes of the returned node will
349 /// be uninitialized. Also note that the `value` attribute of
350 /// `original` is left in a valid but unspecified state.
352 bslalg::BidirectionalLink *original);
353
354 /// Relinquish all memory currently allocated with the memory pool
355 /// maintained by this object.
356 void release();
357
358 /// Add to this pool sufficient memory to satisfy memory requests for at
359 /// least the specified `numNodes` before the pool replenishes. The
360 /// additional memory is added irrespective of the amount of free memory when called.
361 ///
362 /// \pre The behavior is undefined unless `0 < numNodes`.
363 void reserveNodes(size_type numNodes);
364
365 /// Efficiently exchange the nodes of this object with those of the
366 /// specified `other` object. This method provides the no-throw exception-safety guarantee.
367 ///
368 /// \pre The behavior is undefined unless
369 /// `allocator() == other.allocator()`.
370 void swapRetainAllocators(BidirectionalNodePool& other);
371
372 /// Efficiently exchange the nodes and the allocator of this object with
373 /// those of the specified `other` object. This method provides the
374 /// no-throw exception-safety guarantee.
375 void swapExchangeAllocators(BidirectionalNodePool& other);
376
377 // ACCESSORS
378
379 /// Return a reference providing non-modifiable access to the allocator
380 /// supplying memory for the memory pool maintained by this object.
381 const AllocatorType& allocator() const;
382};
383
384// FREE FUNCTIONS
385
386/// Efficiently exchange the nodes of the specified `a` object with those of
387/// the specified `b` object. This method provides the no-throw exception-safety guarantee.
388///
389/// \pre The behavior is undefined unless
390/// `a.allocator() == b.allocator()`.
391template <class VALUE, class ALLOCATOR>
392void swap(BidirectionalNodePool<VALUE, ALLOCATOR>& a,
393 BidirectionalNodePool<VALUE, ALLOCATOR>& b);
394
395} // close package namespace
396
397
398// ============================================================================
399// TYPE TRAITS
400// ============================================================================
401
402// Type traits for HashTable:
403//: o A HashTable is bitwise moveable if the allocator is bitwise moveable.
404
405namespace bslmf {
406
407template <class VALUE, class ALLOCATOR>
408struct IsBitwiseMoveable<bslstl::BidirectionalNodePool<VALUE, ALLOCATOR> >
409: bsl::integral_constant<bool, bslmf::IsBitwiseMoveable<ALLOCATOR>::value>
410{};
411
412} // close namespace bslmf
413
414// ============================================================================
415// TEMPLATE AND INLINE FUNCTION DEFINITIONS
416// ============================================================================
417
418namespace bslstl {
419
420// CREATORS
421template <class VALUE, class ALLOCATOR>
422inline
423BidirectionalNodePool<VALUE, ALLOCATOR>::BidirectionalNodePool(
424 const ALLOCATOR& allocator)
425: d_pool(allocator)
426{
427}
428
429template <class VALUE, class ALLOCATOR>
430inline
431BidirectionalNodePool<VALUE, ALLOCATOR>::BidirectionalNodePool(
433: d_pool(MoveUtil::move(MoveUtil::access(original).d_pool))
434{
435}
436
437// MANIPULATORS
438template <class VALUE, class ALLOCATOR>
439inline
440void BidirectionalNodePool<VALUE, ALLOCATOR>::adopt(
442{
443 BidirectionalNodePool& lvalue = pool;
444 d_pool.adopt(MoveUtil::move(lvalue.d_pool));
445}
446
447template <class VALUE, class ALLOCATOR>
448inline
449typename
450SimplePool<bslalg::BidirectionalNode<VALUE>, ALLOCATOR>::AllocatorType&
451BidirectionalNodePool<VALUE, ALLOCATOR>::allocator()
452{
453 return d_pool.allocator();
454}
455
456template <class VALUE, class ALLOCATOR>
457inline
459BidirectionalNodePool<VALUE, ALLOCATOR>::cloneNode(
460 const bslalg::BidirectionalLink& original)
461{
462 return emplaceIntoNewNode(
463 static_cast<const bslalg::BidirectionalNode<VALUE>&>(original).value());
464}
465
466#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
467// {{{ BEGIN GENERATED CODE
468// Command line: sim_cpp11_features.pl bslstl_bidirectionalnodepool.h
469#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
470#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT 10
471#endif
472#ifndef BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B
473#define BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT
474#endif
475#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 0
476template <class VALUE, class ALLOCATOR>
477inline
479BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
480 )
481{
482 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
483 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
484
485 AllocatorTraits::construct(
486 allocator(),
488 proctor.release();
489 return node;
490}
491#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 0
492
493#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 1
494template <class VALUE, class ALLOCATOR>
495template <class Args_01>
496inline
498BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
499 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01)
500{
501 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
502 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
503
504 AllocatorTraits::construct(
505 allocator(),
507 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01));
508 proctor.release();
509 return node;
510}
511#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 1
512
513#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 2
514template <class VALUE, class ALLOCATOR>
515template <class Args_01,
516 class Args_02>
517inline
519BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
520 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
521 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02)
522{
523 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
524 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
525
526 AllocatorTraits::construct(
527 allocator(),
529 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
530 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02));
531 proctor.release();
532 return node;
533}
534#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 2
535
536#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 3
537template <class VALUE, class ALLOCATOR>
538template <class Args_01,
539 class Args_02,
540 class Args_03>
541inline
543BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
544 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
545 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
546 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03)
547{
548 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
549 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
550
551 AllocatorTraits::construct(
552 allocator(),
554 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
555 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
556 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03));
557 proctor.release();
558 return node;
559}
560#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 3
561
562#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 4
563template <class VALUE, class ALLOCATOR>
564template <class Args_01,
565 class Args_02,
566 class Args_03,
567 class Args_04>
568inline
570BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
571 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
572 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
573 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
574 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04)
575{
576 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
577 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
578
579 AllocatorTraits::construct(
580 allocator(),
582 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
583 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
584 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
585 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04));
586 proctor.release();
587 return node;
588}
589#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 4
590
591#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 5
592template <class VALUE, class ALLOCATOR>
593template <class Args_01,
594 class Args_02,
595 class Args_03,
596 class Args_04,
597 class Args_05>
598inline
600BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
601 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
602 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
603 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
604 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
605 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05)
606{
607 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
608 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
609
610 AllocatorTraits::construct(
611 allocator(),
613 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
614 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
615 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
616 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
617 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05));
618 proctor.release();
619 return node;
620}
621#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 5
622
623#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 6
624template <class VALUE, class ALLOCATOR>
625template <class Args_01,
626 class Args_02,
627 class Args_03,
628 class Args_04,
629 class Args_05,
630 class Args_06>
631inline
633BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
634 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
635 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
636 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
637 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
638 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
639 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06)
640{
641 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
642 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
643
644 AllocatorTraits::construct(
645 allocator(),
647 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
648 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
649 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
650 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
651 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
652 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06));
653 proctor.release();
654 return node;
655}
656#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 6
657
658#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 7
659template <class VALUE, class ALLOCATOR>
660template <class Args_01,
661 class Args_02,
662 class Args_03,
663 class Args_04,
664 class Args_05,
665 class Args_06,
666 class Args_07>
667inline
669BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
670 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
671 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
672 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
673 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
674 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
675 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
676 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07)
677{
678 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
679 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
680
681 AllocatorTraits::construct(
682 allocator(),
684 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
685 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
686 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
687 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
688 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
689 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
690 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07));
691 proctor.release();
692 return node;
693}
694#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 7
695
696#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 8
697template <class VALUE, class ALLOCATOR>
698template <class Args_01,
699 class Args_02,
700 class Args_03,
701 class Args_04,
702 class Args_05,
703 class Args_06,
704 class Args_07,
705 class Args_08>
706inline
708BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
709 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
710 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
711 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
712 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
713 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
714 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
715 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
716 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08)
717{
718 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
719 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
720
721 AllocatorTraits::construct(
722 allocator(),
724 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
725 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
726 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
727 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
728 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
729 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
730 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
731 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08));
732 proctor.release();
733 return node;
734}
735#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 8
736
737#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 9
738template <class VALUE, class ALLOCATOR>
739template <class Args_01,
740 class Args_02,
741 class Args_03,
742 class Args_04,
743 class Args_05,
744 class Args_06,
745 class Args_07,
746 class Args_08,
747 class Args_09>
748inline
750BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
751 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) arguments_01,
752 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) arguments_02,
753 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) arguments_03,
754 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) arguments_04,
755 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) arguments_05,
756 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
757 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
758 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
759 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09)
760{
761 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
762 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
763
764 AllocatorTraits::construct(
765 allocator(),
767 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
768 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
769 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
770 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
771 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
772 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
773 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
774 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
775 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09));
776 proctor.release();
777 return node;
778}
779#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 9
780
781#if BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 10
782template <class VALUE, class ALLOCATOR>
783template <class Args_01,
784 class Args_02,
785 class Args_03,
786 class Args_04,
787 class Args_05,
788 class Args_06,
789 class Args_07,
790 class Args_08,
791 class Args_09,
792 class Args_10>
793inline
795BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
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 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) arguments_06,
802 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) arguments_07,
803 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) arguments_08,
804 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) arguments_09,
805 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) arguments_10)
806{
807 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
808 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
809
810 AllocatorTraits::construct(
811 allocator(),
813 BSLS_COMPILERFEATURES_FORWARD(Args_01,arguments_01),
814 BSLS_COMPILERFEATURES_FORWARD(Args_02,arguments_02),
815 BSLS_COMPILERFEATURES_FORWARD(Args_03,arguments_03),
816 BSLS_COMPILERFEATURES_FORWARD(Args_04,arguments_04),
817 BSLS_COMPILERFEATURES_FORWARD(Args_05,arguments_05),
818 BSLS_COMPILERFEATURES_FORWARD(Args_06,arguments_06),
819 BSLS_COMPILERFEATURES_FORWARD(Args_07,arguments_07),
820 BSLS_COMPILERFEATURES_FORWARD(Args_08,arguments_08),
821 BSLS_COMPILERFEATURES_FORWARD(Args_09,arguments_09),
822 BSLS_COMPILERFEATURES_FORWARD(Args_10,arguments_10));
823 proctor.release();
824 return node;
825}
826#endif // BSLSTL_BIDIRECTIONALNODEPOOL_VARIADIC_LIMIT_B >= 10
827
828#else
829// The generated code below is a workaround for the absence of perfect
830// forwarding in some compilers.
831template <class VALUE, class ALLOCATOR>
832template <class... Args>
833inline
835BidirectionalNodePool<VALUE, ALLOCATOR>::emplaceIntoNewNode(
836 BSLS_COMPILERFEATURES_FORWARD_REF(Args)... arguments)
837{
838 bslalg::BidirectionalNode<VALUE> *node = d_pool.allocate();
839 bslma::DeallocatorProctor<Pool> proctor(node, &d_pool);
840
841 AllocatorTraits::construct(
842 allocator(),
844 BSLS_COMPILERFEATURES_FORWARD(Args,arguments)...);
845 proctor.release();
846 return node;
847}
848// }}} END GENERATED CODE
849#endif
850
851template <class VALUE, class ALLOCATOR>
852inline
854BidirectionalNodePool<VALUE, ALLOCATOR>::moveIntoNewNode(
856{
857 return emplaceIntoNewNode(MoveUtil::move(
858 static_cast<bslalg::BidirectionalNode<VALUE> *>(original)->value()));
859}
860
861template <class VALUE, class ALLOCATOR>
862void BidirectionalNodePool<VALUE, ALLOCATOR>::deleteNode(
864{
865 BSLS_ASSERT(linkNode);
866
868 static_cast<bslalg::BidirectionalNode<VALUE> *>(linkNode);
869 AllocatorTraits::destroy(allocator(),
871 d_pool.deallocate(node);
872}
873
874template <class VALUE, class ALLOCATOR>
875inline
876void BidirectionalNodePool<VALUE, ALLOCATOR>::release()
877{
878 d_pool.release();
879}
880
881template <class VALUE, class ALLOCATOR>
882inline
883void BidirectionalNodePool<VALUE, ALLOCATOR>::reserveNodes(size_type numNodes)
884{
885 BSLS_ASSERT_SAFE(0 < numNodes);
886
887 d_pool.reserve(numNodes);
888}
889
890template <class VALUE, class ALLOCATOR>
891inline
892void BidirectionalNodePool<VALUE, ALLOCATOR>::swapRetainAllocators(
893 BidirectionalNodePool<VALUE, ALLOCATOR>& other)
894{
895 BSLS_ASSERT_SAFE(allocator() == other.allocator());
896
897 d_pool.quickSwapRetainAllocators(other.d_pool);
898}
899
900template <class VALUE, class ALLOCATOR>
901inline
902void BidirectionalNodePool<VALUE, ALLOCATOR>::swapExchangeAllocators(
903 BidirectionalNodePool<VALUE, ALLOCATOR>& other)
904{
905 d_pool.quickSwapExchangeAllocators(other.d_pool);
906}
907
908// ACCESSORS
909template <class VALUE, class ALLOCATOR>
910inline
911const typename
912 SimplePool<bslalg::BidirectionalNode<VALUE>, ALLOCATOR>::
913 AllocatorType&
914BidirectionalNodePool<VALUE, ALLOCATOR>::allocator() const
915{
916 return d_pool.allocator();
917}
918
919} // close package namespace
920
921template <class VALUE, class ALLOCATOR>
922inline
925{
927}
928
929
930
931#else // if ! defined(DEFINED_BSLSTL_BIDIRECTIONALNODEPOOL_H)
932# error Not valid except when included from bslstl_bidirectionalnodepool.h
933#endif // ! defined(COMPILING_BSLSTL_BIDIRECTIONALNODEPOOL_H)
934
935#endif // ! defined(INCLUDED_BSLSTL_BIDIRECTIONALNODEPOOL_CPP03)
936
937// ----------------------------------------------------------------------------
938// Copyright 2019 Bloomberg Finance L.P.
939//
940// Licensed under the Apache License, Version 2.0 (the "License");
941// you may not use this file except in compliance with the License.
942// You may obtain a copy of the License at
943//
944// http://www.apache.org/licenses/LICENSE-2.0
945//
946// Unless required by applicable law or agreed to in writing, software
947// distributed under the License is distributed on an "AS IS" BASIS,
948// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
949// See the License for the specific language governing permissions and
950// limitations under the License.
951// ----------------------------- END-OF-FILE ----------------------------------
952
953/** @} */
954/** @} */
955/** @} */
Definition bslalg_bidirectionalnode.h:357
ValueType & value()
Definition bslalg_bidirectionalnode.h:404
Definition bslma_deallocatorproctor.h:312
Definition bslmf_movableref.h:752
Definition bslstl_bidirectionalnodepool.h:274
void release()
Definition bslstl_bidirectionalnodepool.h:545
bslalg::BidirectionalLink * cloneNode(const bslalg::BidirectionalLink &original)
Definition bslstl_bidirectionalnodepool.h:493
AllocatorType & allocator()
Definition bslstl_bidirectionalnodepool.h:485
void adopt(bslmf::MovableRef< BidirectionalNodePool > pool)
Definition bslstl_bidirectionalnodepool.h:474
void swapRetainAllocators(BidirectionalNodePool &other)
Definition bslstl_bidirectionalnodepool.h:561
bslalg::BidirectionalLink * emplaceIntoNewNode(Args &&... arguments)
Definition bslstl_bidirectionalnodepool.h:505
AllocatorTraits::size_type size_type
Alias for the size_type of the allocator defined by SimplePool.
Definition bslstl_bidirectionalnodepool.h:304
void swapExchangeAllocators(BidirectionalNodePool &other)
Definition bslstl_bidirectionalnodepool.h:571
Pool::AllocatorType AllocatorType
Alias for the allocator type defined by SimplePool.
Definition bslstl_bidirectionalnodepool.h:301
void deleteNode(bslalg::BidirectionalLink *linkNode)
Definition bslstl_bidirectionalnodepool.h:531
bslalg::BidirectionalLink * moveIntoNewNode(bslalg::BidirectionalLink *original)
Definition bslstl_bidirectionalnodepool.h:523
void reserveNodes(size_type numNodes)
Definition bslstl_bidirectionalnodepool.h:552
Types::AllocatorType AllocatorType
Definition bslstl_simplepool.h:343
Types::AllocatorTraits AllocatorTraits
Definition bslstl_simplepool.h:347
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
void swap(OptionValue &a, OptionValue &b)
Definition bdlbb_blob.h:579
Definition bslstl_algorithm.h:84
void swap(BidirectionalNodePool< VALUE, ALLOCATOR > &a, BidirectionalNodePool< VALUE, ALLOCATOR > &b)
Definition bslmf_integralconstant.h:261
Definition bslmf_movableref.h:795
static TYPE * addressOf(TYPE &obj)
Definition bsls_util.h:312