queue 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  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
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_QUEUE
  10. #define _LIBCPP_QUEUE
  11. /*
  12. queue synopsis
  13. namespace std
  14. {
  15. template <class T, class Container = deque<T>>
  16. class queue
  17. {
  18. public:
  19. typedef Container container_type;
  20. typedef typename container_type::value_type value_type;
  21. typedef typename container_type::reference reference;
  22. typedef typename container_type::const_reference const_reference;
  23. typedef typename container_type::size_type size_type;
  24. protected:
  25. container_type c;
  26. public:
  27. queue() = default;
  28. ~queue() = default;
  29. queue(const queue& q) = default;
  30. queue(queue&& q) = default;
  31. queue& operator=(const queue& q) = default;
  32. queue& operator=(queue&& q) = default;
  33. explicit queue(const container_type& c);
  34. explicit queue(container_type&& c)
  35. template<class InputIterator>
  36. queue(InputIterator first, InputIterator last); // since C++23
  37. template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23
  38. template <class Alloc>
  39. explicit queue(const Alloc& a);
  40. template <class Alloc>
  41. queue(const container_type& c, const Alloc& a);
  42. template <class Alloc>
  43. queue(container_type&& c, const Alloc& a);
  44. template <class Alloc>
  45. queue(const queue& q, const Alloc& a);
  46. template <class Alloc>
  47. queue(queue&& q, const Alloc& a);
  48. template <class InputIterator, class Alloc>
  49. queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
  50. template<container-compatible-range<T> R, class Alloc>
  51. queue(from_range_t, R&& rg, const Alloc&); // since C++23
  52. bool empty() const;
  53. size_type size() const;
  54. reference front();
  55. const_reference front() const;
  56. reference back();
  57. const_reference back() const;
  58. void push(const value_type& v);
  59. void push(value_type&& v);
  60. template<container-compatible-range<T> R>
  61. void push_range(R&& rg); // C++23
  62. template <class... Args> reference emplace(Args&&... args); // reference in C++17
  63. void pop();
  64. void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
  65. };
  66. template<class Container>
  67. queue(Container) -> queue<typename Container::value_type, Container>; // C++17
  68. template<class InputIterator>
  69. queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
  70. template<ranges::input_range R>
  71. queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23
  72. template<class Container, class Allocator>
  73. queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
  74. template<class InputIterator, class Allocator>
  75. queue(InputIterator, InputIterator, Allocator)
  76. -> queue<iter-value-type<InputIterator>,
  77. deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
  78. template<ranges::input_range R, class Allocator>
  79. queue(from_range_t, R&&, Allocator)
  80. -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23
  81. template <class T, class Container>
  82. 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);
  85. template <class T, class Container>
  86. bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
  87. template <class T, class Container>
  88. 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);
  91. template <class T, class Container>
  92. bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
  93. template<class T, three_way_comparable Container>
  94. compare_three_way_result_t<Container>
  95. operator<=>(const queue<T, Container>& x, const queue<T, Container>& y); // since C++20
  96. template <class T, class Container>
  97. void swap(queue<T, Container>& x, queue<T, Container>& y)
  98. noexcept(noexcept(x.swap(y)));
  99. template <class T, class Container = vector<T>,
  100. class Compare = less<typename Container::value_type>>
  101. class priority_queue
  102. {
  103. public:
  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;
  109. protected:
  110. container_type c;
  111. Compare comp;
  112. public:
  113. priority_queue() : priority_queue(Compare()) {} // C++20
  114. explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
  115. priority_queue(const Compare& x, const Container&);
  116. explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
  117. priority_queue(const Compare& x, Container&&); // C++20
  118. template <class InputIterator>
  119. priority_queue(InputIterator first, InputIterator last,
  120. const Compare& comp = Compare());
  121. template <class InputIterator>
  122. priority_queue(InputIterator first, InputIterator last,
  123. const Compare& comp, const Container& c);
  124. template <class InputIterator>
  125. priority_queue(InputIterator first, InputIterator last,
  126. const Compare& comp, Container&& c);
  127. template <container-compatible-range<T> R>
  128. priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23
  129. template <class Alloc>
  130. explicit priority_queue(const Alloc& a);
  131. template <class Alloc>
  132. priority_queue(const Compare& comp, const Alloc& a);
  133. template <class Alloc>
  134. priority_queue(const Compare& comp, const Container& c,
  135. const Alloc& a);
  136. template <class Alloc>
  137. priority_queue(const Compare& comp, Container&& c,
  138. const Alloc& a);
  139. template <class InputIterator>
  140. priority_queue(InputIterator first, InputIterator last,
  141. const Alloc& a);
  142. template <class InputIterator>
  143. priority_queue(InputIterator first, InputIterator last,
  144. const Compare& comp, const Alloc& a);
  145. template <class InputIterator>
  146. priority_queue(InputIterator first, InputIterator last,
  147. const Compare& comp, const Container& c, const Alloc& a);
  148. template <class InputIterator>
  149. priority_queue(InputIterator first, InputIterator last,
  150. const Compare& comp, Container&& c, const Alloc& a);
  151. template <container-compatible-range<T> R, class Alloc>
  152. priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23
  153. template <container-compatible-range<T> R, class Alloc>
  154. priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23
  155. template <class Alloc>
  156. priority_queue(const priority_queue& q, const Alloc& a);
  157. template <class Alloc>
  158. priority_queue(priority_queue&& q, const Alloc& a);
  159. bool empty() const;
  160. size_type size() const;
  161. const_reference top() const;
  162. void push(const value_type& v);
  163. void push(value_type&& v);
  164. template<container-compatible-range<T> R>
  165. void push_range(R&& rg); // C++23
  166. template <class... Args> void emplace(Args&&... args);
  167. void pop();
  168. void swap(priority_queue& q)
  169. noexcept(is_nothrow_swappable_v<Container> &&
  170. is_nothrow_swappable_v<Comp>)
  171. };
  172. template <class Compare, class Container>
  173. priority_queue(Compare, Container)
  174. -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
  175. template<class InputIterator,
  176. class Compare = less<iter-value-type<InputIterator>>,
  177. class Container = vector<iter-value-type<InputIterator>>>
  178. priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
  179. -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
  180. template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>>
  181. priority_queue(from_range_t, R&&, Compare = Compare())
  182. -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23
  183. template<class Compare, class Container, class Allocator>
  184. priority_queue(Compare, Container, Allocator)
  185. -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
  186. template<class InputIterator, class Allocator>
  187. priority_queue(InputIterator, InputIterator, Allocator)
  188. -> priority_queue<iter-value-type<InputIterator>,
  189. vector<iter-value-type<InputIterator>, Allocator>,
  190. less<iter-value-type<InputIterator>>>; // C++17
  191. template<class InputIterator, class Compare, class Allocator>
  192. priority_queue(InputIterator, InputIterator, Compare, Allocator)
  193. -> priority_queue<iter-value-type<InputIterator>,
  194. vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
  195. template<class InputIterator, class Compare, class Container, class Allocator>
  196. priority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
  197. -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
  198. template<ranges::input_range R, class Compare, class Allocator>
  199. priority_queue(from_range_t, R&&, Compare, Allocator)
  200. -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
  201. Compare>; // C++23
  202. template<ranges::input_range R, class Allocator>
  203. priority_queue(from_range_t, R&&, Allocator)
  204. -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23
  205. template <class T, class Container, class Compare>
  206. void swap(priority_queue<T, Container, Compare>& x,
  207. priority_queue<T, Container, Compare>& y)
  208. noexcept(noexcept(x.swap(y)));
  209. } // std
  210. */
  211. #include <__algorithm/make_heap.h>
  212. #include <__algorithm/pop_heap.h>
  213. #include <__algorithm/push_heap.h>
  214. #include <__algorithm/ranges_copy.h>
  215. #include <__config>
  216. #include <__functional/operations.h>
  217. #include <__fwd/deque.h>
  218. #include <__fwd/queue.h>
  219. #include <__iterator/back_insert_iterator.h>
  220. #include <__iterator/iterator_traits.h>
  221. #include <__memory/uses_allocator.h>
  222. #include <__ranges/access.h>
  223. #include <__ranges/concepts.h>
  224. #include <__ranges/container_compatible_range.h>
  225. #include <__ranges/from_range.h>
  226. #include <__utility/forward.h>
  227. #include <deque>
  228. #include <vector>
  229. #include <version>
  230. // standard-mandated includes
  231. // [queue.syn]
  232. #include <compare>
  233. #include <initializer_list>
  234. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  235. # pragma GCC system_header
  236. #endif
  237. _LIBCPP_PUSH_MACROS
  238. #include <__undef_macros>
  239. _LIBCPP_BEGIN_NAMESPACE_STD
  240. template <class _Tp, class _Container>
  241. _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
  242. template <class _Tp, class _Container>
  243. _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
  244. template <class _Tp, class _Container /*= deque<_Tp>*/>
  245. class _LIBCPP_TEMPLATE_VIS queue {
  246. public:
  247. typedef _Container container_type;
  248. typedef typename container_type::value_type value_type;
  249. typedef typename container_type::reference reference;
  250. typedef typename container_type::const_reference const_reference;
  251. typedef typename container_type::size_type size_type;
  252. static_assert((is_same<_Tp, value_type>::value), "");
  253. protected:
  254. container_type c;
  255. public:
  256. _LIBCPP_HIDE_FROM_ABI queue() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {}
  257. _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
  258. #if _LIBCPP_STD_VER >= 23
  259. template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
  260. _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
  261. template <_ContainerCompatibleRange<_Tp> _Range>
  262. _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {}
  263. template <class _InputIterator,
  264. class _Alloc,
  265. __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
  266. __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  267. _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc)
  268. : c(__first, __second, __alloc) {}
  269. template <_ContainerCompatibleRange<_Tp> _Range,
  270. class _Alloc,
  271. __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  272. _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
  273. : c(from_range, std::forward<_Range>(__range), __alloc) {}
  274. #endif
  275. _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {
  276. c = __q.c;
  277. return *this;
  278. }
  279. #ifndef _LIBCPP_CXX03_LANG
  280. _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
  281. : c(std::move(__q.c)) {}
  282. _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) {
  283. c = std::move(__q.c);
  284. return *this;
  285. }
  286. #endif // _LIBCPP_CXX03_LANG
  287. _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}
  288. #ifndef _LIBCPP_CXX03_LANG
  289. _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}
  290. #endif // _LIBCPP_CXX03_LANG
  291. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  292. _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}
  293. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  294. _LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {}
  295. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  296. _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}
  297. #ifndef _LIBCPP_CXX03_LANG
  298. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  299. _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {}
  300. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  301. _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {}
  302. #endif // _LIBCPP_CXX03_LANG
  303. _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
  304. _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
  305. _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
  306. _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); }
  307. _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); }
  308. _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }
  309. _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
  310. #ifndef _LIBCPP_CXX03_LANG
  311. _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }
  312. # if _LIBCPP_STD_VER >= 23
  313. template <_ContainerCompatibleRange<_Tp> _Range>
  314. _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
  315. if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
  316. c.append_range(std::forward<_Range>(__range));
  317. } else {
  318. ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
  319. }
  320. }
  321. # endif
  322. template <class... _Args>
  323. _LIBCPP_HIDE_FROM_ABI
  324. # if _LIBCPP_STD_VER >= 17
  325. decltype(auto)
  326. emplace(_Args&&... __args) {
  327. return c.emplace_back(std::forward<_Args>(__args)...);
  328. }
  329. # else
  330. void
  331. emplace(_Args&&... __args) {
  332. c.emplace_back(std::forward<_Args>(__args)...);
  333. }
  334. # endif
  335. #endif // _LIBCPP_CXX03_LANG
  336. _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
  337. _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) {
  338. using std::swap;
  339. swap(c, __q.c);
  340. }
  341. _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
  342. template <class _T1, class _OtherContainer>
  343. friend _LIBCPP_HIDE_FROM_ABI bool
  344. operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
  345. template <class _T1, class _OtherContainer>
  346. friend _LIBCPP_HIDE_FROM_ABI bool
  347. operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
  348. };
  349. #if _LIBCPP_STD_VER >= 17
  350. template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >
  351. queue(_Container) -> queue<typename _Container::value_type, _Container>;
  352. template <class _Container,
  353. class _Alloc,
  354. class = enable_if_t<!__is_allocator<_Container>::value>,
  355. class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
  356. queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
  357. #endif
  358. #if _LIBCPP_STD_VER >= 23
  359. template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
  360. queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;
  361. template <ranges::input_range _Range>
  362. queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>;
  363. template <class _InputIterator,
  364. class _Alloc,
  365. __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
  366. __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
  367. queue(_InputIterator,
  368. _InputIterator,
  369. _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
  370. template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
  371. queue(from_range_t,
  372. _Range&&,
  373. _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
  374. #endif
  375. template <class _Tp, class _Container>
  376. inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  377. return __x.c == __y.c;
  378. }
  379. template <class _Tp, class _Container>
  380. inline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  381. return __x.c < __y.c;
  382. }
  383. template <class _Tp, class _Container>
  384. inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  385. return !(__x == __y);
  386. }
  387. template <class _Tp, class _Container>
  388. inline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  389. return __y < __x;
  390. }
  391. template <class _Tp, class _Container>
  392. inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  393. return !(__x < __y);
  394. }
  395. template <class _Tp, class _Container>
  396. inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  397. return !(__y < __x);
  398. }
  399. #if _LIBCPP_STD_VER >= 20
  400. template <class _Tp, three_way_comparable _Container>
  401. _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
  402. operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
  403. // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors
  404. return __x.__get_container() <=> __y.__get_container();
  405. }
  406. #endif
  407. template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
  408. inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
  409. _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
  410. __x.swap(__y);
  411. }
  412. template <class _Tp, class _Container, class _Alloc>
  413. struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {
  414. };
  415. template <class _Tp, class _Container, class _Compare>
  416. class _LIBCPP_TEMPLATE_VIS priority_queue {
  417. public:
  418. typedef _Container container_type;
  419. typedef _Compare value_compare;
  420. typedef typename container_type::value_type value_type;
  421. typedef typename container_type::reference reference;
  422. typedef typename container_type::const_reference const_reference;
  423. typedef typename container_type::size_type size_type;
  424. static_assert((is_same<_Tp, value_type>::value), "");
  425. protected:
  426. container_type c;
  427. value_compare comp;
  428. public:
  429. _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_(
  430. is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value)
  431. : c(), comp() {}
  432. _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
  433. _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {
  434. c = __q.c;
  435. comp = __q.comp;
  436. return *this;
  437. }
  438. #ifndef _LIBCPP_CXX03_LANG
  439. _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_(
  440. is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value)
  441. : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
  442. _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q)
  443. _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) {
  444. c = std::move(__q.c);
  445. comp = std::move(__q.comp);
  446. return *this;
  447. }
  448. #endif // _LIBCPP_CXX03_LANG
  449. _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}
  450. _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);
  451. #ifndef _LIBCPP_CXX03_LANG
  452. _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
  453. #endif
  454. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
  455. _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
  456. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
  457. _LIBCPP_HIDE_FROM_ABI
  458. priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
  459. #ifndef _LIBCPP_CXX03_LANG
  460. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
  461. _LIBCPP_HIDE_FROM_ABI
  462. priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
  463. #endif // _LIBCPP_CXX03_LANG
  464. #if _LIBCPP_STD_VER >= 23
  465. template <_ContainerCompatibleRange<_Tp> _Range>
  466. _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
  467. : c(from_range, std::forward<_Range>(__range)), comp(__comp) {
  468. std::make_heap(c.begin(), c.end(), comp);
  469. }
  470. #endif
  471. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  472. _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
  473. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  474. _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);
  475. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  476. _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);
  477. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  478. _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
  479. #ifndef _LIBCPP_CXX03_LANG
  480. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  481. _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);
  482. template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
  483. _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);
  484. #endif // _LIBCPP_CXX03_LANG
  485. template <
  486. class _InputIter,
  487. class _Alloc,
  488. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
  489. int> = 0>
  490. _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);
  491. template <
  492. class _InputIter,
  493. class _Alloc,
  494. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
  495. int> = 0>
  496. _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);
  497. template <
  498. class _InputIter,
  499. class _Alloc,
  500. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
  501. int> = 0>
  502. _LIBCPP_HIDE_FROM_ABI priority_queue(
  503. _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
  504. #ifndef _LIBCPP_CXX03_LANG
  505. template <
  506. class _InputIter,
  507. class _Alloc,
  508. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
  509. int> = 0>
  510. _LIBCPP_HIDE_FROM_ABI
  511. priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);
  512. #endif // _LIBCPP_CXX03_LANG
  513. #if _LIBCPP_STD_VER >= 23
  514. template <_ContainerCompatibleRange<_Tp> _Range,
  515. class _Alloc,
  516. class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
  517. _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)
  518. : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) {
  519. std::make_heap(c.begin(), c.end(), comp);
  520. }
  521. template <_ContainerCompatibleRange<_Tp> _Range,
  522. class _Alloc,
  523. class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
  524. _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)
  525. : c(from_range, std::forward<_Range>(__range), __a), comp() {
  526. std::make_heap(c.begin(), c.end(), comp);
  527. }
  528. #endif
  529. _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
  530. _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
  531. _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
  532. _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
  533. #ifndef _LIBCPP_CXX03_LANG
  534. _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);
  535. # if _LIBCPP_STD_VER >= 23
  536. template <_ContainerCompatibleRange<_Tp> _Range>
  537. _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
  538. if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
  539. c.append_range(std::forward<_Range>(__range));
  540. } else {
  541. ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
  542. }
  543. std::make_heap(c.begin(), c.end(), comp);
  544. }
  545. # endif
  546. template <class... _Args>
  547. _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);
  548. #endif // _LIBCPP_CXX03_LANG
  549. _LIBCPP_HIDE_FROM_ABI void pop();
  550. _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
  551. _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value);
  552. _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
  553. };
  554. #if _LIBCPP_STD_VER >= 17
  555. template <class _Compare,
  556. class _Container,
  557. class = enable_if_t<!__is_allocator<_Compare>::value>,
  558. class = enable_if_t<!__is_allocator<_Container>::value> >
  559. priority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
  560. template <class _InputIterator,
  561. class _Compare = less<__iter_value_type<_InputIterator>>,
  562. class _Container = vector<__iter_value_type<_InputIterator>>,
  563. class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
  564. class = enable_if_t<!__is_allocator<_Compare>::value>,
  565. class = enable_if_t<!__is_allocator<_Container>::value> >
  566. priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
  567. -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
  568. template <class _Compare,
  569. class _Container,
  570. class _Alloc,
  571. class = enable_if_t<!__is_allocator<_Compare>::value>,
  572. class = enable_if_t<!__is_allocator<_Container>::value>,
  573. class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
  574. priority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
  575. template <class _InputIterator,
  576. class _Allocator,
  577. class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
  578. class = enable_if_t<__is_allocator<_Allocator>::value> >
  579. priority_queue(_InputIterator, _InputIterator, _Allocator)
  580. -> priority_queue<__iter_value_type<_InputIterator>,
  581. vector<__iter_value_type<_InputIterator>, _Allocator>,
  582. less<__iter_value_type<_InputIterator>>>;
  583. template <class _InputIterator,
  584. class _Compare,
  585. class _Allocator,
  586. class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
  587. class = enable_if_t<!__is_allocator<_Compare>::value>,
  588. class = enable_if_t<__is_allocator<_Allocator>::value> >
  589. priority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
  590. -> priority_queue<__iter_value_type<_InputIterator>,
  591. vector<__iter_value_type<_InputIterator>, _Allocator>,
  592. _Compare>;
  593. template <class _InputIterator,
  594. class _Compare,
  595. class _Container,
  596. class _Alloc,
  597. class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
  598. class = enable_if_t<!__is_allocator<_Compare>::value>,
  599. class = enable_if_t<!__is_allocator<_Container>::value>,
  600. class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
  601. priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
  602. -> priority_queue<typename _Container::value_type, _Container, _Compare>;
  603. #endif
  604. #if _LIBCPP_STD_VER >= 23
  605. template <ranges::input_range _Range,
  606. class _Compare = less<ranges::range_value_t<_Range>>,
  607. class = enable_if_t<!__is_allocator<_Compare>::value>>
  608. priority_queue(from_range_t, _Range&&, _Compare = _Compare())
  609. -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>;
  610. template <ranges::input_range _Range,
  611. class _Compare,
  612. class _Alloc,
  613. class = enable_if_t<!__is_allocator<_Compare>::value>,
  614. class = enable_if_t<__is_allocator<_Alloc>::value>>
  615. priority_queue(from_range_t, _Range&&, _Compare, _Alloc)
  616. -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>;
  617. template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>>
  618. priority_queue(from_range_t, _Range&&, _Alloc)
  619. -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
  620. #endif
  621. template <class _Tp, class _Container, class _Compare>
  622. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)
  623. : c(__c), comp(__comp) {
  624. std::make_heap(c.begin(), c.end(), comp);
  625. }
  626. #ifndef _LIBCPP_CXX03_LANG
  627. template <class _Tp, class _Container, class _Compare>
  628. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)
  629. : c(std::move(__c)), comp(__comp) {
  630. std::make_heap(c.begin(), c.end(), comp);
  631. }
  632. #endif // _LIBCPP_CXX03_LANG
  633. template <class _Tp, class _Container, class _Compare>
  634. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
  635. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  636. _InputIter __f, _InputIter __l, const value_compare& __comp)
  637. : c(__f, __l), comp(__comp) {
  638. std::make_heap(c.begin(), c.end(), comp);
  639. }
  640. template <class _Tp, class _Container, class _Compare>
  641. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
  642. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  643. _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
  644. : c(__c), comp(__comp) {
  645. c.insert(c.end(), __f, __l);
  646. std::make_heap(c.begin(), c.end(), comp);
  647. }
  648. #ifndef _LIBCPP_CXX03_LANG
  649. template <class _Tp, class _Container, class _Compare>
  650. template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
  651. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  652. _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)
  653. : c(std::move(__c)), comp(__comp) {
  654. c.insert(c.end(), __f, __l);
  655. std::make_heap(c.begin(), c.end(), comp);
  656. }
  657. #endif // _LIBCPP_CXX03_LANG
  658. template <class _Tp, class _Container, class _Compare>
  659. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  660. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {}
  661. template <class _Tp, class _Container, class _Compare>
  662. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  663. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a)
  664. : c(__a), comp(__comp) {}
  665. template <class _Tp, class _Container, class _Compare>
  666. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  667. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  668. const value_compare& __comp, const container_type& __c, const _Alloc& __a)
  669. : c(__c, __a), comp(__comp) {
  670. std::make_heap(c.begin(), c.end(), comp);
  671. }
  672. template <class _Tp, class _Container, class _Compare>
  673. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  674. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)
  675. : c(__q.c, __a), comp(__q.comp) {}
  676. #ifndef _LIBCPP_CXX03_LANG
  677. template <class _Tp, class _Container, class _Compare>
  678. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  679. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  680. const value_compare& __comp, container_type&& __c, const _Alloc& __a)
  681. : c(std::move(__c), __a), comp(__comp) {
  682. std::make_heap(c.begin(), c.end(), comp);
  683. }
  684. template <class _Tp, class _Container, class _Compare>
  685. template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
  686. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)
  687. : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
  688. #endif // _LIBCPP_CXX03_LANG
  689. template <class _Tp, class _Container, class _Compare>
  690. template <
  691. class _InputIter,
  692. class _Alloc,
  693. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
  694. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a)
  695. : c(__f, __l, __a), comp() {
  696. std::make_heap(c.begin(), c.end(), comp);
  697. }
  698. template <class _Tp, class _Container, class _Compare>
  699. template <
  700. class _InputIter,
  701. class _Alloc,
  702. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
  703. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  704. _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)
  705. : c(__f, __l, __a), comp(__comp) {
  706. std::make_heap(c.begin(), c.end(), comp);
  707. }
  708. template <class _Tp, class _Container, class _Compare>
  709. template <
  710. class _InputIter,
  711. class _Alloc,
  712. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
  713. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  714. _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)
  715. : c(__c, __a), comp(__comp) {
  716. c.insert(c.end(), __f, __l);
  717. std::make_heap(c.begin(), c.end(), comp);
  718. }
  719. #ifndef _LIBCPP_CXX03_LANG
  720. template <class _Tp, class _Container, class _Compare>
  721. template <
  722. class _InputIter,
  723. class _Alloc,
  724. __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
  725. inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
  726. _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a)
  727. : c(std::move(__c), __a), comp(__comp) {
  728. c.insert(c.end(), __f, __l);
  729. std::make_heap(c.begin(), c.end(), comp);
  730. }
  731. #endif // _LIBCPP_CXX03_LANG
  732. template <class _Tp, class _Container, class _Compare>
  733. inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
  734. c.push_back(__v);
  735. std::push_heap(c.begin(), c.end(), comp);
  736. }
  737. #ifndef _LIBCPP_CXX03_LANG
  738. template <class _Tp, class _Container, class _Compare>
  739. inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {
  740. c.push_back(std::move(__v));
  741. std::push_heap(c.begin(), c.end(), comp);
  742. }
  743. template <class _Tp, class _Container, class _Compare>
  744. template <class... _Args>
  745. inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) {
  746. c.emplace_back(std::forward<_Args>(__args)...);
  747. std::push_heap(c.begin(), c.end(), comp);
  748. }
  749. #endif // _LIBCPP_CXX03_LANG
  750. template <class _Tp, class _Container, class _Compare>
  751. inline void priority_queue<_Tp, _Container, _Compare>::pop() {
  752. std::pop_heap(c.begin(), c.end(), comp);
  753. c.pop_back();
  754. }
  755. template <class _Tp, class _Container, class _Compare>
  756. inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
  757. _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) {
  758. using std::swap;
  759. swap(c, __q.c);
  760. swap(comp, __q.comp);
  761. }
  762. template <class _Tp,
  763. class _Container,
  764. class _Compare,
  765. __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0>
  766. inline _LIBCPP_HIDE_FROM_ABI void
  767. swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)
  768. _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
  769. __x.swap(__y);
  770. }
  771. template <class _Tp, class _Container, class _Compare, class _Alloc>
  772. struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
  773. : public uses_allocator<_Container, _Alloc> {};
  774. _LIBCPP_END_NAMESPACE_STD
  775. _LIBCPP_POP_MACROS
  776. #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
  777. # include <concepts>
  778. # include <cstdlib>
  779. # include <functional>
  780. # include <type_traits>
  781. #endif
  782. #endif // _LIBCPP_QUEUE