xref: /freebsd/contrib/llvm-project/libcxx/include/__cxx03/queue (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric// -*- C++ -*-
2*700637cbSDimitry Andric//===----------------------------------------------------------------------===//
3*700637cbSDimitry Andric//
4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*700637cbSDimitry Andric//
8*700637cbSDimitry Andric//===----------------------------------------------------------------------===//
9*700637cbSDimitry Andric
10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_QUEUE
11*700637cbSDimitry Andric#define _LIBCPP___CXX03_QUEUE
12*700637cbSDimitry Andric
13*700637cbSDimitry Andric/*
14*700637cbSDimitry Andric    queue synopsis
15*700637cbSDimitry Andric
16*700637cbSDimitry Andricnamespace std
17*700637cbSDimitry Andric{
18*700637cbSDimitry Andric
19*700637cbSDimitry Andrictemplate <class T, class Container = deque<T>>
20*700637cbSDimitry Andricclass queue
21*700637cbSDimitry Andric{
22*700637cbSDimitry Andricpublic:
23*700637cbSDimitry Andric    typedef Container                                container_type;
24*700637cbSDimitry Andric    typedef typename container_type::value_type      value_type;
25*700637cbSDimitry Andric    typedef typename container_type::reference       reference;
26*700637cbSDimitry Andric    typedef typename container_type::const_reference const_reference;
27*700637cbSDimitry Andric    typedef typename container_type::size_type       size_type;
28*700637cbSDimitry Andric
29*700637cbSDimitry Andricprotected:
30*700637cbSDimitry Andric    container_type c;
31*700637cbSDimitry Andric
32*700637cbSDimitry Andricpublic:
33*700637cbSDimitry Andric    queue() = default;
34*700637cbSDimitry Andric    ~queue() = default;
35*700637cbSDimitry Andric
36*700637cbSDimitry Andric    queue(const queue& q) = default;
37*700637cbSDimitry Andric    queue(queue&& q) = default;
38*700637cbSDimitry Andric
39*700637cbSDimitry Andric    queue& operator=(const queue& q) = default;
40*700637cbSDimitry Andric    queue& operator=(queue&& q) = default;
41*700637cbSDimitry Andric
42*700637cbSDimitry Andric    explicit queue(const container_type& c);
43*700637cbSDimitry Andric    explicit queue(container_type&& c)
44*700637cbSDimitry Andric    template<class InputIterator>
45*700637cbSDimitry Andric        queue(InputIterator first, InputIterator last); // since C++23
46*700637cbSDimitry Andric    template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23
47*700637cbSDimitry Andric    template <class Alloc>
48*700637cbSDimitry Andric        explicit queue(const Alloc& a);
49*700637cbSDimitry Andric    template <class Alloc>
50*700637cbSDimitry Andric        queue(const container_type& c, const Alloc& a);
51*700637cbSDimitry Andric    template <class Alloc>
52*700637cbSDimitry Andric        queue(container_type&& c, const Alloc& a);
53*700637cbSDimitry Andric    template <class Alloc>
54*700637cbSDimitry Andric        queue(const queue& q, const Alloc& a);
55*700637cbSDimitry Andric    template <class Alloc>
56*700637cbSDimitry Andric        queue(queue&& q, const Alloc& a);
57*700637cbSDimitry Andric    template <class InputIterator, class Alloc>
58*700637cbSDimitry Andric        queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
59*700637cbSDimitry Andric    template<container-compatible-range<T> R, class Alloc>
60*700637cbSDimitry Andric        queue(from_range_t, R&& rg, const Alloc&); // since C++23
61*700637cbSDimitry Andric
62*700637cbSDimitry Andric    bool      empty() const;
63*700637cbSDimitry Andric    size_type size() const;
64*700637cbSDimitry Andric
65*700637cbSDimitry Andric    reference       front();
66*700637cbSDimitry Andric    const_reference front() const;
67*700637cbSDimitry Andric    reference       back();
68*700637cbSDimitry Andric    const_reference back() const;
69*700637cbSDimitry Andric
70*700637cbSDimitry Andric    void push(const value_type& v);
71*700637cbSDimitry Andric    void push(value_type&& v);
72*700637cbSDimitry Andric    template<container-compatible-range<T> R>
73*700637cbSDimitry Andric      void push_range(R&& rg); // C++23
74*700637cbSDimitry Andric    template <class... Args> reference emplace(Args&&... args); // reference in C++17
75*700637cbSDimitry Andric    void pop();
76*700637cbSDimitry Andric
77*700637cbSDimitry Andric    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
78*700637cbSDimitry Andric};
79*700637cbSDimitry Andric
80*700637cbSDimitry Andrictemplate<class Container>
81*700637cbSDimitry Andric  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
82*700637cbSDimitry Andric
83*700637cbSDimitry Andrictemplate<class InputIterator>
84*700637cbSDimitry Andric  queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
85*700637cbSDimitry Andric
86*700637cbSDimitry Andrictemplate<ranges::input_range R>
87*700637cbSDimitry Andric  queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23
88*700637cbSDimitry Andric
89*700637cbSDimitry Andrictemplate<class Container, class Allocator>
90*700637cbSDimitry Andric  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
91*700637cbSDimitry Andric
92*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator>
93*700637cbSDimitry Andric  queue(InputIterator, InputIterator, Allocator)
94*700637cbSDimitry Andric  -> queue<iter-value-type<InputIterator>,
95*700637cbSDimitry Andric           deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
96*700637cbSDimitry Andric
97*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator>
98*700637cbSDimitry Andric    queue(from_range_t, R&&, Allocator)
99*700637cbSDimitry Andric      -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23
100*700637cbSDimitry Andric
101*700637cbSDimitry Andrictemplate <class T, class Container>
102*700637cbSDimitry Andric  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
103*700637cbSDimitry Andric
104*700637cbSDimitry Andrictemplate <class T, class Container>
105*700637cbSDimitry Andric  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
106*700637cbSDimitry Andric
107*700637cbSDimitry Andrictemplate <class T, class Container>
108*700637cbSDimitry Andric  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
109*700637cbSDimitry Andric
110*700637cbSDimitry Andrictemplate <class T, class Container>
111*700637cbSDimitry Andric  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
112*700637cbSDimitry Andric
113*700637cbSDimitry Andrictemplate <class T, class Container>
114*700637cbSDimitry Andric  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
115*700637cbSDimitry Andric
116*700637cbSDimitry Andrictemplate <class T, class Container>
117*700637cbSDimitry Andric  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
118*700637cbSDimitry Andric
119*700637cbSDimitry Andrictemplate<class T, three_way_comparable Container>
120*700637cbSDimitry Andric  compare_three_way_result_t<Container>
121*700637cbSDimitry Andric    operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);  // since C++20
122*700637cbSDimitry Andric
123*700637cbSDimitry Andrictemplate <class T, class Container>
124*700637cbSDimitry Andric  void swap(queue<T, Container>& x, queue<T, Container>& y)
125*700637cbSDimitry Andric  noexcept(noexcept(x.swap(y)));
126*700637cbSDimitry Andric
127*700637cbSDimitry Andrictemplate <class T, class Container = vector<T>,
128*700637cbSDimitry Andric          class Compare = less<typename Container::value_type>>
129*700637cbSDimitry Andricclass priority_queue
130*700637cbSDimitry Andric{
131*700637cbSDimitry Andricpublic:
132*700637cbSDimitry Andric    typedef Container                                container_type;
133*700637cbSDimitry Andric    typedef typename container_type::value_type      value_type;
134*700637cbSDimitry Andric    typedef typename container_type::reference       reference;
135*700637cbSDimitry Andric    typedef typename container_type::const_reference const_reference;
136*700637cbSDimitry Andric    typedef typename container_type::size_type       size_type;
137*700637cbSDimitry Andric
138*700637cbSDimitry Andricprotected:
139*700637cbSDimitry Andric    container_type c;
140*700637cbSDimitry Andric    Compare comp;
141*700637cbSDimitry Andric
142*700637cbSDimitry Andricpublic:
143*700637cbSDimitry Andric    priority_queue() : priority_queue(Compare()) {} // C++20
144*700637cbSDimitry Andric    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
145*700637cbSDimitry Andric    priority_queue(const Compare& x, const Container&);
146*700637cbSDimitry Andric    explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
147*700637cbSDimitry Andric    priority_queue(const Compare& x, Container&&); // C++20
148*700637cbSDimitry Andric    template <class InputIterator>
149*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
150*700637cbSDimitry Andric                       const Compare& comp = Compare());
151*700637cbSDimitry Andric    template <class InputIterator>
152*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
153*700637cbSDimitry Andric                       const Compare& comp, const Container& c);
154*700637cbSDimitry Andric    template <class InputIterator>
155*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
156*700637cbSDimitry Andric                       const Compare& comp, Container&& c);
157*700637cbSDimitry Andric    template <container-compatible-range<T> R>
158*700637cbSDimitry Andric        priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23
159*700637cbSDimitry Andric    template <class Alloc>
160*700637cbSDimitry Andric        explicit priority_queue(const Alloc& a);
161*700637cbSDimitry Andric    template <class Alloc>
162*700637cbSDimitry Andric        priority_queue(const Compare& comp, const Alloc& a);
163*700637cbSDimitry Andric    template <class Alloc>
164*700637cbSDimitry Andric        priority_queue(const Compare& comp, const Container& c,
165*700637cbSDimitry Andric                       const Alloc& a);
166*700637cbSDimitry Andric    template <class Alloc>
167*700637cbSDimitry Andric        priority_queue(const Compare& comp, Container&& c,
168*700637cbSDimitry Andric                       const Alloc& a);
169*700637cbSDimitry Andric    template <class InputIterator>
170*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
171*700637cbSDimitry Andric                       const Alloc& a);
172*700637cbSDimitry Andric    template <class InputIterator>
173*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
174*700637cbSDimitry Andric                       const Compare& comp, const Alloc& a);
175*700637cbSDimitry Andric    template <class InputIterator>
176*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
177*700637cbSDimitry Andric                       const Compare& comp, const Container& c, const Alloc& a);
178*700637cbSDimitry Andric    template <class InputIterator>
179*700637cbSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
180*700637cbSDimitry Andric                       const Compare& comp, Container&& c, const Alloc& a);
181*700637cbSDimitry Andric    template <container-compatible-range<T> R, class Alloc>
182*700637cbSDimitry Andric      priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23
183*700637cbSDimitry Andric    template <container-compatible-range<T> R, class Alloc>
184*700637cbSDimitry Andric      priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23
185*700637cbSDimitry Andric    template <class Alloc>
186*700637cbSDimitry Andric        priority_queue(const priority_queue& q, const Alloc& a);
187*700637cbSDimitry Andric    template <class Alloc>
188*700637cbSDimitry Andric        priority_queue(priority_queue&& q, const Alloc& a);
189*700637cbSDimitry Andric
190*700637cbSDimitry Andric    bool            empty() const;
191*700637cbSDimitry Andric    size_type       size() const;
192*700637cbSDimitry Andric    const_reference top() const;
193*700637cbSDimitry Andric
194*700637cbSDimitry Andric    void push(const value_type& v);
195*700637cbSDimitry Andric    void push(value_type&& v);
196*700637cbSDimitry Andric    template<container-compatible-range<T> R>
197*700637cbSDimitry Andric      void push_range(R&& rg); // C++23
198*700637cbSDimitry Andric    template <class... Args> void emplace(Args&&... args);
199*700637cbSDimitry Andric    void pop();
200*700637cbSDimitry Andric
201*700637cbSDimitry Andric    void swap(priority_queue& q)
202*700637cbSDimitry Andric        noexcept(is_nothrow_swappable_v<Container> &&
203*700637cbSDimitry Andric                 is_nothrow_swappable_v<Comp>)
204*700637cbSDimitry Andric};
205*700637cbSDimitry Andric
206*700637cbSDimitry Andrictemplate <class Compare, class Container>
207*700637cbSDimitry Andricpriority_queue(Compare, Container)
208*700637cbSDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
209*700637cbSDimitry Andric
210*700637cbSDimitry Andrictemplate<class InputIterator,
211*700637cbSDimitry Andric         class Compare = less<iter-value-type<InputIterator>>,
212*700637cbSDimitry Andric         class Container = vector<iter-value-type<InputIterator>>>
213*700637cbSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
214*700637cbSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
215*700637cbSDimitry Andric
216*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>>
217*700637cbSDimitry Andric  priority_queue(from_range_t, R&&, Compare = Compare())
218*700637cbSDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23
219*700637cbSDimitry Andric
220*700637cbSDimitry Andrictemplate<class Compare, class Container, class Allocator>
221*700637cbSDimitry Andricpriority_queue(Compare, Container, Allocator)
222*700637cbSDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
223*700637cbSDimitry Andric
224*700637cbSDimitry Andrictemplate<class InputIterator, class Allocator>
225*700637cbSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator)
226*700637cbSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
227*700637cbSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>,
228*700637cbSDimitry Andric                      less<iter-value-type<InputIterator>>>; // C++17
229*700637cbSDimitry Andric
230*700637cbSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator>
231*700637cbSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator)
232*700637cbSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
233*700637cbSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
234*700637cbSDimitry Andric
235*700637cbSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator>
236*700637cbSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
237*700637cbSDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
238*700637cbSDimitry Andric
239*700637cbSDimitry Andrictemplate<ranges::input_range R, class Compare, class Allocator>
240*700637cbSDimitry Andric  priority_queue(from_range_t, R&&, Compare, Allocator)
241*700637cbSDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
242*700637cbSDimitry Andric                        Compare>; // C++23
243*700637cbSDimitry Andric
244*700637cbSDimitry Andrictemplate<ranges::input_range R, class Allocator>
245*700637cbSDimitry Andric  priority_queue(from_range_t, R&&, Allocator)
246*700637cbSDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23
247*700637cbSDimitry Andric
248*700637cbSDimitry Andrictemplate <class T, class Container, class Compare>
249*700637cbSDimitry Andric  void swap(priority_queue<T, Container, Compare>& x,
250*700637cbSDimitry Andric            priority_queue<T, Container, Compare>& y)
251*700637cbSDimitry Andric            noexcept(noexcept(x.swap(y)));
252*700637cbSDimitry Andric
253*700637cbSDimitry Andric}  // std
254*700637cbSDimitry Andric
255*700637cbSDimitry Andric*/
256*700637cbSDimitry Andric
257*700637cbSDimitry Andric#include <__cxx03/__algorithm/make_heap.h>
258*700637cbSDimitry Andric#include <__cxx03/__algorithm/pop_heap.h>
259*700637cbSDimitry Andric#include <__cxx03/__algorithm/push_heap.h>
260*700637cbSDimitry Andric#include <__cxx03/__config>
261*700637cbSDimitry Andric#include <__cxx03/__functional/operations.h>
262*700637cbSDimitry Andric#include <__cxx03/__fwd/deque.h>
263*700637cbSDimitry Andric#include <__cxx03/__fwd/queue.h>
264*700637cbSDimitry Andric#include <__cxx03/__iterator/back_insert_iterator.h>
265*700637cbSDimitry Andric#include <__cxx03/__iterator/iterator_traits.h>
266*700637cbSDimitry Andric#include <__cxx03/__memory/uses_allocator.h>
267*700637cbSDimitry Andric#include <__cxx03/__utility/forward.h>
268*700637cbSDimitry Andric#include <__cxx03/deque>
269*700637cbSDimitry Andric#include <__cxx03/vector>
270*700637cbSDimitry Andric#include <__cxx03/version>
271*700637cbSDimitry Andric
272*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
273*700637cbSDimitry Andric#  pragma GCC system_header
274*700637cbSDimitry Andric#endif
275*700637cbSDimitry Andric
276*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS
277*700637cbSDimitry Andric#include <__cxx03/__undef_macros>
278*700637cbSDimitry Andric
279*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
280*700637cbSDimitry Andric
281*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
282*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
283*700637cbSDimitry Andric
284*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
285*700637cbSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
286*700637cbSDimitry Andric
287*700637cbSDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
288*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue {
289*700637cbSDimitry Andricpublic:
290*700637cbSDimitry Andric  typedef _Container container_type;
291*700637cbSDimitry Andric  typedef typename container_type::value_type value_type;
292*700637cbSDimitry Andric  typedef typename container_type::reference reference;
293*700637cbSDimitry Andric  typedef typename container_type::const_reference const_reference;
294*700637cbSDimitry Andric  typedef typename container_type::size_type size_type;
295*700637cbSDimitry Andric  static_assert(is_same<_Tp, value_type>::value, "");
296*700637cbSDimitry Andric
297*700637cbSDimitry Andricprotected:
298*700637cbSDimitry Andric  container_type c;
299*700637cbSDimitry Andric
300*700637cbSDimitry Andricpublic:
301*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue() : c() {}
302*700637cbSDimitry Andric
303*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
304*700637cbSDimitry Andric
305*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {
306*700637cbSDimitry Andric    c = __q.c;
307*700637cbSDimitry Andric    return *this;
308*700637cbSDimitry Andric  }
309*700637cbSDimitry Andric
310*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}
311*700637cbSDimitry Andric
312*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
313*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}
314*700637cbSDimitry Andric
315*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
316*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {}
317*700637cbSDimitry Andric
318*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
319*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}
320*700637cbSDimitry Andric
321*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
322*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
323*700637cbSDimitry Andric
324*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
325*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); }
326*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); }
327*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }
328*700637cbSDimitry Andric
329*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
330*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
331*700637cbSDimitry Andric
332*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) {
333*700637cbSDimitry Andric    using std::swap;
334*700637cbSDimitry Andric    swap(c, __q.c);
335*700637cbSDimitry Andric  }
336*700637cbSDimitry Andric
337*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
338*700637cbSDimitry Andric
339*700637cbSDimitry Andric  template <class _T1, class _OtherContainer>
340*700637cbSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
341*700637cbSDimitry Andric  operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
342*700637cbSDimitry Andric
343*700637cbSDimitry Andric  template <class _T1, class _OtherContainer>
344*700637cbSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
345*700637cbSDimitry Andric  operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
346*700637cbSDimitry Andric};
347*700637cbSDimitry Andric
348*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
349*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
350*700637cbSDimitry Andric  return __x.c == __y.c;
351*700637cbSDimitry Andric}
352*700637cbSDimitry Andric
353*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
354*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
355*700637cbSDimitry Andric  return __x.c < __y.c;
356*700637cbSDimitry Andric}
357*700637cbSDimitry Andric
358*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
359*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
360*700637cbSDimitry Andric  return !(__x == __y);
361*700637cbSDimitry Andric}
362*700637cbSDimitry Andric
363*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
364*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
365*700637cbSDimitry Andric  return __y < __x;
366*700637cbSDimitry Andric}
367*700637cbSDimitry Andric
368*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
369*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
370*700637cbSDimitry Andric  return !(__x < __y);
371*700637cbSDimitry Andric}
372*700637cbSDimitry Andric
373*700637cbSDimitry Andrictemplate <class _Tp, class _Container>
374*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
375*700637cbSDimitry Andric  return !(__y < __x);
376*700637cbSDimitry Andric}
377*700637cbSDimitry Andric
378*700637cbSDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
379*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) {
380*700637cbSDimitry Andric  __x.swap(__y);
381*700637cbSDimitry Andric}
382*700637cbSDimitry Andric
383*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
384*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {
385*700637cbSDimitry Andric};
386*700637cbSDimitry Andric
387*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
388*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue {
389*700637cbSDimitry Andricpublic:
390*700637cbSDimitry Andric  typedef _Container container_type;
391*700637cbSDimitry Andric  typedef _Compare value_compare;
392*700637cbSDimitry Andric  typedef typename container_type::value_type value_type;
393*700637cbSDimitry Andric  typedef typename container_type::reference reference;
394*700637cbSDimitry Andric  typedef typename container_type::const_reference const_reference;
395*700637cbSDimitry Andric  typedef typename container_type::size_type size_type;
396*700637cbSDimitry Andric  static_assert(is_same<_Tp, value_type>::value, "");
397*700637cbSDimitry Andric
398*700637cbSDimitry Andricprotected:
399*700637cbSDimitry Andric  container_type c;
400*700637cbSDimitry Andric  value_compare comp;
401*700637cbSDimitry Andric
402*700637cbSDimitry Andricpublic:
403*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue() : c(), comp() {}
404*700637cbSDimitry Andric
405*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
406*700637cbSDimitry Andric
407*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {
408*700637cbSDimitry Andric    c    = __q.c;
409*700637cbSDimitry Andric    comp = __q.comp;
410*700637cbSDimitry Andric    return *this;
411*700637cbSDimitry Andric  }
412*700637cbSDimitry Andric
413*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}
414*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);
415*700637cbSDimitry Andric  template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
416*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
417*700637cbSDimitry Andric
418*700637cbSDimitry Andric  template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
419*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
420*700637cbSDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
421*700637cbSDimitry Andric
422*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
423*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
424*700637cbSDimitry Andric
425*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
426*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);
427*700637cbSDimitry Andric
428*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
429*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);
430*700637cbSDimitry Andric
431*700637cbSDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
432*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
433*700637cbSDimitry Andric
434*700637cbSDimitry Andric  template <
435*700637cbSDimitry Andric      class _InputIter,
436*700637cbSDimitry Andric      class _Alloc,
437*700637cbSDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
438*700637cbSDimitry Andric                    int> = 0>
439*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);
440*700637cbSDimitry Andric
441*700637cbSDimitry Andric  template <
442*700637cbSDimitry Andric      class _InputIter,
443*700637cbSDimitry Andric      class _Alloc,
444*700637cbSDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
445*700637cbSDimitry Andric                    int> = 0>
446*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);
447*700637cbSDimitry Andric
448*700637cbSDimitry Andric  template <
449*700637cbSDimitry Andric      class _InputIter,
450*700637cbSDimitry Andric      class _Alloc,
451*700637cbSDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
452*700637cbSDimitry Andric                    int> = 0>
453*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
454*700637cbSDimitry Andric      _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
455*700637cbSDimitry Andric
456*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
457*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
458*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
459*700637cbSDimitry Andric
460*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
461*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop();
462*700637cbSDimitry Andric
463*700637cbSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q);
464*700637cbSDimitry Andric
465*700637cbSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
466*700637cbSDimitry Andric};
467*700637cbSDimitry Andric
468*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
469*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)
470*700637cbSDimitry Andric    : c(__c), comp(__comp) {
471*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
472*700637cbSDimitry Andric}
473*700637cbSDimitry Andric
474*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
475*700637cbSDimitry Andrictemplate <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
476*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
477*700637cbSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp)
478*700637cbSDimitry Andric    : c(__f, __l), comp(__comp) {
479*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
480*700637cbSDimitry Andric}
481*700637cbSDimitry Andric
482*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
483*700637cbSDimitry Andrictemplate <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
484*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
485*700637cbSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
486*700637cbSDimitry Andric    : c(__c), comp(__comp) {
487*700637cbSDimitry Andric  c.insert(c.end(), __f, __l);
488*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
489*700637cbSDimitry Andric}
490*700637cbSDimitry Andric
491*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
492*700637cbSDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
493*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {}
494*700637cbSDimitry Andric
495*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
496*700637cbSDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
497*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a)
498*700637cbSDimitry Andric    : c(__a), comp(__comp) {}
499*700637cbSDimitry Andric
500*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
501*700637cbSDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
502*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
503*700637cbSDimitry Andric    const value_compare& __comp, const container_type& __c, const _Alloc& __a)
504*700637cbSDimitry Andric    : c(__c, __a), comp(__comp) {
505*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
506*700637cbSDimitry Andric}
507*700637cbSDimitry Andric
508*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
509*700637cbSDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
510*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)
511*700637cbSDimitry Andric    : c(__q.c, __a), comp(__q.comp) {}
512*700637cbSDimitry Andric
513*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
514*700637cbSDimitry Andrictemplate <
515*700637cbSDimitry Andric    class _InputIter,
516*700637cbSDimitry Andric    class _Alloc,
517*700637cbSDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
518*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a)
519*700637cbSDimitry Andric    : c(__f, __l, __a), comp() {
520*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
521*700637cbSDimitry Andric}
522*700637cbSDimitry Andric
523*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
524*700637cbSDimitry Andrictemplate <
525*700637cbSDimitry Andric    class _InputIter,
526*700637cbSDimitry Andric    class _Alloc,
527*700637cbSDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
528*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
529*700637cbSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)
530*700637cbSDimitry Andric    : c(__f, __l, __a), comp(__comp) {
531*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
532*700637cbSDimitry Andric}
533*700637cbSDimitry Andric
534*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
535*700637cbSDimitry Andrictemplate <
536*700637cbSDimitry Andric    class _InputIter,
537*700637cbSDimitry Andric    class _Alloc,
538*700637cbSDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
539*700637cbSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
540*700637cbSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)
541*700637cbSDimitry Andric    : c(__c, __a), comp(__comp) {
542*700637cbSDimitry Andric  c.insert(c.end(), __f, __l);
543*700637cbSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
544*700637cbSDimitry Andric}
545*700637cbSDimitry Andric
546*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
547*700637cbSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
548*700637cbSDimitry Andric  c.push_back(__v);
549*700637cbSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
550*700637cbSDimitry Andric}
551*700637cbSDimitry Andric
552*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
553*700637cbSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::pop() {
554*700637cbSDimitry Andric  std::pop_heap(c.begin(), c.end(), comp);
555*700637cbSDimitry Andric  c.pop_back();
556*700637cbSDimitry Andric}
557*700637cbSDimitry Andric
558*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
559*700637cbSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) {
560*700637cbSDimitry Andric  using std::swap;
561*700637cbSDimitry Andric  swap(c, __q.c);
562*700637cbSDimitry Andric  swap(comp, __q.comp);
563*700637cbSDimitry Andric}
564*700637cbSDimitry Andric
565*700637cbSDimitry Andrictemplate <class _Tp,
566*700637cbSDimitry Andric          class _Container,
567*700637cbSDimitry Andric          class _Compare,
568*700637cbSDimitry Andric          __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0>
569*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
570*700637cbSDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) {
571*700637cbSDimitry Andric  __x.swap(__y);
572*700637cbSDimitry Andric}
573*700637cbSDimitry Andric
574*700637cbSDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
575*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
576*700637cbSDimitry Andric    : public uses_allocator<_Container, _Alloc> {};
577*700637cbSDimitry Andric
578*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD
579*700637cbSDimitry Andric
580*700637cbSDimitry Andric_LIBCPP_POP_MACROS
581*700637cbSDimitry Andric
582*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
583*700637cbSDimitry Andric#  include <__cxx03/cstdlib>
584*700637cbSDimitry Andric#  include <__cxx03/functional>
585*700637cbSDimitry Andric#  include <__cxx03/type_traits>
586*700637cbSDimitry Andric#endif
587*700637cbSDimitry Andric
588*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_QUEUE
589