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