2 //===--------------------------- queue ------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
19 template <class T, class Container = deque<T>>
23 typedef Container container_type;
24 typedef typename container_type::value_type value_type;
25 typedef typename container_type::reference reference;
26 typedef typename container_type::const_reference const_reference;
27 typedef typename container_type::size_type size_type;
36 queue(const queue& q) = default;
37 queue(queue&& q) = default;
39 queue& operator=(const queue& q) = default;
40 queue& operator=(queue&& q) = default;
42 explicit queue(const container_type& c);
43 explicit queue(container_type&& c)
44 template <class Alloc>
45 explicit queue(const Alloc& a);
46 template <class Alloc>
47 queue(const container_type& c, const Alloc& a);
48 template <class Alloc>
49 queue(container_type&& c, const Alloc& a);
50 template <class Alloc>
51 queue(const queue& q, const Alloc& a);
52 template <class Alloc>
53 queue(queue&& q, const Alloc& a);
56 size_type size() const;
59 const_reference front() const;
61 const_reference back() const;
63 void push(const value_type& v);
64 void push(value_type&& v);
65 template <class... Args> reference emplace(Args&&... args); // reference in C++17
68 void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
71 template<class Container>
72 queue(Container) -> queue<typename Container::value_type, Container>; // C++17
74 template<class Container, class Allocator>
75 queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
77 template <class T, class Container>
78 bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
80 template <class T, class Container>
81 bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
83 template <class T, class Container>
84 bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
86 template <class T, class Container>
87 bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
89 template <class T, class Container>
90 bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
92 template <class T, class Container>
93 bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
95 template <class T, class Container>
96 void swap(queue<T, Container>& x, queue<T, Container>& y)
97 noexcept(noexcept(x.swap(y)));
99 template <class T, class Container = vector<T>,
100 class Compare = less<typename Container::value_type>>
104 typedef Container container_type;
105 typedef typename container_type::value_type value_type;
106 typedef typename container_type::reference reference;
107 typedef typename container_type::const_reference const_reference;
108 typedef typename container_type::size_type size_type;
115 priority_queue() = default;
116 ~priority_queue() = default;
118 priority_queue(const priority_queue& q) = default;
119 priority_queue(priority_queue&& q) = default;
121 priority_queue& operator=(const priority_queue& q) = default;
122 priority_queue& operator=(priority_queue&& q) = default;
124 explicit priority_queue(const Compare& comp);
125 priority_queue(const Compare& comp, const container_type& c);
126 explicit priority_queue(const Compare& comp, container_type&& c);
127 template <class InputIterator>
128 priority_queue(InputIterator first, InputIterator last,
129 const Compare& comp = Compare());
130 template <class InputIterator>
131 priority_queue(InputIterator first, InputIterator last,
132 const Compare& comp, const container_type& c);
133 template <class InputIterator>
134 priority_queue(InputIterator first, InputIterator last,
135 const Compare& comp, container_type&& c);
136 template <class Alloc>
137 explicit priority_queue(const Alloc& a);
138 template <class Alloc>
139 priority_queue(const Compare& comp, const Alloc& a);
140 template <class Alloc>
141 priority_queue(const Compare& comp, const container_type& c,
143 template <class Alloc>
144 priority_queue(const Compare& comp, container_type&& c,
146 template <class Alloc>
147 priority_queue(const priority_queue& q, const Alloc& a);
148 template <class Alloc>
149 priority_queue(priority_queue&& q, const Alloc& a);
152 size_type size() const;
153 const_reference top() const;
155 void push(const value_type& v);
156 void push(value_type&& v);
157 template <class... Args> void emplace(Args&&... args);
160 void swap(priority_queue& q)
161 noexcept(is_nothrow_swappable_v<Container> &&
162 is_nothrow_swappable_v<Comp>)
165 template <class Compare, class Container>
166 priority_queue(Compare, Container)
167 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
169 template<class InputIterator,
170 class Compare = less<typename iterator_traits<InputIterator>::value_type>,
171 class Container = vector<typename iterator_traits<InputIterator>::value_type>>
172 priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
173 -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
175 template<class Compare, class Container, class Allocator>
176 priority_queue(Compare, Container, Allocator)
177 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
179 template <class T, class Container, class Compare>
180 void swap(priority_queue<T, Container, Compare>& x,
181 priority_queue<T, Container, Compare>& y)
182 noexcept(noexcept(x.swap(y)));
191 #include <functional>
194 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
195 #pragma GCC system_header
198 _LIBCPP_BEGIN_NAMESPACE_STD
200 template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
202 template <class _Tp, class _Container>
203 _LIBCPP_INLINE_VISIBILITY
205 operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
207 template <class _Tp, class _Container>
208 _LIBCPP_INLINE_VISIBILITY
210 operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
212 template <class _Tp, class _Container /*= deque<_Tp>*/>
213 class _LIBCPP_TEMPLATE_VIS queue
216 typedef _Container container_type;
217 typedef typename container_type::value_type value_type;
218 typedef typename container_type::reference reference;
219 typedef typename container_type::const_reference const_reference;
220 typedef typename container_type::size_type size_type;
221 static_assert((is_same<_Tp, value_type>::value), "" );
227 _LIBCPP_INLINE_VISIBILITY
229 _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
232 _LIBCPP_INLINE_VISIBILITY
233 queue(const queue& __q) : c(__q.c) {}
235 _LIBCPP_INLINE_VISIBILITY
236 queue& operator=(const queue& __q) {c = __q.c; return *this;}
238 #ifndef _LIBCPP_CXX03_LANG
239 _LIBCPP_INLINE_VISIBILITY
241 _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
242 : c(_VSTD::move(__q.c)) {}
244 _LIBCPP_INLINE_VISIBILITY
245 queue& operator=(queue&& __q)
246 _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
247 {c = _VSTD::move(__q.c); return *this;}
248 #endif // _LIBCPP_CXX03_LANG
250 _LIBCPP_INLINE_VISIBILITY
251 explicit queue(const container_type& __c) : c(__c) {}
252 #ifndef _LIBCPP_CXX03_LANG
253 _LIBCPP_INLINE_VISIBILITY
254 explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
255 #endif // _LIBCPP_CXX03_LANG
256 template <class _Alloc>
257 _LIBCPP_INLINE_VISIBILITY
258 explicit queue(const _Alloc& __a,
259 typename enable_if<uses_allocator<container_type,
260 _Alloc>::value>::type* = 0)
262 template <class _Alloc>
263 _LIBCPP_INLINE_VISIBILITY
264 queue(const queue& __q, const _Alloc& __a,
265 typename enable_if<uses_allocator<container_type,
266 _Alloc>::value>::type* = 0)
268 template <class _Alloc>
269 _LIBCPP_INLINE_VISIBILITY
270 queue(const container_type& __c, const _Alloc& __a,
271 typename enable_if<uses_allocator<container_type,
272 _Alloc>::value>::type* = 0)
274 #ifndef _LIBCPP_CXX03_LANG
275 template <class _Alloc>
276 _LIBCPP_INLINE_VISIBILITY
277 queue(container_type&& __c, const _Alloc& __a,
278 typename enable_if<uses_allocator<container_type,
279 _Alloc>::value>::type* = 0)
280 : c(_VSTD::move(__c), __a) {}
281 template <class _Alloc>
282 _LIBCPP_INLINE_VISIBILITY
283 queue(queue&& __q, const _Alloc& __a,
284 typename enable_if<uses_allocator<container_type,
285 _Alloc>::value>::type* = 0)
286 : c(_VSTD::move(__q.c), __a) {}
288 #endif // _LIBCPP_CXX03_LANG
290 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
291 bool empty() const {return c.empty();}
292 _LIBCPP_INLINE_VISIBILITY
293 size_type size() const {return c.size();}
295 _LIBCPP_INLINE_VISIBILITY
296 reference front() {return c.front();}
297 _LIBCPP_INLINE_VISIBILITY
298 const_reference front() const {return c.front();}
299 _LIBCPP_INLINE_VISIBILITY
300 reference back() {return c.back();}
301 _LIBCPP_INLINE_VISIBILITY
302 const_reference back() const {return c.back();}
304 _LIBCPP_INLINE_VISIBILITY
305 void push(const value_type& __v) {c.push_back(__v);}
306 #ifndef _LIBCPP_CXX03_LANG
307 _LIBCPP_INLINE_VISIBILITY
308 void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
309 template <class... _Args>
310 _LIBCPP_INLINE_VISIBILITY
311 #if _LIBCPP_STD_VER > 14
312 decltype(auto) emplace(_Args&&... __args)
313 { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
315 void emplace(_Args&&... __args)
316 { c.emplace_back(_VSTD::forward<_Args>(__args)...);}
318 #endif // _LIBCPP_CXX03_LANG
319 _LIBCPP_INLINE_VISIBILITY
320 void pop() {c.pop_front();}
322 _LIBCPP_INLINE_VISIBILITY
323 void swap(queue& __q)
324 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
330 template <class _T1, class _C1>
332 _LIBCPP_INLINE_VISIBILITY
334 operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
336 template <class _T1, class _C1>
338 _LIBCPP_INLINE_VISIBILITY
340 operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
343 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
344 template<class _Container,
345 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
348 -> queue<typename _Container::value_type, _Container>;
350 template<class _Container,
352 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
353 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
355 queue(_Container, _Alloc)
356 -> queue<typename _Container::value_type, _Container>;
359 template <class _Tp, class _Container>
360 inline _LIBCPP_INLINE_VISIBILITY
362 operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
364 return __x.c == __y.c;
367 template <class _Tp, class _Container>
368 inline _LIBCPP_INLINE_VISIBILITY
370 operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
372 return __x.c < __y.c;
375 template <class _Tp, class _Container>
376 inline _LIBCPP_INLINE_VISIBILITY
378 operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
380 return !(__x == __y);
383 template <class _Tp, class _Container>
384 inline _LIBCPP_INLINE_VISIBILITY
386 operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
391 template <class _Tp, class _Container>
392 inline _LIBCPP_INLINE_VISIBILITY
394 operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
399 template <class _Tp, class _Container>
400 inline _LIBCPP_INLINE_VISIBILITY
402 operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
407 template <class _Tp, class _Container>
408 inline _LIBCPP_INLINE_VISIBILITY
410 __is_swappable<_Container>::value,
413 swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
414 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
419 template <class _Tp, class _Container, class _Alloc>
420 struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
421 : public uses_allocator<_Container, _Alloc>
425 template <class _Tp, class _Container = vector<_Tp>,
426 class _Compare = less<typename _Container::value_type> >
427 class _LIBCPP_TEMPLATE_VIS priority_queue
430 typedef _Container container_type;
431 typedef _Compare value_compare;
432 typedef typename container_type::value_type value_type;
433 typedef typename container_type::reference reference;
434 typedef typename container_type::const_reference const_reference;
435 typedef typename container_type::size_type size_type;
436 static_assert((is_same<_Tp, value_type>::value), "" );
443 _LIBCPP_INLINE_VISIBILITY
445 _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
446 is_nothrow_default_constructible<value_compare>::value)
449 _LIBCPP_INLINE_VISIBILITY
450 priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
452 _LIBCPP_INLINE_VISIBILITY
453 priority_queue& operator=(const priority_queue& __q)
454 {c = __q.c; comp = __q.comp; return *this;}
456 #ifndef _LIBCPP_CXX03_LANG
457 _LIBCPP_INLINE_VISIBILITY
458 priority_queue(priority_queue&& __q)
459 _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
460 is_nothrow_move_constructible<value_compare>::value)
461 : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
463 _LIBCPP_INLINE_VISIBILITY
464 priority_queue& operator=(priority_queue&& __q)
465 _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
466 is_nothrow_move_assignable<value_compare>::value)
467 {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
468 #endif // _LIBCPP_CXX03_LANG
470 _LIBCPP_INLINE_VISIBILITY
471 explicit priority_queue(const value_compare& __comp)
472 : c(), comp(__comp) {}
473 _LIBCPP_INLINE_VISIBILITY
474 priority_queue(const value_compare& __comp, const container_type& __c);
475 #ifndef _LIBCPP_CXX03_LANG
476 _LIBCPP_INLINE_VISIBILITY
477 explicit priority_queue(const value_compare& __comp, container_type&& __c);
479 template <class _InputIter>
480 _LIBCPP_INLINE_VISIBILITY
481 priority_queue(_InputIter __f, _InputIter __l,
482 const value_compare& __comp = value_compare());
483 template <class _InputIter>
484 _LIBCPP_INLINE_VISIBILITY
485 priority_queue(_InputIter __f, _InputIter __l,
486 const value_compare& __comp, const container_type& __c);
487 #ifndef _LIBCPP_CXX03_LANG
488 template <class _InputIter>
489 _LIBCPP_INLINE_VISIBILITY
490 priority_queue(_InputIter __f, _InputIter __l,
491 const value_compare& __comp, container_type&& __c);
492 #endif // _LIBCPP_CXX03_LANG
493 template <class _Alloc>
494 _LIBCPP_INLINE_VISIBILITY
495 explicit priority_queue(const _Alloc& __a,
496 typename enable_if<uses_allocator<container_type,
497 _Alloc>::value>::type* = 0);
498 template <class _Alloc>
499 _LIBCPP_INLINE_VISIBILITY
500 priority_queue(const value_compare& __comp, const _Alloc& __a,
501 typename enable_if<uses_allocator<container_type,
502 _Alloc>::value>::type* = 0);
503 template <class _Alloc>
504 _LIBCPP_INLINE_VISIBILITY
505 priority_queue(const value_compare& __comp, const container_type& __c,
507 typename enable_if<uses_allocator<container_type,
508 _Alloc>::value>::type* = 0);
509 template <class _Alloc>
510 _LIBCPP_INLINE_VISIBILITY
511 priority_queue(const priority_queue& __q, const _Alloc& __a,
512 typename enable_if<uses_allocator<container_type,
513 _Alloc>::value>::type* = 0);
514 #ifndef _LIBCPP_CXX03_LANG
515 template <class _Alloc>
516 _LIBCPP_INLINE_VISIBILITY
517 priority_queue(const value_compare& __comp, container_type&& __c,
519 typename enable_if<uses_allocator<container_type,
520 _Alloc>::value>::type* = 0);
521 template <class _Alloc>
522 _LIBCPP_INLINE_VISIBILITY
523 priority_queue(priority_queue&& __q, const _Alloc& __a,
524 typename enable_if<uses_allocator<container_type,
525 _Alloc>::value>::type* = 0);
526 #endif // _LIBCPP_CXX03_LANG
528 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
529 bool empty() const {return c.empty();}
530 _LIBCPP_INLINE_VISIBILITY
531 size_type size() const {return c.size();}
532 _LIBCPP_INLINE_VISIBILITY
533 const_reference top() const {return c.front();}
535 _LIBCPP_INLINE_VISIBILITY
536 void push(const value_type& __v);
537 #ifndef _LIBCPP_CXX03_LANG
538 _LIBCPP_INLINE_VISIBILITY
539 void push(value_type&& __v);
540 template <class... _Args>
541 _LIBCPP_INLINE_VISIBILITY
542 void emplace(_Args&&... __args);
543 #endif // _LIBCPP_CXX03_LANG
544 _LIBCPP_INLINE_VISIBILITY
547 _LIBCPP_INLINE_VISIBILITY
548 void swap(priority_queue& __q)
549 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
550 __is_nothrow_swappable<value_compare>::value);
553 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
554 template <class _Compare,
556 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
557 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
559 priority_queue(_Compare, _Container)
560 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
562 template<class _InputIterator,
563 class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
564 class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
565 class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,
566 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
567 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
569 priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
570 -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
572 template<class _Compare,
575 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
576 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
577 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
579 priority_queue(_Compare, _Container, _Alloc)
580 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
583 template <class _Tp, class _Container, class _Compare>
585 priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
586 const container_type& __c)
590 _VSTD::make_heap(c.begin(), c.end(), comp);
593 #ifndef _LIBCPP_CXX03_LANG
595 template <class _Tp, class _Container, class _Compare>
597 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
598 container_type&& __c)
599 : c(_VSTD::move(__c)),
602 _VSTD::make_heap(c.begin(), c.end(), comp);
605 #endif // _LIBCPP_CXX03_LANG
607 template <class _Tp, class _Container, class _Compare>
608 template <class _InputIter>
610 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
611 const value_compare& __comp)
615 _VSTD::make_heap(c.begin(), c.end(), comp);
618 template <class _Tp, class _Container, class _Compare>
619 template <class _InputIter>
621 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
622 const value_compare& __comp,
623 const container_type& __c)
627 c.insert(c.end(), __f, __l);
628 _VSTD::make_heap(c.begin(), c.end(), comp);
631 #ifndef _LIBCPP_CXX03_LANG
633 template <class _Tp, class _Container, class _Compare>
634 template <class _InputIter>
636 priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
637 const value_compare& __comp,
638 container_type&& __c)
639 : c(_VSTD::move(__c)),
642 c.insert(c.end(), __f, __l);
643 _VSTD::make_heap(c.begin(), c.end(), comp);
646 #endif // _LIBCPP_CXX03_LANG
648 template <class _Tp, class _Container, class _Compare>
649 template <class _Alloc>
651 priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
652 typename enable_if<uses_allocator<container_type,
653 _Alloc>::value>::type*)
658 template <class _Tp, class _Container, class _Compare>
659 template <class _Alloc>
661 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
663 typename enable_if<uses_allocator<container_type,
664 _Alloc>::value>::type*)
670 template <class _Tp, class _Container, class _Compare>
671 template <class _Alloc>
673 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
674 const container_type& __c,
676 typename enable_if<uses_allocator<container_type,
677 _Alloc>::value>::type*)
681 _VSTD::make_heap(c.begin(), c.end(), comp);
684 template <class _Tp, class _Container, class _Compare>
685 template <class _Alloc>
687 priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
689 typename enable_if<uses_allocator<container_type,
690 _Alloc>::value>::type*)
694 _VSTD::make_heap(c.begin(), c.end(), comp);
697 #ifndef _LIBCPP_CXX03_LANG
699 template <class _Tp, class _Container, class _Compare>
700 template <class _Alloc>
702 priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
703 container_type&& __c,
705 typename enable_if<uses_allocator<container_type,
706 _Alloc>::value>::type*)
707 : c(_VSTD::move(__c), __a),
710 _VSTD::make_heap(c.begin(), c.end(), comp);
713 template <class _Tp, class _Container, class _Compare>
714 template <class _Alloc>
716 priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
718 typename enable_if<uses_allocator<container_type,
719 _Alloc>::value>::type*)
720 : c(_VSTD::move(__q.c), __a),
721 comp(_VSTD::move(__q.comp))
723 _VSTD::make_heap(c.begin(), c.end(), comp);
726 #endif // _LIBCPP_CXX03_LANG
728 template <class _Tp, class _Container, class _Compare>
731 priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
734 _VSTD::push_heap(c.begin(), c.end(), comp);
737 #ifndef _LIBCPP_CXX03_LANG
739 template <class _Tp, class _Container, class _Compare>
742 priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
744 c.push_back(_VSTD::move(__v));
745 _VSTD::push_heap(c.begin(), c.end(), comp);
748 template <class _Tp, class _Container, class _Compare>
749 template <class... _Args>
752 priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
754 c.emplace_back(_VSTD::forward<_Args>(__args)...);
755 _VSTD::push_heap(c.begin(), c.end(), comp);
758 #endif // _LIBCPP_CXX03_LANG
760 template <class _Tp, class _Container, class _Compare>
763 priority_queue<_Tp, _Container, _Compare>::pop()
765 _VSTD::pop_heap(c.begin(), c.end(), comp);
769 template <class _Tp, class _Container, class _Compare>
772 priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
773 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
774 __is_nothrow_swappable<value_compare>::value)
778 swap(comp, __q.comp);
781 template <class _Tp, class _Container, class _Compare>
782 inline _LIBCPP_INLINE_VISIBILITY
784 __is_swappable<_Container>::value
785 && __is_swappable<_Compare>::value,
788 swap(priority_queue<_Tp, _Container, _Compare>& __x,
789 priority_queue<_Tp, _Container, _Compare>& __y)
790 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
795 template <class _Tp, class _Container, class _Compare, class _Alloc>
796 struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
797 : public uses_allocator<_Container, _Alloc>
801 _LIBCPP_END_NAMESPACE_STD
803 #endif // _LIBCPP_QUEUE