BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_priorityqueue_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_priorityqueue_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_priorityqueue_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_PRIORITYQUEUE_CPP03
12#define INCLUDED_BSLSTL_PRIORITYQUEUE_CPP03
13
14/// @defgroup bslstl_priorityqueue_cpp03 bslstl_priorityqueue_cpp03
15/// @brief Provide C++03 implementation for bslstl_priorityqueue.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_priorityqueue_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_priorityqueue_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_priorityqueue_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_priorityqueue_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_priorityqueue_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_priorityqueue.h
30///
31/// # Classes {#bslstl_priorityqueue_cpp03-classes}
32/// See bslstl_priorityqueue.h for list of classes
33///
34/// @see bslstl_priorityqueue
35///
36/// # Description {#bslstl_priorityqueue_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 Wed Jun 3 10:06:09 2026
48/// Command line: sim_cpp11_features.pl bslstl_priorityqueue.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_priorityqueue_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_PRIORITYQUEUE_H
64
65namespace bsl {
66
67 // ====================
68 // class priority_queue
69 // ====================
70
71/// This class is a value-semantic class template, adapting a container of
72/// the (template parameter) type `CONTAINER`, that holds elements of the
73/// (template parameter) type `VALUE`, to provide a highest-priority-first
74/// priority queue data structure, where the priorities of elements are
75/// compared by a comparator of the template parameter type, `COMPARATOR`.
76/// The container object held by a @ref priority_queue class object is
77/// referenced as `c` in the following documentation.
78///
79/// See @ref bslstl_priorityqueue_cpp03
80template <class VALUE,
81 class CONTAINER = vector<VALUE>,
82 class COMPARATOR = std::less<typename CONTAINER::value_type> >
83class priority_queue {
84
85#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
86 // STATIC CHECK: Type mismatch is UB per C++17
88#endif
89
90 private:
91 // PRIVATE TYPES
92
93 /// This `typedef` is a convenient alias for the utility associated with
94 /// movable references.
95 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
96
97 // PRIVATE MANIPULATORS
98
99 /// Push onto the back of the underlying container the elements of the
100 /// specified `[first, last)` range.
101 template <class INPUT_ITER, class SENTINEL>
102 void privatePushRange(INPUT_ITER first, SENTINEL last);
103
104 public:
105 // PUBLIC TYPES
106 typedef CONTAINER container_type;
107 typedef COMPARATOR value_compare;
108 typedef typename CONTAINER::value_type value_type;
109 typedef typename CONTAINER::reference reference;
110 typedef typename CONTAINER::const_reference const_reference;
111 typedef typename CONTAINER::size_type size_type;
112
113 protected:
114 // PROTECTED DATA
115 CONTAINER c; // container for elements in the 'priority_queue'. This
116 // data member exactly matches its definition in the
117 // C++11 standard [23.6.4].
118
119 COMPARATOR comp; // comparator that defines the priority order of elements
120 // in the @ref priority_queue . This data member exactly
121 // matches its definition in the C++11 standard [23.6.4].
122
123 public:
124 // TRAITS
127 BloombergLP::bslma::UsesBslmaAllocator,
128 BloombergLP::bslma::UsesBslmaAllocator<container_type>::value);
129
130 // CREATORS
131
132 /// Create an empty priority queue, adapting a default-constructed
133 /// container of the (template parameter) type `CONTAINER`. Use a
134 /// default-constructed comparator of the (template parameter) type
135 /// `COMPARATOR` to order elements in the priority queue.
137
138 /// Create an empty priority queue, adapting a default-constructed
139 /// container of the (template parameter) type `CONTAINER`, and having
140 /// the specified `comparator` of the (template parameter) type
141 /// `COMPARATOR` to order elements in the priority queue.
142 explicit priority_queue(const COMPARATOR& comparator);
143
144 /// Create a priority queue, adapting the specified `container` of the
145 /// (template parameter) type `CONTAINER`, and having the specified
146 /// `comparator` of the (template parameter) type `COMPARATOR` to order
147 /// elements in the priority queue.
148 priority_queue(const COMPARATOR& comparator, const CONTAINER& container);
149
150 /// Create a priority queue, adapting the specified `container` of the
151 /// (template parameter) type `CONTAINER`, and having the specified
152 /// `comparator` of the (template parameter) type `COMPARATOR` to order
153 /// elements in the priority queue.
154 explicit priority_queue(
155 const COMPARATOR& comparator,
156 BloombergLP::bslmf::MovableRef<CONTAINER> container);
157
158
159 /// Create a priority queue, adapting a default-constructed container of
160 /// the (template parameter) type `CONTAINER`, and inserting into the
161 /// container a sequence of `value_type` elements that starts at the
162 /// specified `first` and ends immediately before the specified `last`.
163 /// Use a default-constructed comparator of the (template parameter)
164 /// type `COMPARATOR` to order elements in the priority queue.
165 template <class INPUT_ITERATOR>
166 priority_queue(INPUT_ITERATOR first, INPUT_ITERATOR last);
167
168 /// Create a priority queue, adapting the specified `container`, having
169 /// the specified `comparator` to order the priorities of elements,
170 /// including those originally existed in `container`, and those
171 /// inserted into the `container` from a sequence of `value_type`
172 /// elements starting at the specified `first`, and ending immediately
173 /// before the specified `last`.
174 template <class INPUT_ITERATOR>
175 priority_queue(INPUT_ITERATOR first,
176 INPUT_ITERATOR last,
177 const COMPARATOR& comparator,
178 const CONTAINER& container);
179
180 /// Create a priority queue, adapting the specified `container`, having
181 /// the specified `comparator` to order elements in the priority queue,
182 /// including those originally existed in `container`, and those
183 /// inserted into the `container` from a sequence of `value_type`
184 /// elements starting at the specified `first`, and ending immediately
185 /// before the specified `last`.
186 template <class INPUT_ITERATOR>
188 INPUT_ITERATOR first,
189 INPUT_ITERATOR last,
190 const COMPARATOR& comparator,
191 BloombergLP::bslmf::MovableRef<CONTAINER> container);
192
193 /// Create a priority queue having the same value as the specified
194 /// `original` object. Use a copy of the comparator from `original` to
195 /// order elements in the priority queue.
196 priority_queue(const priority_queue& original);
197
198 /// Create a priority queue having the same value as the specified
199 /// `original` object. Use a copy of the comparator from `original` to
200 /// order elements in the priority queue.
201 priority_queue(BloombergLP::bslmf::MovableRef<priority_queue> original);
202
203 /// Create an empty priority queue, adapting a default-constructed
204 /// container of the (template parameter) type `CONTAINER` that uses the
205 /// specified `basicAllocator` to supply memory. Use a
206 /// default-constructed object of the (template parameter) type
207 /// `COMPARATOR` to order elements in the priority queue.
208 ///
209 /// \note Note that this constructor is only defined if the underlying container uses
210 /// allocator. Otherwise this constructor is disabled.
211 template <class ALLOCATOR>
212 explicit
213 priority_queue(const ALLOCATOR& basicAllocator,
214 typename enable_if<
216 ALLOCATOR>::type * = 0);
217
218 /// Create an empty priority queue, adapting a default-constructed
219 /// container of the (template parameter) type `CONTAINER` that uses the
220 /// specified `basicAllocator` to supply memory, and the specified
221 /// `comparator` to order elements in the priority queue.
222 ///
223 /// \note Note that this constructor is only defined if the underlying container uses
224 /// allocator. Otherwise this constructor is disabled.
225 template <class ALLOCATOR>
226 priority_queue(const COMPARATOR& comparator,
227 const ALLOCATOR& basicAllocator,
228 typename enable_if<
230 ALLOCATOR>::type * = 0);
231
232 /// Create a priority queue, adapting the specified `container` that
233 /// uses the specified `basicAllocator` to supply memory, and the
234 /// specified `comparator` to order elements in the priority queue.
235 ///
236 /// \note Note that this constructor is only defined if the underlying
237 /// container uses allocator. Otherwise this constructor is disabled.
238 template <class ALLOCATOR>
239 priority_queue(const COMPARATOR& comparator,
240 const CONTAINER& container,
241 const ALLOCATOR& basicAllocator,
242 typename enable_if<
244 ALLOCATOR>::type * = 0);
245
246 /// Create a priority queue, adapting the specified `container` that
247 /// uses the specified `basicAllocator` to supply memory, and the
248 /// specified `comparator` to order elements in the priority queue.
249 ///
250 /// \note Note that this constructor is only defined if the underlying
251 /// container uses allocator. Otherwise this constructor is disabled.
252 template <class ALLOCATOR>
253 priority_queue(const COMPARATOR& comparator,
254 BloombergLP::bslmf::MovableRef<CONTAINER> container,
255 const ALLOCATOR& basicAllocator,
256 typename enable_if<
258 ALLOCATOR>::type * = 0);
259
260 /// Create a priority queue having the same value as the specified
261 /// `original` object and using the specified `basicAllocator` to supply
262 /// memory. Use a copy of the comparator from `original` to order elements in the priority queue.
263 ///
264 /// \note Note that this constructor is only
265 /// defined if the underlying container uses allocator. Otherwise this
266 /// constructor is disabled.
267 template <class ALLOCATOR>
268 priority_queue(const priority_queue& original,
269 const ALLOCATOR& basicAllocator,
270 typename enable_if<
272 ALLOCATOR>::type * = 0);
273
274 /// Create a priority queue having the same value as the specified
275 /// `original` object and using the specified `basicAllocator` to supply
276 /// memory. Use a copy of the comparator from `original` to order elements in the priority queue.
277 ///
278 /// \note Note that this constructor is only
279 /// defined if the underlying container uses allocator. Otherwise this
280 /// constructor is disabled.
281 template <class ALLOCATOR>
283 BloombergLP::bslmf::MovableRef<priority_queue> original,
284 const ALLOCATOR& basicAllocator,
285 typename enable_if<
287 ALLOCATOR>::type * = 0);
288
289 /// Create a priority queue from the elements of the specified `range`.
290 /// Optionally specify a `comparator` used to order elements in the
291 /// priority queue. Optionally supply an `allocator` to supply memory. If
292 /// `allocator` is not supplied and if `CONTAINER` is allocator aware, the currently installed default allocator is used.
293 ///
294 /// \note Note that `range` must
295 /// (minimally) meet the requirements of an input range and the values from
296 /// the range must have a type matching or convertible to (template
297 /// parameter) `VALUE`. Also note that the constructor overloads that take
298 /// allocators are defined only if the underlying `CONTAINTER` is allocator
299 /// aware.
300 template <class t_RANGE>
303 from_range_t ,
305 const COMPARATOR& comparator = COMPARATOR());
306 template <class t_RANGE, class t_ALLOCATOR>
308 priority_queue(from_range_t ,
310 const COMPARATOR& comparator,
311 const t_ALLOCATOR& allocator,
312 typename enable_if<bsl::uses_allocator<CONTAINER,
313 t_ALLOCATOR>::value,
314 t_ALLOCATOR>::type * = 0);
315 template <class t_RANGE, class t_ALLOCATOR>
317 priority_queue(from_range_t ,
319 const t_ALLOCATOR& allocator,
320 typename enable_if<bsl::uses_allocator<CONTAINER,
321 t_ALLOCATOR>::value,
322 t_ALLOCATOR>::type * = 0);
323
324 // MANIPULATORS
325
326 /// Assign to this object the value and comparator of the specified
327 /// `rhs` object and return a reference providing modifiable access to
328 /// this object.
330
331 /// Assign to this object the value and comparator of the specified
332 /// `rhs` object and return a reference providing modifiable access to
333 /// this object. `rhs` is left in a valid but unspecified state.
335 BloombergLP::bslmf::MovableRef<priority_queue> rhs)
337
338 /// Insert the specified `value` into this priority queue. In effect,
339 /// performs `c.push_back(value);`.
340 void push(const value_type& value);
341
342 /// Insert the specified `value` into this priority queue. In effect,
343 /// performs `c.push_back(value);`.
344 void push(BloombergLP::bslmf::MovableRef<value_type> value);
345
346 /// Insert the elements of the specified `range` into this priority queue.
347 ///
348 /// \note Note that `range` must meet the requirements of an input range and the
349 /// values from `range` must have a type matching or convertible to
350 /// (template parameter) `VALUE`.
351 template <class t_RANGE>
354
355#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
356// {{{ BEGIN GENERATED CODE
357// Command line: sim_cpp11_features.pl bslstl_priorityqueue.h
358#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
359#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT 10
360#endif
361#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A
362#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
363#endif
364#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 0
365 void emplace();
366#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 0
367
368#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 1
369 template <class Args_01>
370 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01);
371#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 1
372
373#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 2
374 template <class Args_01,
375 class Args_02>
376 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
377 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02);
378#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 2
379
380#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 3
381 template <class Args_01,
382 class Args_02,
383 class Args_03>
384 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
385 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
386 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03);
387#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 3
388
389#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 4
390 template <class Args_01,
391 class Args_02,
392 class Args_03,
393 class Args_04>
394 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
395 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
396 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
397 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04);
398#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 4
399
400#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 5
401 template <class Args_01,
402 class Args_02,
403 class Args_03,
404 class Args_04,
405 class Args_05>
406 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
407 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
408 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
409 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
410 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05);
411#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 5
412
413#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 6
414 template <class Args_01,
415 class Args_02,
416 class Args_03,
417 class Args_04,
418 class Args_05,
419 class Args_06>
420 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
421 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
422 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
423 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
424 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
425 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06);
426#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 6
427
428#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 7
429 template <class Args_01,
430 class Args_02,
431 class Args_03,
432 class Args_04,
433 class Args_05,
434 class Args_06,
435 class Args_07>
436 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
437 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
438 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
439 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
440 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
441 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
442 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07);
443#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 7
444
445#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 8
446 template <class Args_01,
447 class Args_02,
448 class Args_03,
449 class Args_04,
450 class Args_05,
451 class Args_06,
452 class Args_07,
453 class Args_08>
454 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
455 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
456 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
457 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
458 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
459 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
460 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
461 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08);
462#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 8
463
464#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 9
465 template <class Args_01,
466 class Args_02,
467 class Args_03,
468 class Args_04,
469 class Args_05,
470 class Args_06,
471 class Args_07,
472 class Args_08,
473 class Args_09>
474 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
475 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
476 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
477 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
478 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
479 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
480 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
481 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
482 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09);
483#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 9
484
485#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 10
486 template <class Args_01,
487 class Args_02,
488 class Args_03,
489 class Args_04,
490 class Args_05,
491 class Args_06,
492 class Args_07,
493 class Args_08,
494 class Args_09,
495 class Args_10>
496 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
497 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
498 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
499 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
500 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
501 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
502 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
503 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
504 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09,
505 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) args_10);
506#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 10
507
508#else
509// The generated code below is a workaround for the absence of perfect
510// forwarding in some compilers.
511 template <class... Args>
512 void emplace(BSLS_COMPILERFEATURES_FORWARD_REF(Args)... args);
513// }}} END GENERATED CODE
514#endif
515
516 /// Remove the top element from this @ref priority_queue object that has
517 /// the highest priority. In effect, performs `c.pop_back();`.
518 ///
519 /// \pre The behavior is undefined if there is currently no elements in this
520 /// object.
521 void pop();
522
523 /// Efficiently exchange the value of this object with the value of the
524 /// specified `other` object. In effect, performs
525 /// `using bsl::swap; swap(c, other.c);`.
527 bsl::is_nothrow_swappable<CONTAINER>::value &&
528 bsl::is_nothrow_swappable<COMPARATOR>::value);
529
530 // ACCESSORS
531
532 /// Return `true` if this @ref priority_queue object contains no elements,
533 /// and `false` otherwise. In effect, performs `return c.empty();`.
534 bool empty() const;
535
536 /// Return the number of elements in this @ref priority_queue object. In
537 /// effect, performs `return c.size()`.
538 size_type size() const;
539
540 /// Return a reference providing non-modifiable access to the element
541 /// having the highest priority in this @ref priority_queue object. In effect, performs `return c.front()`.
542 ///
543 /// \pre The behavior is undefined if
544 /// the priority queue is empty.
545 const_reference top() const;
546};
547
548#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
549// CLASS TEMPLATE DEDUCTION GUIDES
550
551/// Deduce the template parameter `VALUE` and `CONTAINER` from the
552/// parameters supplied to the constructor of @ref priority_queue .
553template <
554 class COMPARATOR,
555 class CONTAINER,
556 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<CONTAINER>>
557 >
558priority_queue(COMPARATOR, CONTAINER)
559 -> priority_queue<typename CONTAINER::value_type, CONTAINER, COMPARATOR>;
560
561/// Deduce the template parameters `VALUE`, `CONTAINER` and `COMPARATOR`
562/// from the parameters supplied to the constructor of @ref priority_queue .
563/// This deduction guide does not participate unless the supplied allocator
564/// is convertible to the underlying container's `allocator_type`.
565template <
566 class COMPARATOR,
567 class CONTAINER,
568 class ALLOCATOR,
569 class = bsl::enable_if_t<bsl::uses_allocator_v<CONTAINER, ALLOCATOR>>
570 >
571priority_queue(COMPARATOR, CONTAINER, ALLOCATOR)
572 -> priority_queue<typename CONTAINER::value_type, CONTAINER, COMPARATOR>;
573
574/// Deduce the template parameter `VALUE` from the `value_type` of the
575/// iterators supplied to the constructor of @ref priority_queue .
576template <
577 class INPUT_ITERATOR,
578 class VALUE =
579 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
580 >
581priority_queue(INPUT_ITERATOR, INPUT_ITERATOR)
582 -> priority_queue<VALUE>;
583
584/// Deduce the template parameter `VALUE` from the `value_type` of the
585/// iterators supplied to the constructor of @ref priority_queue . Deduce the
586/// template parameters `CONTAINER` and `COMPARATOR` from the other
587/// parameters passed to the constructor.
588template <
589 class INPUT_ITERATOR,
590 class COMPARATOR,
591 class CONTAINER,
592 class VALUE =
593 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
594 >
595priority_queue(INPUT_ITERATOR, INPUT_ITERATOR, COMPARATOR, CONTAINER)
596 -> priority_queue<VALUE, CONTAINER, COMPARATOR>;
597
598#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
599/// Deduce the template parameters `VALUE` and `COMPARATOR` from the parameters
600/// supplied to the constructor of @ref priority_queue .
601template <ranges::input_range t_RANGE,
602 class t_COMPARATOR =
603 std::less<ranges::range_value_t<t_RANGE>>,
604 class t_TYPE = ranges::range_value_t<t_RANGE>,
605 class = enable_if_t<!IsStdAllocator_v<t_COMPARATOR>>>
606priority_queue(from_range_t, t_RANGE&&, t_COMPARATOR = t_COMPARATOR())
607-> priority_queue<t_TYPE, vector<t_TYPE>, t_COMPARATOR>;
608
609/// Deduce the template parameters `VALUE`, `COMPARATOR`, and `ALLOCATOR` from
610/// the parameters supplied to the constructor of @ref priority_queue . This
611/// deduction guide does not participate if the `t_ALLOCATOR` parameter does
612/// not meet the requirements for a standard allocator or the `t_COMPARATOR`
613/// parameter meets the requirements for a standard allocator.
614template <ranges::input_range t_RANGE,
615 class t_COMPARATOR,
616 class t_ALLOCATOR,
617 class t_TYPE = ranges::range_value_t<t_RANGE>>
618requires (!IsStdAllocator_v<t_COMPARATOR> && IsStdAllocator_v<t_ALLOCATOR>)
619priority_queue(from_range_t, t_RANGE&&, t_COMPARATOR, t_ALLOCATOR)
620-> priority_queue<t_TYPE, vector<t_TYPE, t_ALLOCATOR>, t_COMPARATOR>;
621
622/// Deduce the template parameters `VALUE` and `ALLOCATOR` from the parameters
623/// supplied to the constructor of @ref priority_queue . This deduction guide does
624/// not participate unless the `t_ALLOCATOR` parameter meets the requirements
625/// for a standard allocator.
626template <ranges::input_range t_RANGE,
627 class t_ALLOCATOR,
628 class t_TYPE = ranges::range_value_t<t_RANGE>,
629 class = enable_if_t<IsStdAllocator_v<t_ALLOCATOR>>>
630priority_queue(from_range_t, t_RANGE&&, t_ALLOCATOR)
631-> priority_queue<t_TYPE, vector<t_TYPE, t_ALLOCATOR>>;
632#endif
633#endif
634
635// FREE FUNCTIONS
636
637/// Exchange the container and comparator of the specified `a` object with
638/// the container and comparator of the specified `b` object.
639template <class VALUE, class CONTAINER, class COMPARATOR>
640void swap(priority_queue<VALUE, CONTAINER, COMPARATOR>& a,
641 priority_queue<VALUE, CONTAINER, COMPARATOR>& b)
643
644// ============================================================================
645// TEMPLATE AND INLINE FUNCTION DEFINITIONS
646// ============================================================================
647
648 // --------------------
649 // class priority_queue
650 // --------------------
651
652// CREATORS
653template <class VALUE, class CONTAINER, class COMPARATOR>
654inline
656{
657}
658
659template <class VALUE, class CONTAINER, class COMPARATOR>
660inline
662 const COMPARATOR& comparator)
663: comp(comparator)
664{
665}
666
667template <class VALUE, class CONTAINER, class COMPARATOR>
668inline
669priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
670 const COMPARATOR& comparator,
671 const CONTAINER& container)
672: c(container)
673, comp(comparator)
674{
675 std::make_heap(c.begin(), c.end(), comp);
676}
677
678template <class VALUE, class CONTAINER, class COMPARATOR>
679inline
680priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
681 const COMPARATOR& comparator,
682 BloombergLP::bslmf::MovableRef<CONTAINER> container)
683: c(MoveUtil::move(container))
684, comp(comparator)
685{
686 std::make_heap(c.begin(), c.end(), comp);
687}
688
689template <class VALUE, class CONTAINER, class COMPARATOR>
690template <class INPUT_ITERATOR>
691inline
692priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
693 INPUT_ITERATOR first,
694 INPUT_ITERATOR last)
695{
696 c.insert(c.end(), first, last);
697 std::make_heap(c.begin(), c.end(), comp);
698}
699
700template <class VALUE, class CONTAINER, class COMPARATOR>
701template <class INPUT_ITERATOR>
702inline
703priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
704 INPUT_ITERATOR first,
705 INPUT_ITERATOR last,
706 const COMPARATOR& comparator,
707 const CONTAINER& container)
708: c(container)
709, comp(comparator)
710{
711 c.insert(c.end(), first, last);
712 std::make_heap(c.begin(), c.end(), comp);
713}
714
715template <class VALUE, class CONTAINER, class COMPARATOR>
716template <class INPUT_ITERATOR>
717inline
718priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
719 INPUT_ITERATOR first,
720 INPUT_ITERATOR last,
721 const COMPARATOR& comparator,
722 BloombergLP::bslmf::MovableRef<CONTAINER> container)
723: c(MoveUtil::move(container))
724, comp(comparator)
725{
726 c.insert(c.end(), first, last);
727 std::make_heap(c.begin(), c.end(), comp);
728}
729
730template <class VALUE, class CONTAINER, class COMPARATOR>
731inline
732priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
733 const priority_queue& original)
734: c(original.c)
735, comp(original.comp)
736{
737}
738
739template <class VALUE, class CONTAINER, class COMPARATOR>
740inline
741priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
742 BloombergLP::bslmf::MovableRef<priority_queue> original)
743: c(MoveUtil::move(MoveUtil::access(original).c))
744, comp(MoveUtil::access(original).comp)
745{
746}
747
748template <class VALUE, class CONTAINER, class COMPARATOR>
749template <class ALLOCATOR>
750inline
751priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
752 const ALLOCATOR& basicAllocator,
753 typename enable_if<
755 ALLOCATOR>::type *)
756: c(basicAllocator)
757, comp(COMPARATOR())
758{
759}
760
761template <class VALUE, class CONTAINER, class COMPARATOR>
762template <class ALLOCATOR>
763inline
764priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
765 const COMPARATOR& comparator,
766 const ALLOCATOR& basicAllocator,
767 typename enable_if<
769 ALLOCATOR>::type *)
770: c(basicAllocator)
771, comp(comparator)
772{
773}
774
775template <class VALUE, class CONTAINER, class COMPARATOR>
776template <class ALLOCATOR>
777inline
778priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
779 const COMPARATOR& comparator,
780 const CONTAINER& container,
781 const ALLOCATOR& basicAllocator,
782 typename enable_if<
784 ALLOCATOR>::type *)
785: c(container, basicAllocator)
786, comp(comparator)
787{
788 std::make_heap(c.begin(), c.end(), comp);
789}
790
791template <class VALUE, class CONTAINER, class COMPARATOR>
792template <class ALLOCATOR>
793inline
794priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
795 const COMPARATOR& comparator,
796 BloombergLP::bslmf::MovableRef<CONTAINER> container,
797 const ALLOCATOR& basicAllocator,
798 typename enable_if<
800 ALLOCATOR>::type *)
801: c(MoveUtil::move(container), basicAllocator)
802, comp(comparator)
803{
804 std::make_heap(c.begin(), c.end(), comp);
805}
806
807template <class VALUE, class CONTAINER, class COMPARATOR>
808template <class ALLOCATOR>
809inline
810priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
811 const priority_queue& original,
812 const ALLOCATOR& basicAllocator,
813 typename enable_if<
815 ALLOCATOR>::type *)
816: c(original.c, basicAllocator)
817, comp(original.comp)
818{
819}
820
821template <class VALUE, class CONTAINER, class COMPARATOR>
822template <class ALLOCATOR>
823inline
824priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
825 BloombergLP::bslmf::MovableRef<priority_queue> original,
826 const ALLOCATOR& basicAllocator,
827 typename enable_if<
829 ALLOCATOR>::type *)
830: c(MoveUtil::move(MoveUtil::access(original).c), basicAllocator)
831, comp(MoveUtil::access(original).comp)
832{
833}
834
835template <class VALUE, class CONTAINER, class COMPARATOR>
836template <class t_RANGE>
838inline
839priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
840 from_range_t ,
842 const COMPARATOR& comparator)
843#ifdef BSLS_LIBRARYFEATURES_HAS_CPP23_RANGES_TO_CONTAINER
844: c(ranges::to<CONTAINER>(std::forward<t_RANGE>(range)))
845#else
846: c(from_range, BSLS_COMPILERFEATURES_FORWARD(t_RANGE, range))
847#endif
848, comp(comparator)
849{
850 std::make_heap(c.begin(), c.end(), comp);
851}
852
853template <class VALUE, class CONTAINER, class COMPARATOR>
854template <class t_RANGE, class t_ALLOCATOR>
856inline
857priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
858 from_range_t ,
860 const COMPARATOR& comparator,
861 const t_ALLOCATOR& allocator,
862 typename enable_if<bsl::uses_allocator<CONTAINER,
863 t_ALLOCATOR>::value,
864 t_ALLOCATOR>::type *)
865#ifdef BSLS_LIBRARYFEATURES_HAS_CPP23_RANGES_TO_CONTAINER
866: c(ranges::to<CONTAINER>(std::forward<t_RANGE>(range), allocator))
867#else
868: c(from_range, BSLS_COMPILERFEATURES_FORWARD(t_RANGE, range), allocator)
869#endif
870, comp(comparator)
871{
872 std::make_heap(c.begin(), c.end(), comp);
873}
874
875template <class VALUE, class CONTAINER, class COMPARATOR>
876template <class t_RANGE, class t_ALLOCATOR>
878inline
879priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
880 from_range_t ,
882 const t_ALLOCATOR& allocator,
883 typename enable_if<bsl::uses_allocator<CONTAINER,
884 t_ALLOCATOR>::value,
885 t_ALLOCATOR>::type *)
886#ifdef BSLS_LIBRARYFEATURES_HAS_CPP23_RANGES_TO_CONTAINER
887: c(ranges::to<CONTAINER>(std::forward<t_RANGE>(range), allocator))
888#else
889: c(from_range, BSLS_COMPILERFEATURES_FORWARD(t_RANGE, range), allocator)
890#endif
891{
892 std::make_heap(c.begin(), c.end(), comp);
893}
894
895// PRIVATE MANIPULATORS
896template <class VALUE, class CONTAINER, class COMPARATOR>
897template <class INPUT_ITER, class SENTINEL>
898inline
899void priority_queue<VALUE, CONTAINER, COMPARATOR>::privatePushRange(
900 INPUT_ITER first,
901 SENTINEL last)
902{
903 while (first != last) {
904 c.push_back(*first);
905 ++first;
906 }
907}
908
909// MANIPULATORS
910template <class VALUE, class CONTAINER, class COMPARATOR>
911inline
912priority_queue<VALUE, CONTAINER, COMPARATOR>&
913priority_queue<VALUE, CONTAINER, COMPARATOR>::operator=(
914 const priority_queue& rhs)
915{
916 c = rhs.c;
917 comp = rhs.comp;
918 return *this;
919}
920
921template <class VALUE, class CONTAINER, class COMPARATOR>
922inline
923priority_queue<VALUE, CONTAINER, COMPARATOR>&
924priority_queue<VALUE, CONTAINER, COMPARATOR>::operator=(
925 BloombergLP::bslmf::MovableRef<priority_queue> rhs)
927{
928 c = MoveUtil::move(MoveUtil::access(rhs).c);
929 comp = MoveUtil::access(rhs).comp;
930 return *this;
931}
932
933template <class VALUE, class CONTAINER, class COMPARATOR>
934inline
935void priority_queue<VALUE, CONTAINER, COMPARATOR>::push(
936 const value_type& value)
937{
938 c.push_back(value);
939 std::push_heap(c.begin(), c.end(), comp);
940}
941
942template <class VALUE, class CONTAINER, class COMPARATOR>
943inline
944void priority_queue<VALUE, CONTAINER, COMPARATOR>::push(
945 BloombergLP::bslmf::MovableRef<value_type> value)
946{
947 c.push_back(MoveUtil::move(value));
948 std::push_heap(c.begin(), c.end(), comp);
949}
950
951template <class VALUE, class CONTAINER, class COMPARATOR>
952template <class t_RANGE>
954void priority_queue<VALUE, CONTAINER, COMPARATOR>::push_range(
956{
957#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
958 if constexpr (requires{ c.append_range(std::forward<t_RANGE>(range)); }) {
959 c.append_range(std::forward<t_RANGE>(range));
960 }
961 else {
962 ranges::copy(range, back_inserter(c));
963 }
964#else
965 privatePushRange(bsl::begin(range), bsl::end(range));
966#endif
967 std::make_heap(c.begin(), c.end(), comp);
968}
969
970#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
971// {{{ BEGIN GENERATED CODE
972// Command line: sim_cpp11_features.pl bslstl_priorityqueue.h
973#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
974#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT 10
975#endif
976#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B
977#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
978#endif
979#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 0
980template <class VALUE, class CONTAINER, class COMPARATOR>
981inline
982void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
983 )
984{
985 c.emplace_back();
986 std::push_heap(c.begin(), c.end(), comp);
987}
988#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 0
989
990#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 1
991template <class VALUE, class CONTAINER, class COMPARATOR>
992template <class Args_01>
993inline
994void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
995 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01)
996{
997 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01));
998 std::push_heap(c.begin(), c.end(), comp);
999}
1000#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 1
1001
1002#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 2
1003template <class VALUE, class CONTAINER, class COMPARATOR>
1004template <class Args_01,
1005 class Args_02>
1006inline
1007void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1008 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1009 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02)
1010{
1011 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1012 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02));
1013 std::push_heap(c.begin(), c.end(), comp);
1014}
1015#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 2
1016
1017#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 3
1018template <class VALUE, class CONTAINER, class COMPARATOR>
1019template <class Args_01,
1020 class Args_02,
1021 class Args_03>
1022inline
1023void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1024 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1025 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1026 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03)
1027{
1028 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1029 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1030 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03));
1031 std::push_heap(c.begin(), c.end(), comp);
1032}
1033#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 3
1034
1035#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 4
1036template <class VALUE, class CONTAINER, class COMPARATOR>
1037template <class Args_01,
1038 class Args_02,
1039 class Args_03,
1040 class Args_04>
1041inline
1042void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1043 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1044 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1045 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1046 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04)
1047{
1048 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1049 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1050 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1051 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04));
1052 std::push_heap(c.begin(), c.end(), comp);
1053}
1054#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 4
1055
1056#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 5
1057template <class VALUE, class CONTAINER, class COMPARATOR>
1058template <class Args_01,
1059 class Args_02,
1060 class Args_03,
1061 class Args_04,
1062 class Args_05>
1063inline
1064void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1065 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1066 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1067 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1068 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1069 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05)
1070{
1071 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1072 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1073 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1074 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1075 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05));
1076 std::push_heap(c.begin(), c.end(), comp);
1077}
1078#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 5
1079
1080#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 6
1081template <class VALUE, class CONTAINER, class COMPARATOR>
1082template <class Args_01,
1083 class Args_02,
1084 class Args_03,
1085 class Args_04,
1086 class Args_05,
1087 class Args_06>
1088inline
1089void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1090 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1091 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1092 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1093 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1094 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1095 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06)
1096{
1097 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1098 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1099 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1100 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1101 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1102 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06));
1103 std::push_heap(c.begin(), c.end(), comp);
1104}
1105#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 6
1106
1107#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 7
1108template <class VALUE, class CONTAINER, class COMPARATOR>
1109template <class Args_01,
1110 class Args_02,
1111 class Args_03,
1112 class Args_04,
1113 class Args_05,
1114 class Args_06,
1115 class Args_07>
1116inline
1117void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1118 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1119 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1120 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1121 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1122 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1123 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1124 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07)
1125{
1126 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1127 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1128 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1129 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1130 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1131 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1132 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07));
1133 std::push_heap(c.begin(), c.end(), comp);
1134}
1135#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 7
1136
1137#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 8
1138template <class VALUE, class CONTAINER, class COMPARATOR>
1139template <class Args_01,
1140 class Args_02,
1141 class Args_03,
1142 class Args_04,
1143 class Args_05,
1144 class Args_06,
1145 class Args_07,
1146 class Args_08>
1147inline
1148void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1149 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1150 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1151 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1152 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1153 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1154 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1155 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1156 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08)
1157{
1158 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1159 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1160 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1161 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1162 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1163 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1164 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1165 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08));
1166 std::push_heap(c.begin(), c.end(), comp);
1167}
1168#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 8
1169
1170#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 9
1171template <class VALUE, class CONTAINER, class COMPARATOR>
1172template <class Args_01,
1173 class Args_02,
1174 class Args_03,
1175 class Args_04,
1176 class Args_05,
1177 class Args_06,
1178 class Args_07,
1179 class Args_08,
1180 class Args_09>
1181inline
1182void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1183 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1184 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1185 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1186 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1187 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1188 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1189 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1190 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
1191 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09)
1192{
1193 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1194 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1195 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1196 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1197 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1198 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1199 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1200 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08),
1201 BSLS_COMPILERFEATURES_FORWARD(Args_09,args_09));
1202 std::push_heap(c.begin(), c.end(), comp);
1203}
1204#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 9
1205
1206#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 10
1207template <class VALUE, class CONTAINER, class COMPARATOR>
1208template <class Args_01,
1209 class Args_02,
1210 class Args_03,
1211 class Args_04,
1212 class Args_05,
1213 class Args_06,
1214 class Args_07,
1215 class Args_08,
1216 class Args_09,
1217 class Args_10>
1218inline
1219void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1220 BSLS_COMPILERFEATURES_FORWARD_REF(Args_01) args_01,
1221 BSLS_COMPILERFEATURES_FORWARD_REF(Args_02) args_02,
1222 BSLS_COMPILERFEATURES_FORWARD_REF(Args_03) args_03,
1223 BSLS_COMPILERFEATURES_FORWARD_REF(Args_04) args_04,
1224 BSLS_COMPILERFEATURES_FORWARD_REF(Args_05) args_05,
1225 BSLS_COMPILERFEATURES_FORWARD_REF(Args_06) args_06,
1226 BSLS_COMPILERFEATURES_FORWARD_REF(Args_07) args_07,
1227 BSLS_COMPILERFEATURES_FORWARD_REF(Args_08) args_08,
1228 BSLS_COMPILERFEATURES_FORWARD_REF(Args_09) args_09,
1229 BSLS_COMPILERFEATURES_FORWARD_REF(Args_10) args_10)
1230{
1231 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args_01,args_01),
1232 BSLS_COMPILERFEATURES_FORWARD(Args_02,args_02),
1233 BSLS_COMPILERFEATURES_FORWARD(Args_03,args_03),
1234 BSLS_COMPILERFEATURES_FORWARD(Args_04,args_04),
1235 BSLS_COMPILERFEATURES_FORWARD(Args_05,args_05),
1236 BSLS_COMPILERFEATURES_FORWARD(Args_06,args_06),
1237 BSLS_COMPILERFEATURES_FORWARD(Args_07,args_07),
1238 BSLS_COMPILERFEATURES_FORWARD(Args_08,args_08),
1239 BSLS_COMPILERFEATURES_FORWARD(Args_09,args_09),
1240 BSLS_COMPILERFEATURES_FORWARD(Args_10,args_10));
1241 std::push_heap(c.begin(), c.end(), comp);
1242}
1243#endif // BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 10
1244
1245#else
1246// The generated code below is a workaround for the absence of perfect
1247// forwarding in some compilers.
1248template <class VALUE, class CONTAINER, class COMPARATOR>
1249template <class... Args>
1250inline
1251void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1253{
1254 c.emplace_back(BSLS_COMPILERFEATURES_FORWARD(Args,args)...);
1255 std::push_heap(c.begin(), c.end(), comp);
1256}
1257// }}} END GENERATED CODE
1258#endif
1259
1260template <class VALUE, class CONTAINER, class COMPARATOR>
1261inline
1262void priority_queue<VALUE, CONTAINER, COMPARATOR>::pop()
1263{
1264 std::pop_heap(c.begin(), c.end(), comp);
1265 c.pop_back();
1266}
1267
1268template <class VALUE, class CONTAINER, class COMPARATOR>
1269inline
1270void priority_queue<VALUE, CONTAINER, COMPARATOR>::swap(priority_queue& other)
1272 bsl::is_nothrow_swappable<CONTAINER>::value &&
1273 bsl::is_nothrow_swappable<COMPARATOR>::value)
1274{
1275 BloombergLP::bslalg::SwapUtil::swap(&c, &other.c);
1276 BloombergLP::bslalg::SwapUtil::swap(&comp, &other.comp);
1277}
1278
1279// ACCESSORS
1280template <class VALUE, class CONTAINER, class COMPARATOR>
1281inline
1282bool priority_queue<VALUE, CONTAINER, COMPARATOR>::empty() const
1283{
1284 return c.empty();
1285}
1286
1287template <class VALUE, class CONTAINER, class COMPARATOR>
1288inline
1289typename priority_queue<VALUE, CONTAINER, COMPARATOR>::size_type
1290priority_queue<VALUE, CONTAINER, COMPARATOR>::size() const
1291{
1292 return c.size();
1293}
1294
1295template <class VALUE, class CONTAINER, class COMPARATOR>
1296inline
1297typename priority_queue<VALUE, CONTAINER, COMPARATOR>::const_reference
1298priority_queue<VALUE, CONTAINER, COMPARATOR>::top() const
1299{
1300 return c.front();
1301}
1302
1303// FREE FUNCTIONS
1304template <class VALUE, class CONTAINER, class COMPARATOR>
1305void swap(priority_queue<VALUE, CONTAINER, COMPARATOR>& a,
1306 priority_queue<VALUE, CONTAINER, COMPARATOR>& b)
1308{
1309 a.swap(b);
1310}
1311
1312} // close namespace bsl
1313
1314#else // if ! defined(DEFINED_BSLSTL_PRIORITYQUEUE_H)
1315# error Not valid except when included from bslstl_priorityqueue.h
1316#endif // ! defined(COMPILING_BSLSTL_PRIORITYQUEUE_H)
1317
1318#endif // ! defined(INCLUDED_BSLSTL_PRIORITYQUEUE_CPP03)
1319
1320// ----------------------------------------------------------------------------
1321// Copyright 2016 Bloomberg Finance L.P.
1322//
1323// Licensed under the Apache License, Version 2.0 (the "License");
1324// you may not use this file except in compliance with the License.
1325// You may obtain a copy of the License at
1326//
1327// http://www.apache.org/licenses/LICENSE-2.0
1328//
1329// Unless required by applicable law or agreed to in writing, software
1330// distributed under the License is distributed on an "AS IS" BASIS,
1331// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1332// See the License for the specific language governing permissions and
1333// limitations under the License.
1334// ----------------------------- END-OF-FILE ----------------------------------
1335
1336/** @} */
1337/** @} */
1338/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
size_type size() const
Definition bslstl_priorityqueue.h:1222
void emplace(Args &&... args)
Definition bslstl_priorityqueue.h:1185
void pop()
Definition bslstl_priorityqueue.h:1194
void swap(priority_queue &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl bool empty() const
Definition bslstl_priorityqueue.h:745
COMPARATOR value_compare
Definition bslstl_priorityqueue.h:470
CONTAINER::reference reference
Definition bslstl_priorityqueue.h:472
COMPARATOR comp
Definition bslstl_priorityqueue.h:482
CONTAINER::size_type size_type
Definition bslstl_priorityqueue.h:474
priority_queue()
Definition bslstl_priorityqueue.h:866
void push_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
Definition bslstl_priorityqueue.h:1165
CONTAINER::const_reference const_reference
Definition bslstl_priorityqueue.h:473
CONTAINER c
Definition bslstl_priorityqueue.h:478
CONTAINER::value_type value_type
Definition bslstl_priorityqueue.h:471
void push(const value_type &value)
Definition bslstl_priorityqueue.h:1146
const_reference top() const
Definition bslstl_priorityqueue.h:1230
CONTAINER container_type
Definition bslstl_priorityqueue.h:469
priority_queue & operator=(const priority_queue &rhs)
Definition bslstl_priorityqueue.h:1124
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
static const t_TYPE value
Definition bslmf_integralconstant.h:267
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLSTL_PRIORITY_QUEUE_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
Definition bslstl_priorityqueue.h:412
void swap(OptionValue &a, OptionValue &b)
Definition bdlat_valuetypefunctions.h:939
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
Definition bslmf_usesallocator.h:165