blob: 4677e52ae3a7ceb404d4e8beb78666f625b8d180 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- queue ------------------------------------===//
3//
Howard Hinnantc566dc32010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantc51e1022010-05-11 19:42:16 +00005//
Howard Hinnantee11c312010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc51e1022010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_QUEUE
12#define _LIBCPP_QUEUE
13
14/*
15 queue synopsis
16
17namespace std
18{
19
20template <class T, class Container = deque<T>>
21class queue
22{
23public:
24 typedef Container container_type;
25 typedef typename container_type::value_type value_type;
26 typedef typename container_type::reference reference;
27 typedef typename container_type::const_reference const_reference;
28 typedef typename container_type::size_type size_type;
29
30protected:
31 container_type c;
32
33public:
Howard Hinnantbf438282011-06-04 21:32:33 +000034 queue() = default;
35 ~queue() = default;
36
37 queue(const queue& q) = default;
38 queue(queue&& q) = default;
39
40 queue& operator=(const queue& q) = default;
41 queue& operator=(queue&& q) = default;
42
Howard Hinnantc51e1022010-05-11 19:42:16 +000043 explicit queue(const container_type& c);
Howard Hinnantbf438282011-06-04 21:32:33 +000044 explicit queue(container_type&& c)
Howard Hinnantc51e1022010-05-11 19:42:16 +000045 template <class Alloc>
46 explicit queue(const Alloc& a);
47 template <class Alloc>
48 queue(const container_type& c, const Alloc& a);
49 template <class Alloc>
50 queue(container_type&& c, const Alloc& a);
51 template <class Alloc>
Howard Hinnantbf438282011-06-04 21:32:33 +000052 queue(const queue& q, const Alloc& a);
53 template <class Alloc>
Howard Hinnantc51e1022010-05-11 19:42:16 +000054 queue(queue&& q, const Alloc& a);
55
Howard Hinnantc51e1022010-05-11 19:42:16 +000056 bool empty() const;
57 size_type size() const;
58
59 reference front();
60 const_reference front() const;
61 reference back();
62 const_reference back() const;
63
64 void push(const value_type& v);
65 void push(value_type&& v);
Marshall Clowea52cc42017-01-24 23:09:12 +000066 template <class... Args> reference emplace(Args&&... args); // reference in C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +000067 void pop();
68
Eric Fiselier6bfed252016-04-21 23:38:59 +000069 void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
Howard Hinnantc51e1022010-05-11 19:42:16 +000070};
71
Marshall Clow592d9952018-05-22 01:57:53 +000072template<class Container>
73 queue(Container) -> queue<typename Container::value_type, Container>; // C++17
74
75template<class Container, class Allocator>
76 queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
77
Howard Hinnantc51e1022010-05-11 19:42:16 +000078template <class T, class Container>
79 bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
80
81template <class T, class Container>
82 bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
83
84template <class T, class Container>
85 bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
86
87template <class T, class Container>
88 bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
89
90template <class T, class Container>
91 bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
92
93template <class T, class Container>
94 bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
95
96template <class T, class Container>
Howard Hinnantbf438282011-06-04 21:32:33 +000097 void swap(queue<T, Container>& x, queue<T, Container>& y)
98 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +000099
100template <class T, class Container = vector<T>,
101 class Compare = less<typename Container::value_type>>
102class priority_queue
103{
104public:
105 typedef Container container_type;
106 typedef typename container_type::value_type value_type;
107 typedef typename container_type::reference reference;
108 typedef typename container_type::const_reference const_reference;
109 typedef typename container_type::size_type size_type;
110
111protected:
112 container_type c;
113 Compare comp;
114
115public:
Howard Hinnantbf438282011-06-04 21:32:33 +0000116 priority_queue() = default;
117 ~priority_queue() = default;
118
119 priority_queue(const priority_queue& q) = default;
120 priority_queue(priority_queue&& q) = default;
121
122 priority_queue& operator=(const priority_queue& q) = default;
123 priority_queue& operator=(priority_queue&& q) = default;
124
125 explicit priority_queue(const Compare& comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000126 priority_queue(const Compare& comp, const container_type& c);
127 explicit priority_queue(const Compare& comp, container_type&& c);
128 template <class InputIterator>
129 priority_queue(InputIterator first, InputIterator last,
130 const Compare& comp = Compare());
131 template <class InputIterator>
132 priority_queue(InputIterator first, InputIterator last,
133 const Compare& comp, const container_type& c);
134 template <class InputIterator>
135 priority_queue(InputIterator first, InputIterator last,
136 const Compare& comp, container_type&& c);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000137 template <class Alloc>
138 explicit priority_queue(const Alloc& a);
139 template <class Alloc>
140 priority_queue(const Compare& comp, const Alloc& a);
141 template <class Alloc>
142 priority_queue(const Compare& comp, const container_type& c,
143 const Alloc& a);
144 template <class Alloc>
145 priority_queue(const Compare& comp, container_type&& c,
146 const Alloc& a);
147 template <class Alloc>
Howard Hinnantbf438282011-06-04 21:32:33 +0000148 priority_queue(const priority_queue& q, const Alloc& a);
149 template <class Alloc>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000150 priority_queue(priority_queue&& q, const Alloc& a);
151
152 bool empty() const;
153 size_type size() const;
154 const_reference top() const;
155
156 void push(const value_type& v);
157 void push(value_type&& v);
158 template <class... Args> void emplace(Args&&... args);
159 void pop();
160
Howard Hinnantbf438282011-06-04 21:32:33 +0000161 void swap(priority_queue& q)
Eric Fiselier6bfed252016-04-21 23:38:59 +0000162 noexcept(is_nothrow_swappable_v<Container> &&
163 is_nothrow_swappable_v<Comp>)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000164};
165
Marshall Clow592d9952018-05-22 01:57:53 +0000166template <class Compare, class Container>
167priority_queue(Compare, Container)
168 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
169
170template<class InputIterator,
171 class Compare = less<typename iterator_traits<InputIterator>::value_type>,
172 class Container = vector<typename iterator_traits<InputIterator>::value_type>>
173priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
174 -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
175
176template<class Compare, class Container, class Allocator>
177priority_queue(Compare, Container, Allocator)
178 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
179
Howard Hinnantc51e1022010-05-11 19:42:16 +0000180template <class T, class Container, class Compare>
181 void swap(priority_queue<T, Container, Compare>& x,
Howard Hinnantbf438282011-06-04 21:32:33 +0000182 priority_queue<T, Container, Compare>& y)
183 noexcept(noexcept(x.swap(y)));
Howard Hinnantc51e1022010-05-11 19:42:16 +0000184
185} // std
186
187*/
188
189#include <__config>
190#include <deque>
191#include <vector>
192#include <functional>
193#include <algorithm>
194
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000195#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000196#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +0000197#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +0000198
199_LIBCPP_BEGIN_NAMESPACE_STD
200
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000201template <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000202
203template <class _Tp, class _Container>
Howard Hinnanta54386e2012-09-14 00:39:16 +0000204_LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000205bool
206operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
207
208template <class _Tp, class _Container>
Howard Hinnanta54386e2012-09-14 00:39:16 +0000209_LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000210bool
211operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
212
Marshall Clow9e1b8452015-02-18 17:51:56 +0000213template <class _Tp, class _Container /*= deque<_Tp>*/>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000214class _LIBCPP_TEMPLATE_VIS queue
Howard Hinnantc51e1022010-05-11 19:42:16 +0000215{
216public:
217 typedef _Container container_type;
218 typedef typename container_type::value_type value_type;
219 typedef typename container_type::reference reference;
220 typedef typename container_type::const_reference const_reference;
221 typedef typename container_type::size_type size_type;
Marshall Clowb8825f02016-03-14 17:58:11 +0000222 static_assert((is_same<_Tp, value_type>::value), "" );
Howard Hinnantc51e1022010-05-11 19:42:16 +0000223
224protected:
225 container_type c;
226
227public:
Howard Hinnantf5f99992010-09-22 18:02:38 +0000228 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbf438282011-06-04 21:32:33 +0000229 queue()
230 _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
231 : c() {}
232
233 _LIBCPP_INLINE_VISIBILITY
234 queue(const queue& __q) : c(__q.c) {}
235
Eric Fiselier26081dd2017-04-18 21:23:18 +0000236 _LIBCPP_INLINE_VISIBILITY
237 queue& operator=(const queue& __q) {c = __q.c; return *this;}
238
239#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbf438282011-06-04 21:32:33 +0000240 _LIBCPP_INLINE_VISIBILITY
241 queue(queue&& __q)
242 _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000243 : c(_VSTD::move(__q.c)) {}
Howard Hinnantbf438282011-06-04 21:32:33 +0000244
245 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbf438282011-06-04 21:32:33 +0000246 queue& operator=(queue&& __q)
247 _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000248 {c = _VSTD::move(__q.c); return *this;}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000249#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbf438282011-06-04 21:32:33 +0000250
Howard Hinnantf5f99992010-09-22 18:02:38 +0000251 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000252 explicit queue(const container_type& __c) : c(__c) {}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000253#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantf5f99992010-09-22 18:02:38 +0000254 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000255 explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000256#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000257 template <class _Alloc>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000258 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000259 explicit queue(const _Alloc& __a,
260 typename enable_if<uses_allocator<container_type,
261 _Alloc>::value>::type* = 0)
262 : c(__a) {}
263 template <class _Alloc>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000264 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000265 queue(const queue& __q, const _Alloc& __a,
266 typename enable_if<uses_allocator<container_type,
267 _Alloc>::value>::type* = 0)
268 : c(__q.c, __a) {}
269 template <class _Alloc>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000270 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000271 queue(const container_type& __c, const _Alloc& __a,
272 typename enable_if<uses_allocator<container_type,
273 _Alloc>::value>::type* = 0)
274 : c(__c, __a) {}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000275#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000276 template <class _Alloc>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000277 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000278 queue(container_type&& __c, const _Alloc& __a,
279 typename enable_if<uses_allocator<container_type,
280 _Alloc>::value>::type* = 0)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000281 : c(_VSTD::move(__c), __a) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000282 template <class _Alloc>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000283 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000284 queue(queue&& __q, const _Alloc& __a,
285 typename enable_if<uses_allocator<container_type,
286 _Alloc>::value>::type* = 0)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000287 : c(_VSTD::move(__q.c), __a) {}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000288
Eric Fiselier26081dd2017-04-18 21:23:18 +0000289#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000290
Marshall Clow425f5752017-11-15 05:51:26 +0000291 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000292 bool empty() const {return c.empty();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000293 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000294 size_type size() const {return c.size();}
295
Howard Hinnantf5f99992010-09-22 18:02:38 +0000296 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000297 reference front() {return c.front();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000298 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000299 const_reference front() const {return c.front();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000300 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000301 reference back() {return c.back();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000302 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000303 const_reference back() const {return c.back();}
304
Howard Hinnantf5f99992010-09-22 18:02:38 +0000305 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000306 void push(const value_type& __v) {c.push_back(__v);}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000307#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantf5f99992010-09-22 18:02:38 +0000308 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000309 void push(value_type&& __v) {c.push_back(_VSTD::move(__v));}
Howard Hinnantc51e1022010-05-11 19:42:16 +0000310 template <class... _Args>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000311 _LIBCPP_INLINE_VISIBILITY
Marshall Clowea52cc42017-01-24 23:09:12 +0000312#if _LIBCPP_STD_VER > 14
Marshall Clow88746852018-01-24 22:42:25 +0000313 decltype(auto) emplace(_Args&&... __args)
Eric Fiselier34ba5b92016-07-21 03:20:17 +0000314 { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
Marshall Clowea52cc42017-01-24 23:09:12 +0000315#else
316 void emplace(_Args&&... __args)
317 { c.emplace_back(_VSTD::forward<_Args>(__args)...);}
318#endif
Eric Fiselier26081dd2017-04-18 21:23:18 +0000319#endif // _LIBCPP_CXX03_LANG
Howard Hinnantf5f99992010-09-22 18:02:38 +0000320 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000321 void pop() {c.pop_front();}
322
Howard Hinnantf5f99992010-09-22 18:02:38 +0000323 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000324 void swap(queue& __q)
Howard Hinnantbf438282011-06-04 21:32:33 +0000325 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000326 {
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000327 using _VSTD::swap;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000328 swap(c, __q.c);
329 }
330
331 template <class _T1, class _C1>
332 friend
Howard Hinnantf5f99992010-09-22 18:02:38 +0000333 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000334 bool
335 operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
Howard Hinnant3b6579a2010-08-22 00:02:43 +0000336
Howard Hinnantc51e1022010-05-11 19:42:16 +0000337 template <class _T1, class _C1>
338 friend
Howard Hinnantf5f99992010-09-22 18:02:38 +0000339 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000340 bool
341 operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
342};
343
Marshall Clow592d9952018-05-22 01:57:53 +0000344#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
345template<class _Container,
346 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
347>
348queue(_Container)
349 -> queue<typename _Container::value_type, _Container>;
350
351template<class _Container,
352 class _Alloc,
353 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
354 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
355>
356queue(_Container, _Alloc)
357 -> queue<typename _Container::value_type, _Container>;
358#endif
359
Howard Hinnantc51e1022010-05-11 19:42:16 +0000360template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000361inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000362bool
363operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
364{
365 return __x.c == __y.c;
366}
367
368template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000369inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000370bool
371operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
372{
373 return __x.c < __y.c;
374}
375
376template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000377inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000378bool
379operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
380{
381 return !(__x == __y);
382}
383
384template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000385inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000386bool
387operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
388{
389 return __y < __x;
390}
391
392template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000393inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000394bool
395operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
396{
397 return !(__x < __y);
398}
399
400template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000401inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000402bool
403operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
404{
405 return !(__y < __x);
406}
407
408template <class _Tp, class _Container>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000409inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier6bfed252016-04-21 23:38:59 +0000410typename enable_if<
411 __is_swappable<_Container>::value,
412 void
413>::type
Howard Hinnantc51e1022010-05-11 19:42:16 +0000414swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
Howard Hinnantbf438282011-06-04 21:32:33 +0000415 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000416{
417 __x.swap(__y);
418}
419
420template <class _Tp, class _Container, class _Alloc>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000421struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000422 : public uses_allocator<_Container, _Alloc>
423{
424};
425
426template <class _Tp, class _Container = vector<_Tp>,
427 class _Compare = less<typename _Container::value_type> >
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000428class _LIBCPP_TEMPLATE_VIS priority_queue
Howard Hinnantc51e1022010-05-11 19:42:16 +0000429{
430public:
431 typedef _Container container_type;
432 typedef _Compare value_compare;
433 typedef typename container_type::value_type value_type;
434 typedef typename container_type::reference reference;
435 typedef typename container_type::const_reference const_reference;
436 typedef typename container_type::size_type size_type;
Marshall Clowb8825f02016-03-14 17:58:11 +0000437 static_assert((is_same<_Tp, value_type>::value), "" );
Howard Hinnantc51e1022010-05-11 19:42:16 +0000438
439protected:
440 container_type c;
441 value_compare comp;
442
443public:
Howard Hinnantf5f99992010-09-22 18:02:38 +0000444 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbf438282011-06-04 21:32:33 +0000445 priority_queue()
446 _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
447 is_nothrow_default_constructible<value_compare>::value)
448 : c(), comp() {}
449
450 _LIBCPP_INLINE_VISIBILITY
451 priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
452
Eric Fiselier26081dd2017-04-18 21:23:18 +0000453 _LIBCPP_INLINE_VISIBILITY
454 priority_queue& operator=(const priority_queue& __q)
455 {c = __q.c; comp = __q.comp; return *this;}
456
457#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbf438282011-06-04 21:32:33 +0000458 _LIBCPP_INLINE_VISIBILITY
459 priority_queue(priority_queue&& __q)
460 _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
461 is_nothrow_move_constructible<value_compare>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000462 : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
Howard Hinnantbf438282011-06-04 21:32:33 +0000463
464 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbf438282011-06-04 21:32:33 +0000465 priority_queue& operator=(priority_queue&& __q)
466 _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
467 is_nothrow_move_assignable<value_compare>::value)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000468 {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
Eric Fiselier26081dd2017-04-18 21:23:18 +0000469#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbf438282011-06-04 21:32:33 +0000470
471 _LIBCPP_INLINE_VISIBILITY
472 explicit priority_queue(const value_compare& __comp)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000473 : c(), comp(__comp) {}
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000475 priority_queue(const value_compare& __comp, const container_type& __c);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000476#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000477 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000478 explicit priority_queue(const value_compare& __comp, container_type&& __c);
479#endif
480 template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000481 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000482 priority_queue(_InputIter __f, _InputIter __l,
483 const value_compare& __comp = value_compare());
484 template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000485 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000486 priority_queue(_InputIter __f, _InputIter __l,
487 const value_compare& __comp, const container_type& __c);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000488#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000489 template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000491 priority_queue(_InputIter __f, _InputIter __l,
492 const value_compare& __comp, container_type&& __c);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000493#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000494 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000495 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000496 explicit priority_queue(const _Alloc& __a,
497 typename enable_if<uses_allocator<container_type,
498 _Alloc>::value>::type* = 0);
499 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000500 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000501 priority_queue(const value_compare& __comp, const _Alloc& __a,
502 typename enable_if<uses_allocator<container_type,
503 _Alloc>::value>::type* = 0);
504 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000505 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000506 priority_queue(const value_compare& __comp, const container_type& __c,
507 const _Alloc& __a,
508 typename enable_if<uses_allocator<container_type,
509 _Alloc>::value>::type* = 0);
510 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000511 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000512 priority_queue(const priority_queue& __q, const _Alloc& __a,
513 typename enable_if<uses_allocator<container_type,
514 _Alloc>::value>::type* = 0);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000515#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000516 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000517 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000518 priority_queue(const value_compare& __comp, container_type&& __c,
519 const _Alloc& __a,
520 typename enable_if<uses_allocator<container_type,
521 _Alloc>::value>::type* = 0);
522 template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000523 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000524 priority_queue(priority_queue&& __q, const _Alloc& __a,
525 typename enable_if<uses_allocator<container_type,
526 _Alloc>::value>::type* = 0);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000527#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000528
Marshall Clow425f5752017-11-15 05:51:26 +0000529 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000530 bool empty() const {return c.empty();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000531 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000532 size_type size() const {return c.size();}
Howard Hinnantf5f99992010-09-22 18:02:38 +0000533 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000534 const_reference top() const {return c.front();}
535
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000536 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000537 void push(const value_type& __v);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000538#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000539 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000540 void push(value_type&& __v);
Eric Fiselier26081dd2017-04-18 21:23:18 +0000541 template <class... _Args>
542 _LIBCPP_INLINE_VISIBILITY
543 void emplace(_Args&&... __args);
544#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000545 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantc51e1022010-05-11 19:42:16 +0000546 void pop();
547
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000548 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbf438282011-06-04 21:32:33 +0000549 void swap(priority_queue& __q)
550 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
551 __is_nothrow_swappable<value_compare>::value);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000552};
553
Marshall Clow592d9952018-05-22 01:57:53 +0000554#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
555template <class _Compare,
556 class _Container,
557 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
558 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
559>
560priority_queue(_Compare, _Container)
561 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
562
563template<class _InputIterator,
564 class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,
565 class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
566 class = typename enable_if< __is_input_iterator<_InputIterator>::value, nullptr_t>::type,
567 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
568 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
569>
570priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
571 -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
572
573template<class _Compare,
574 class _Container,
575 class _Alloc,
576 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
577 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
578 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
579>
580priority_queue(_Compare, _Container, _Alloc)
581 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
582#endif
583
Howard Hinnantc51e1022010-05-11 19:42:16 +0000584template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000585inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000586priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
587 const container_type& __c)
588 : c(__c),
589 comp(__comp)
590{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000591 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000592}
593
Eric Fiselier26081dd2017-04-18 21:23:18 +0000594#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000595
596template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000597inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000598priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
599 container_type&& __c)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000600 : c(_VSTD::move(__c)),
Howard Hinnantc51e1022010-05-11 19:42:16 +0000601 comp(__comp)
602{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000603 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000604}
605
Eric Fiselier26081dd2017-04-18 21:23:18 +0000606#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000607
608template <class _Tp, class _Container, class _Compare>
609template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000610inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000611priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
612 const value_compare& __comp)
613 : c(__f, __l),
614 comp(__comp)
615{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000616 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000617}
618
619template <class _Tp, class _Container, class _Compare>
620template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000621inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000622priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
623 const value_compare& __comp,
624 const container_type& __c)
625 : c(__c),
626 comp(__comp)
627{
628 c.insert(c.end(), __f, __l);
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000629 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000630}
631
Eric Fiselier26081dd2017-04-18 21:23:18 +0000632#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000633
634template <class _Tp, class _Container, class _Compare>
635template <class _InputIter>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000636inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000637priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
638 const value_compare& __comp,
639 container_type&& __c)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000640 : c(_VSTD::move(__c)),
Howard Hinnantc51e1022010-05-11 19:42:16 +0000641 comp(__comp)
642{
643 c.insert(c.end(), __f, __l);
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000644 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000645}
646
Eric Fiselier26081dd2017-04-18 21:23:18 +0000647#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000648
649template <class _Tp, class _Container, class _Compare>
650template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000651inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000652priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
653 typename enable_if<uses_allocator<container_type,
654 _Alloc>::value>::type*)
655 : c(__a)
656{
657}
658
659template <class _Tp, class _Container, class _Compare>
660template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000661inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000662priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
663 const _Alloc& __a,
664 typename enable_if<uses_allocator<container_type,
665 _Alloc>::value>::type*)
666 : c(__a),
667 comp(__comp)
668{
669}
670
671template <class _Tp, class _Container, class _Compare>
672template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000673inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000674priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
675 const container_type& __c,
676 const _Alloc& __a,
677 typename enable_if<uses_allocator<container_type,
678 _Alloc>::value>::type*)
679 : c(__c, __a),
680 comp(__comp)
681{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000682 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000683}
684
685template <class _Tp, class _Container, class _Compare>
686template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000687inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000688priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
689 const _Alloc& __a,
690 typename enable_if<uses_allocator<container_type,
691 _Alloc>::value>::type*)
692 : c(__q.c, __a),
693 comp(__q.comp)
694{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000695 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000696}
697
Eric Fiselier26081dd2017-04-18 21:23:18 +0000698#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000699
700template <class _Tp, class _Container, class _Compare>
701template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000702inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000703priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
704 container_type&& __c,
705 const _Alloc& __a,
706 typename enable_if<uses_allocator<container_type,
707 _Alloc>::value>::type*)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000708 : c(_VSTD::move(__c), __a),
Howard Hinnantc51e1022010-05-11 19:42:16 +0000709 comp(__comp)
710{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000711 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000712}
713
Howard Hinnantc51e1022010-05-11 19:42:16 +0000714template <class _Tp, class _Container, class _Compare>
715template <class _Alloc>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000716inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000717priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
718 const _Alloc& __a,
719 typename enable_if<uses_allocator<container_type,
720 _Alloc>::value>::type*)
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000721 : c(_VSTD::move(__q.c), __a),
722 comp(_VSTD::move(__q.comp))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000723{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000724 _VSTD::make_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000725}
726
Eric Fiselier26081dd2017-04-18 21:23:18 +0000727#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000728
729template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000730inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000731void
732priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
733{
734 c.push_back(__v);
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000735 _VSTD::push_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000736}
737
Eric Fiselier26081dd2017-04-18 21:23:18 +0000738#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000739
740template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000741inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000742void
743priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
744{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000745 c.push_back(_VSTD::move(__v));
746 _VSTD::push_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000747}
748
749template <class _Tp, class _Container, class _Compare>
750template <class... _Args>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000751inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000752void
753priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
754{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000755 c.emplace_back(_VSTD::forward<_Args>(__args)...);
756 _VSTD::push_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000757}
758
Eric Fiselier26081dd2017-04-18 21:23:18 +0000759#endif // _LIBCPP_CXX03_LANG
Howard Hinnantc51e1022010-05-11 19:42:16 +0000760
761template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000762inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000763void
764priority_queue<_Tp, _Container, _Compare>::pop()
765{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000766 _VSTD::pop_heap(c.begin(), c.end(), comp);
Howard Hinnantc51e1022010-05-11 19:42:16 +0000767 c.pop_back();
768}
769
770template <class _Tp, class _Container, class _Compare>
Evgeniy Stepanov3b68ae52016-04-22 01:04:55 +0000771inline
Howard Hinnantc51e1022010-05-11 19:42:16 +0000772void
773priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
Howard Hinnantbf438282011-06-04 21:32:33 +0000774 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
775 __is_nothrow_swappable<value_compare>::value)
Howard Hinnantc51e1022010-05-11 19:42:16 +0000776{
Howard Hinnantb1ad5a82011-06-30 21:18:19 +0000777 using _VSTD::swap;
Howard Hinnantc51e1022010-05-11 19:42:16 +0000778 swap(c, __q.c);
779 swap(comp, __q.comp);
780}
781
782template <class _Tp, class _Container, class _Compare>
Howard Hinnantf5f99992010-09-22 18:02:38 +0000783inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier6bfed252016-04-21 23:38:59 +0000784typename enable_if<
785 __is_swappable<_Container>::value
786 && __is_swappable<_Compare>::value,
787 void
788>::type
Howard Hinnantc51e1022010-05-11 19:42:16 +0000789swap(priority_queue<_Tp, _Container, _Compare>& __x,
790 priority_queue<_Tp, _Container, _Compare>& __y)
Howard Hinnantbf438282011-06-04 21:32:33 +0000791 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
Howard Hinnantc51e1022010-05-11 19:42:16 +0000792{
793 __x.swap(__y);
794}
795
796template <class _Tp, class _Container, class _Compare, class _Alloc>
Eric Fiselierb5eb1bf2017-01-04 23:56:00 +0000797struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
Howard Hinnantc51e1022010-05-11 19:42:16 +0000798 : public uses_allocator<_Container, _Alloc>
799{
800};
801
802_LIBCPP_END_NAMESPACE_STD
803
804#endif // _LIBCPP_QUEUE