10b57cec5SDimitry Andric// -*- C++ -*-
2349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_QUEUE
110b57cec5SDimitry Andric#define _LIBCPP_QUEUE
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    queue synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andricnamespace std
170b57cec5SDimitry Andric{
180b57cec5SDimitry Andric
190b57cec5SDimitry Andrictemplate <class T, class Container = deque<T>>
200b57cec5SDimitry Andricclass queue
210b57cec5SDimitry Andric{
220b57cec5SDimitry Andricpublic:
230b57cec5SDimitry Andric    typedef Container                                container_type;
240b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
250b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
260b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
270b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
280b57cec5SDimitry Andric
290b57cec5SDimitry Andricprotected:
300b57cec5SDimitry Andric    container_type c;
310b57cec5SDimitry Andric
320b57cec5SDimitry Andricpublic:
330b57cec5SDimitry Andric    queue() = default;
340b57cec5SDimitry Andric    ~queue() = default;
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric    queue(const queue& q) = default;
370b57cec5SDimitry Andric    queue(queue&& q) = default;
380b57cec5SDimitry Andric
390b57cec5SDimitry Andric    queue& operator=(const queue& q) = default;
400b57cec5SDimitry Andric    queue& operator=(queue&& q) = default;
410b57cec5SDimitry Andric
420b57cec5SDimitry Andric    explicit queue(const container_type& c);
430b57cec5SDimitry Andric    explicit queue(container_type&& c)
4404eeddc0SDimitry Andric    template<class InputIterator>
4504eeddc0SDimitry Andric        queue(InputIterator first, InputIterator last); // since C++23
460b57cec5SDimitry Andric    template <class Alloc>
470b57cec5SDimitry Andric        explicit queue(const Alloc& a);
480b57cec5SDimitry Andric    template <class Alloc>
490b57cec5SDimitry Andric        queue(const container_type& c, const Alloc& a);
500b57cec5SDimitry Andric    template <class Alloc>
510b57cec5SDimitry Andric        queue(container_type&& c, const Alloc& a);
520b57cec5SDimitry Andric    template <class Alloc>
530b57cec5SDimitry Andric        queue(const queue& q, const Alloc& a);
540b57cec5SDimitry Andric    template <class Alloc>
550b57cec5SDimitry Andric        queue(queue&& q, const Alloc& a);
5604eeddc0SDimitry Andric    template <class InputIterator, class Alloc>
5704eeddc0SDimitry Andric        queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
580b57cec5SDimitry Andric
590b57cec5SDimitry Andric    bool      empty() const;
600b57cec5SDimitry Andric    size_type size() const;
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric    reference       front();
630b57cec5SDimitry Andric    const_reference front() const;
640b57cec5SDimitry Andric    reference       back();
650b57cec5SDimitry Andric    const_reference back() const;
660b57cec5SDimitry Andric
670b57cec5SDimitry Andric    void push(const value_type& v);
680b57cec5SDimitry Andric    void push(value_type&& v);
690b57cec5SDimitry Andric    template <class... Args> reference emplace(Args&&... args); // reference in C++17
700b57cec5SDimitry Andric    void pop();
710b57cec5SDimitry Andric
720b57cec5SDimitry Andric    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
730b57cec5SDimitry Andric};
740b57cec5SDimitry Andric
750b57cec5SDimitry Andrictemplate<class Container>
760b57cec5SDimitry Andric  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
770b57cec5SDimitry Andric
7804eeddc0SDimitry Andrictemplate<class InputIterator>
7904eeddc0SDimitry Andric  queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
8004eeddc0SDimitry Andric
810b57cec5SDimitry Andrictemplate<class Container, class Allocator>
820b57cec5SDimitry Andric  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
830b57cec5SDimitry Andric
8404eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator>
8504eeddc0SDimitry Andric  queue(InputIterator, InputIterator, Allocator)
8604eeddc0SDimitry Andric  -> queue<iter-value-type<InputIterator>,
8704eeddc0SDimitry Andric           deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
8804eeddc0SDimitry Andric
890b57cec5SDimitry Andrictemplate <class T, class Container>
900b57cec5SDimitry Andric  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
910b57cec5SDimitry Andric
920b57cec5SDimitry Andrictemplate <class T, class Container>
930b57cec5SDimitry Andric  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
940b57cec5SDimitry Andric
950b57cec5SDimitry Andrictemplate <class T, class Container>
960b57cec5SDimitry Andric  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
970b57cec5SDimitry Andric
980b57cec5SDimitry Andrictemplate <class T, class Container>
990b57cec5SDimitry Andric  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
1000b57cec5SDimitry Andric
1010b57cec5SDimitry Andrictemplate <class T, class Container>
1020b57cec5SDimitry Andric  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
1030b57cec5SDimitry Andric
1040b57cec5SDimitry Andrictemplate <class T, class Container>
1050b57cec5SDimitry Andric  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
1060b57cec5SDimitry Andric
1070b57cec5SDimitry Andrictemplate <class T, class Container>
1080b57cec5SDimitry Andric  void swap(queue<T, Container>& x, queue<T, Container>& y)
1090b57cec5SDimitry Andric  noexcept(noexcept(x.swap(y)));
1100b57cec5SDimitry Andric
1110b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>,
1120b57cec5SDimitry Andric          class Compare = less<typename Container::value_type>>
1130b57cec5SDimitry Andricclass priority_queue
1140b57cec5SDimitry Andric{
1150b57cec5SDimitry Andricpublic:
1160b57cec5SDimitry Andric    typedef Container                                container_type;
1170b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
1180b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
1190b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
1200b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
1210b57cec5SDimitry Andric
1220b57cec5SDimitry Andricprotected:
1230b57cec5SDimitry Andric    container_type c;
1240b57cec5SDimitry Andric    Compare comp;
1250b57cec5SDimitry Andric
1260b57cec5SDimitry Andricpublic:
127e8d8bef9SDimitry Andric    priority_queue() : priority_queue(Compare()) {} // C++20
128e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
129e8d8bef9SDimitry Andric    priority_queue(const Compare& x, const Container&);
130e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
131e8d8bef9SDimitry Andric    priority_queue(const Compare& x, Container&&); // C++20
1320b57cec5SDimitry Andric    template <class InputIterator>
1330b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
1340b57cec5SDimitry Andric                       const Compare& comp = Compare());
1350b57cec5SDimitry Andric    template <class InputIterator>
1360b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
137349cc55cSDimitry Andric                       const Compare& comp, const Container& c);
1380b57cec5SDimitry Andric    template <class InputIterator>
1390b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
140349cc55cSDimitry Andric                       const Compare& comp, Container&& c);
1410b57cec5SDimitry Andric    template <class Alloc>
1420b57cec5SDimitry Andric        explicit priority_queue(const Alloc& a);
1430b57cec5SDimitry Andric    template <class Alloc>
1440b57cec5SDimitry Andric        priority_queue(const Compare& comp, const Alloc& a);
1450b57cec5SDimitry Andric    template <class Alloc>
146349cc55cSDimitry Andric        priority_queue(const Compare& comp, const Container& c,
1470b57cec5SDimitry Andric                       const Alloc& a);
1480b57cec5SDimitry Andric    template <class Alloc>
149349cc55cSDimitry Andric        priority_queue(const Compare& comp, Container&& c,
1500b57cec5SDimitry Andric                       const Alloc& a);
151349cc55cSDimitry Andric    template <class InputIterator>
152349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
153349cc55cSDimitry Andric                       const Alloc& a);
154349cc55cSDimitry Andric    template <class InputIterator>
155349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
156349cc55cSDimitry Andric                       const Compare& comp, const Alloc& a);
157349cc55cSDimitry Andric    template <class InputIterator>
158349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
159349cc55cSDimitry Andric                       const Compare& comp, const Container& c, const Alloc& a);
160349cc55cSDimitry Andric    template <class InputIterator>
161349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
162349cc55cSDimitry Andric                       const Compare& comp, Container&& c, const Alloc& a);
1630b57cec5SDimitry Andric    template <class Alloc>
1640b57cec5SDimitry Andric        priority_queue(const priority_queue& q, const Alloc& a);
1650b57cec5SDimitry Andric    template <class Alloc>
1660b57cec5SDimitry Andric        priority_queue(priority_queue&& q, const Alloc& a);
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andric    bool            empty() const;
1690b57cec5SDimitry Andric    size_type       size() const;
1700b57cec5SDimitry Andric    const_reference top() const;
1710b57cec5SDimitry Andric
1720b57cec5SDimitry Andric    void push(const value_type& v);
1730b57cec5SDimitry Andric    void push(value_type&& v);
1740b57cec5SDimitry Andric    template <class... Args> void emplace(Args&&... args);
1750b57cec5SDimitry Andric    void pop();
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric    void swap(priority_queue& q)
1780b57cec5SDimitry Andric        noexcept(is_nothrow_swappable_v<Container> &&
1790b57cec5SDimitry Andric                 is_nothrow_swappable_v<Comp>)
1800b57cec5SDimitry Andric};
1810b57cec5SDimitry Andric
1820b57cec5SDimitry Andrictemplate <class Compare, class Container>
1830b57cec5SDimitry Andricpriority_queue(Compare, Container)
1840b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1850b57cec5SDimitry Andric
1860b57cec5SDimitry Andrictemplate<class InputIterator,
187349cc55cSDimitry Andric         class Compare = less<iter-value-type<InputIterator>>,
188349cc55cSDimitry Andric         class Container = vector<iter-value-type<InputIterator>>>
1890b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
190349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator>
1930b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator)
1940b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1950b57cec5SDimitry Andric
196349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
197349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator)
198349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
199349cc55cSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>,
200349cc55cSDimitry Andric                      less<iter-value-type<InputIterator>>>; // C++17
201349cc55cSDimitry Andric
202349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator>
203349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator)
204349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
205349cc55cSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
206349cc55cSDimitry Andric
207349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator>
208349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
209349cc55cSDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
210349cc55cSDimitry Andric
2110b57cec5SDimitry Andrictemplate <class T, class Container, class Compare>
2120b57cec5SDimitry Andric  void swap(priority_queue<T, Container, Compare>& x,
2130b57cec5SDimitry Andric            priority_queue<T, Container, Compare>& y)
2140b57cec5SDimitry Andric            noexcept(noexcept(x.swap(y)));
2150b57cec5SDimitry Andric
2160b57cec5SDimitry Andric}  // std
2170b57cec5SDimitry Andric
2180b57cec5SDimitry Andric*/
2190b57cec5SDimitry Andric
22081ad6265SDimitry Andric#include <__algorithm/make_heap.h>
22181ad6265SDimitry Andric#include <__algorithm/pop_heap.h>
22281ad6265SDimitry Andric#include <__algorithm/push_heap.h>
22381ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
2240b57cec5SDimitry Andric#include <__config>
22581ad6265SDimitry Andric#include <__functional/operations.h>
22604eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
227fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
228fe6060f1SDimitry Andric#include <__utility/forward.h>
229fe6060f1SDimitry Andric#include <deque>
23004eeddc0SDimitry Andric#include <type_traits>
231fe6060f1SDimitry Andric#include <vector>
23204eeddc0SDimitry Andric#include <version>
2330b57cec5SDimitry Andric
23481ad6265SDimitry Andric// standard-mandated includes
235bdd1243dSDimitry Andric
236bdd1243dSDimitry Andric// [queue.syn]
23781ad6265SDimitry Andric#include <compare>
23881ad6265SDimitry Andric#include <initializer_list>
23981ad6265SDimitry Andric
2400b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2410b57cec5SDimitry Andric#  pragma GCC system_header
2420b57cec5SDimitry Andric#endif
2430b57cec5SDimitry Andric
2440b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2450b57cec5SDimitry Andric
2460b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
2470b57cec5SDimitry Andric
2480b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2490b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2500b57cec5SDimitry Andricbool
2510b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2520b57cec5SDimitry Andric
2530b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2540b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2550b57cec5SDimitry Andricbool
2560b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2570b57cec5SDimitry Andric
2580b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
2590b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue
2600b57cec5SDimitry Andric{
2610b57cec5SDimitry Andricpublic:
2620b57cec5SDimitry Andric    typedef _Container                               container_type;
2630b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
2640b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
2650b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
2660b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
2670b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
2680b57cec5SDimitry Andric
2690b57cec5SDimitry Andricprotected:
2700b57cec5SDimitry Andric    container_type c;
2710b57cec5SDimitry Andric
2720b57cec5SDimitry Andricpublic:
2730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2740b57cec5SDimitry Andric    queue()
2750b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2760b57cec5SDimitry Andric        : c() {}
2770b57cec5SDimitry Andric
2780b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2790b57cec5SDimitry Andric    queue(const queue& __q) : c(__q.c) {}
2800b57cec5SDimitry Andric
28104eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20
28204eeddc0SDimitry Andric    template <class _InputIterator,
28304eeddc0SDimitry Andric              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
28404eeddc0SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
28504eeddc0SDimitry Andric    queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
28604eeddc0SDimitry Andric
28704eeddc0SDimitry Andric    template <class _InputIterator,
28804eeddc0SDimitry Andric              class _Alloc,
28904eeddc0SDimitry Andric              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
29004eeddc0SDimitry Andric              class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
29104eeddc0SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
29204eeddc0SDimitry Andric    queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {}
29304eeddc0SDimitry Andric#endif
29404eeddc0SDimitry Andric
2950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2960b57cec5SDimitry Andric    queue& operator=(const queue& __q) {c = __q.c; return *this;}
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2990b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3000b57cec5SDimitry Andric    queue(queue&& __q)
3010b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
3020b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)) {}
3030b57cec5SDimitry Andric
3040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3050b57cec5SDimitry Andric    queue& operator=(queue&& __q)
3060b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
3070b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); return *this;}
3080b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3110b57cec5SDimitry Andric    explicit queue(const container_type& __c)  : c(__c) {}
3120b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3140b57cec5SDimitry Andric    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
3150b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3160b57cec5SDimitry Andric    template <class _Alloc>
3170b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3180b57cec5SDimitry Andric        explicit queue(const _Alloc& __a,
319349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3200b57cec5SDimitry Andric            : c(__a) {}
3210b57cec5SDimitry Andric    template <class _Alloc>
3220b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3230b57cec5SDimitry Andric        queue(const queue& __q, const _Alloc& __a,
324349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3250b57cec5SDimitry Andric            : c(__q.c, __a) {}
3260b57cec5SDimitry Andric    template <class _Alloc>
3270b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3280b57cec5SDimitry Andric        queue(const container_type& __c, const _Alloc& __a,
329349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3300b57cec5SDimitry Andric            : c(__c, __a) {}
3310b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3320b57cec5SDimitry Andric    template <class _Alloc>
3330b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3340b57cec5SDimitry Andric        queue(container_type&& __c, const _Alloc& __a,
335349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3360b57cec5SDimitry Andric            : c(_VSTD::move(__c), __a) {}
3370b57cec5SDimitry Andric    template <class _Alloc>
3380b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3390b57cec5SDimitry Andric        queue(queue&& __q, const _Alloc& __a,
340349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3410b57cec5SDimitry Andric            : c(_VSTD::move(__q.c), __a) {}
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3440b57cec5SDimitry Andric
3450b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
3460b57cec5SDimitry Andric    bool      empty() const {return c.empty();}
3470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3480b57cec5SDimitry Andric    size_type size() const  {return c.size();}
3490b57cec5SDimitry Andric
3500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3510b57cec5SDimitry Andric    reference       front()       {return c.front();}
3520b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3530b57cec5SDimitry Andric    const_reference front() const {return c.front();}
3540b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3550b57cec5SDimitry Andric    reference       back()        {return c.back();}
3560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3570b57cec5SDimitry Andric    const_reference back() const  {return c.back();}
3580b57cec5SDimitry Andric
3590b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3600b57cec5SDimitry Andric    void push(const value_type& __v) {c.push_back(__v);}
3610b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3620b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3630b57cec5SDimitry Andric    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3640b57cec5SDimitry Andric    template <class... _Args>
3650b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3660b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
3670b57cec5SDimitry Andric        decltype(auto) emplace(_Args&&... __args)
3680b57cec5SDimitry Andric            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3690b57cec5SDimitry Andric#else
3700b57cec5SDimitry Andric        void     emplace(_Args&&... __args)
3710b57cec5SDimitry Andric            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3720b57cec5SDimitry Andric#endif
3730b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3740b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3750b57cec5SDimitry Andric    void pop() {c.pop_front();}
3760b57cec5SDimitry Andric
3770b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3780b57cec5SDimitry Andric    void swap(queue& __q)
3790b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3800b57cec5SDimitry Andric    {
3810b57cec5SDimitry Andric        using _VSTD::swap;
3820b57cec5SDimitry Andric        swap(c, __q.c);
3830b57cec5SDimitry Andric    }
3840b57cec5SDimitry Andric
385bdd1243dSDimitry Andric    _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
386bdd1243dSDimitry Andric
3870b57cec5SDimitry Andric    template <class _T1, class _C1>
3880b57cec5SDimitry Andric    friend
3890b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3900b57cec5SDimitry Andric    bool
3910b57cec5SDimitry Andric    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3920b57cec5SDimitry Andric
3930b57cec5SDimitry Andric    template <class _T1, class _C1>
3940b57cec5SDimitry Andric    friend
3950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3960b57cec5SDimitry Andric    bool
3970b57cec5SDimitry Andric    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3980b57cec5SDimitry Andric};
3990b57cec5SDimitry Andric
40004eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 14
4010b57cec5SDimitry Andrictemplate<class _Container,
402349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>
4030b57cec5SDimitry Andric>
4040b57cec5SDimitry Andricqueue(_Container)
4050b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
4060b57cec5SDimitry Andric
4070b57cec5SDimitry Andrictemplate<class _Container,
4080b57cec5SDimitry Andric         class _Alloc,
409349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
410349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
4110b57cec5SDimitry Andric>
4120b57cec5SDimitry Andricqueue(_Container, _Alloc)
4130b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
4140b57cec5SDimitry Andric#endif
4150b57cec5SDimitry Andric
41604eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20
41704eeddc0SDimitry Andrictemplate <class _InputIterator,
41804eeddc0SDimitry Andric          class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
41904eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator)
42004eeddc0SDimitry Andric    -> queue<__iter_value_type<_InputIterator>>;
42104eeddc0SDimitry Andric
42204eeddc0SDimitry Andrictemplate <class _InputIterator,
42304eeddc0SDimitry Andric          class _Alloc,
42404eeddc0SDimitry Andric          class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
42504eeddc0SDimitry Andric          class = __enable_if_t<__is_allocator<_Alloc>::value>>
42604eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc)
42704eeddc0SDimitry Andric    -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
42804eeddc0SDimitry Andric#endif
42904eeddc0SDimitry Andric
4300b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4310b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4320b57cec5SDimitry Andricbool
4330b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4340b57cec5SDimitry Andric{
4350b57cec5SDimitry Andric    return __x.c == __y.c;
4360b57cec5SDimitry Andric}
4370b57cec5SDimitry Andric
4380b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4390b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4400b57cec5SDimitry Andricbool
4410b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4420b57cec5SDimitry Andric{
4430b57cec5SDimitry Andric    return __x.c < __y.c;
4440b57cec5SDimitry Andric}
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4470b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4480b57cec5SDimitry Andricbool
4490b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4500b57cec5SDimitry Andric{
4510b57cec5SDimitry Andric    return !(__x == __y);
4520b57cec5SDimitry Andric}
4530b57cec5SDimitry Andric
4540b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4550b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4560b57cec5SDimitry Andricbool
4570b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4580b57cec5SDimitry Andric{
4590b57cec5SDimitry Andric    return __y < __x;
4600b57cec5SDimitry Andric}
4610b57cec5SDimitry Andric
4620b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4630b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4640b57cec5SDimitry Andricbool
4650b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4660b57cec5SDimitry Andric{
4670b57cec5SDimitry Andric    return !(__x < __y);
4680b57cec5SDimitry Andric}
4690b57cec5SDimitry Andric
4700b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4710b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4720b57cec5SDimitry Andricbool
4730b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4740b57cec5SDimitry Andric{
4750b57cec5SDimitry Andric    return !(__y < __x);
4760b57cec5SDimitry Andric}
4770b57cec5SDimitry Andric
4780b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4790b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
480349cc55cSDimitry Andric__enable_if_t<__is_swappable<_Container>::value, void>
4810b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4820b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4830b57cec5SDimitry Andric{
4840b57cec5SDimitry Andric    __x.swap(__y);
4850b57cec5SDimitry Andric}
4860b57cec5SDimitry Andric
4870b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
4880b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4890b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
4900b57cec5SDimitry Andric{
4910b57cec5SDimitry Andric};
4920b57cec5SDimitry Andric
4930b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>,
4940b57cec5SDimitry Andric          class _Compare = less<typename _Container::value_type> >
4950b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue
4960b57cec5SDimitry Andric{
4970b57cec5SDimitry Andricpublic:
4980b57cec5SDimitry Andric    typedef _Container                               container_type;
4990b57cec5SDimitry Andric    typedef _Compare                                 value_compare;
5000b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
5010b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
5020b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
5030b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
5040b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
5050b57cec5SDimitry Andric
5060b57cec5SDimitry Andricprotected:
5070b57cec5SDimitry Andric    container_type c;
5080b57cec5SDimitry Andric    value_compare comp;
5090b57cec5SDimitry Andric
5100b57cec5SDimitry Andricpublic:
5110b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5120b57cec5SDimitry Andric    priority_queue()
5130b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
5140b57cec5SDimitry Andric                   is_nothrow_default_constructible<value_compare>::value)
5150b57cec5SDimitry Andric        : c(), comp() {}
5160b57cec5SDimitry Andric
5170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5180b57cec5SDimitry Andric    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
5190b57cec5SDimitry Andric
5200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5210b57cec5SDimitry Andric    priority_queue& operator=(const priority_queue& __q)
5220b57cec5SDimitry Andric        {c = __q.c; comp = __q.comp; return *this;}
5230b57cec5SDimitry Andric
5240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5260b57cec5SDimitry Andric    priority_queue(priority_queue&& __q)
5270b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
5280b57cec5SDimitry Andric                   is_nothrow_move_constructible<value_compare>::value)
5290b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
5300b57cec5SDimitry Andric
5310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5320b57cec5SDimitry Andric    priority_queue& operator=(priority_queue&& __q)
5330b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
5340b57cec5SDimitry Andric                   is_nothrow_move_assignable<value_compare>::value)
5350b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
5360b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5370b57cec5SDimitry Andric
5380b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5390b57cec5SDimitry Andric    explicit priority_queue(const value_compare& __comp)
5400b57cec5SDimitry Andric        : c(), comp(__comp) {}
5410b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5420b57cec5SDimitry Andric    priority_queue(const value_compare& __comp, const container_type& __c);
5430b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
545e8d8bef9SDimitry Andric    priority_queue(const value_compare& __comp, container_type&& __c);
5460b57cec5SDimitry Andric#endif
547349cc55cSDimitry Andric    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5480b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5490b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
5500b57cec5SDimitry Andric                       const value_compare& __comp = value_compare());
551349cc55cSDimitry Andric    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5520b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5530b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
5540b57cec5SDimitry Andric                       const value_compare& __comp, const container_type& __c);
5550b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
556349cc55cSDimitry Andric    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5570b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5580b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
5590b57cec5SDimitry Andric                       const value_compare& __comp, container_type&& __c);
5600b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5610b57cec5SDimitry Andric    template <class _Alloc>
5620b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5630b57cec5SDimitry Andric        explicit priority_queue(const _Alloc& __a,
564349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5650b57cec5SDimitry Andric    template <class _Alloc>
5660b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5670b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const _Alloc& __a,
568349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5690b57cec5SDimitry Andric    template <class _Alloc>
5700b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5710b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const container_type& __c,
5720b57cec5SDimitry Andric                       const _Alloc& __a,
573349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5740b57cec5SDimitry Andric    template <class _Alloc>
5750b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5760b57cec5SDimitry Andric        priority_queue(const priority_queue& __q, const _Alloc& __a,
577349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5780b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5790b57cec5SDimitry Andric    template <class _Alloc>
5800b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5810b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, container_type&& __c,
5820b57cec5SDimitry Andric                       const _Alloc& __a,
583349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5840b57cec5SDimitry Andric    template <class _Alloc>
5850b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5860b57cec5SDimitry Andric        priority_queue(priority_queue&& __q, const _Alloc& __a,
587349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
588349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
589349cc55cSDimitry Andric
590349cc55cSDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
591349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
592349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a,
593349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
594349cc55cSDimitry Andric
595349cc55cSDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
596349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
597349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
598349cc55cSDimitry Andric                       const value_compare& __comp, const _Alloc& __a,
599349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
600349cc55cSDimitry Andric
601349cc55cSDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
602349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
603349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
604349cc55cSDimitry Andric                       const value_compare& __comp, const container_type& __c, const _Alloc& __a,
605349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
606349cc55cSDimitry Andric
607349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
608349cc55cSDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
609349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
610349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
611349cc55cSDimitry Andric                       const value_compare& __comp, container_type&& __c, const _Alloc& __a,
612349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6130b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
6140b57cec5SDimitry Andric
6150b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
6160b57cec5SDimitry Andric    bool            empty() const {return c.empty();}
6170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6180b57cec5SDimitry Andric    size_type       size() const  {return c.size();}
6190b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6200b57cec5SDimitry Andric    const_reference top() const   {return c.front();}
6210b57cec5SDimitry Andric
6220b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6230b57cec5SDimitry Andric    void push(const value_type& __v);
6240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6260b57cec5SDimitry Andric    void push(value_type&& __v);
6270b57cec5SDimitry Andric    template <class... _Args>
6280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6290b57cec5SDimitry Andric    void emplace(_Args&&... __args);
6300b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6320b57cec5SDimitry Andric    void pop();
6330b57cec5SDimitry Andric
6340b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6350b57cec5SDimitry Andric    void swap(priority_queue& __q)
6360b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
6370b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value);
638bdd1243dSDimitry Andric
639bdd1243dSDimitry Andric    _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
6400b57cec5SDimitry Andric};
6410b57cec5SDimitry Andric
642349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
6430b57cec5SDimitry Andrictemplate <class _Compare,
6440b57cec5SDimitry Andric          class _Container,
645349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
646349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>
6470b57cec5SDimitry Andric>
6480b57cec5SDimitry Andricpriority_queue(_Compare, _Container)
6490b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6500b57cec5SDimitry Andric
6510b57cec5SDimitry Andrictemplate<class _InputIterator,
652fe6060f1SDimitry Andric         class _Compare = less<__iter_value_type<_InputIterator>>,
653fe6060f1SDimitry Andric         class _Container = vector<__iter_value_type<_InputIterator>>,
654349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
655349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
656349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>
6570b57cec5SDimitry Andric>
6580b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
659fe6060f1SDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
6600b57cec5SDimitry Andric
6610b57cec5SDimitry Andrictemplate<class _Compare,
6620b57cec5SDimitry Andric         class _Container,
6630b57cec5SDimitry Andric         class _Alloc,
664349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
665349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
666349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
6670b57cec5SDimitry Andric>
6680b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc)
6690b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
670349cc55cSDimitry Andric
671349cc55cSDimitry Andrictemplate<class _InputIterator, class _Allocator,
672349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
673349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>
674349cc55cSDimitry Andric>
675349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator)
676349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
677349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
678349cc55cSDimitry Andric                      less<__iter_value_type<_InputIterator>>>;
679349cc55cSDimitry Andric
680349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Allocator,
681349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
682349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
683349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>
684349cc55cSDimitry Andric>
685349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
686349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
687349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>;
688349cc55cSDimitry Andric
689349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Container, class _Alloc,
690349cc55cSDimitry Andric         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
691349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
692349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
693349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
694349cc55cSDimitry Andric>
695349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
696349cc55cSDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6970b57cec5SDimitry Andric#endif
6980b57cec5SDimitry Andric
6990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7000b57cec5SDimitry Andricinline
7010b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
7020b57cec5SDimitry Andric                                                          const container_type& __c)
7030b57cec5SDimitry Andric    : c(__c),
7040b57cec5SDimitry Andric      comp(__comp)
7050b57cec5SDimitry Andric{
7060b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7070b57cec5SDimitry Andric}
7080b57cec5SDimitry Andric
7090b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7100b57cec5SDimitry Andric
7110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7120b57cec5SDimitry Andricinline
7130b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7140b57cec5SDimitry Andric                                                          container_type&& __c)
7150b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
7160b57cec5SDimitry Andric      comp(__comp)
7170b57cec5SDimitry Andric{
7180b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7190b57cec5SDimitry Andric}
7200b57cec5SDimitry Andric
7210b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7220b57cec5SDimitry Andric
7230b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
724349cc55cSDimitry Andrictemplate <class _InputIter, class>
7250b57cec5SDimitry Andricinline
7260b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7270b57cec5SDimitry Andric                                                          const value_compare& __comp)
7280b57cec5SDimitry Andric    : c(__f, __l),
7290b57cec5SDimitry Andric      comp(__comp)
7300b57cec5SDimitry Andric{
7310b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7320b57cec5SDimitry Andric}
7330b57cec5SDimitry Andric
7340b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
735349cc55cSDimitry Andrictemplate <class _InputIter, class>
7360b57cec5SDimitry Andricinline
7370b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7380b57cec5SDimitry Andric                                                          const value_compare& __comp,
7390b57cec5SDimitry Andric                                                          const container_type& __c)
7400b57cec5SDimitry Andric    : c(__c),
7410b57cec5SDimitry Andric      comp(__comp)
7420b57cec5SDimitry Andric{
7430b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
7440b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7450b57cec5SDimitry Andric}
7460b57cec5SDimitry Andric
7470b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7480b57cec5SDimitry Andric
7490b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
750349cc55cSDimitry Andrictemplate <class _InputIter, class>
7510b57cec5SDimitry Andricinline
7520b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7530b57cec5SDimitry Andric                                                          const value_compare& __comp,
7540b57cec5SDimitry Andric                                                          container_type&& __c)
7550b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
7560b57cec5SDimitry Andric      comp(__comp)
7570b57cec5SDimitry Andric{
7580b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
7590b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7600b57cec5SDimitry Andric}
7610b57cec5SDimitry Andric
7620b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7630b57cec5SDimitry Andric
7640b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7650b57cec5SDimitry Andrictemplate <class _Alloc>
7660b57cec5SDimitry Andricinline
7670b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
768349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7690b57cec5SDimitry Andric    : c(__a)
7700b57cec5SDimitry Andric{
7710b57cec5SDimitry Andric}
7720b57cec5SDimitry Andric
7730b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7740b57cec5SDimitry Andrictemplate <class _Alloc>
7750b57cec5SDimitry Andricinline
7760b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7770b57cec5SDimitry Andric                                                          const _Alloc& __a,
778349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7790b57cec5SDimitry Andric    : c(__a),
7800b57cec5SDimitry Andric      comp(__comp)
7810b57cec5SDimitry Andric{
7820b57cec5SDimitry Andric}
7830b57cec5SDimitry Andric
7840b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7850b57cec5SDimitry Andrictemplate <class _Alloc>
7860b57cec5SDimitry Andricinline
7870b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7880b57cec5SDimitry Andric                                                          const container_type& __c,
7890b57cec5SDimitry Andric                                                          const _Alloc& __a,
790349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7910b57cec5SDimitry Andric    : c(__c, __a),
7920b57cec5SDimitry Andric      comp(__comp)
7930b57cec5SDimitry Andric{
7940b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7950b57cec5SDimitry Andric}
7960b57cec5SDimitry Andric
7970b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7980b57cec5SDimitry Andrictemplate <class _Alloc>
7990b57cec5SDimitry Andricinline
8000b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
8010b57cec5SDimitry Andric                                                          const _Alloc& __a,
802349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8030b57cec5SDimitry Andric    : c(__q.c, __a),
8040b57cec5SDimitry Andric      comp(__q.comp)
8050b57cec5SDimitry Andric{
8060b57cec5SDimitry Andric}
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8090b57cec5SDimitry Andric
8100b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8110b57cec5SDimitry Andrictemplate <class _Alloc>
8120b57cec5SDimitry Andricinline
8130b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
8140b57cec5SDimitry Andric                                                          container_type&& __c,
8150b57cec5SDimitry Andric                                                          const _Alloc& __a,
816349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8170b57cec5SDimitry Andric    : c(_VSTD::move(__c), __a),
8180b57cec5SDimitry Andric      comp(__comp)
8190b57cec5SDimitry Andric{
8200b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
8210b57cec5SDimitry Andric}
8220b57cec5SDimitry Andric
8230b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8240b57cec5SDimitry Andrictemplate <class _Alloc>
8250b57cec5SDimitry Andricinline
8260b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
8270b57cec5SDimitry Andric                                                          const _Alloc& __a,
828349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8290b57cec5SDimitry Andric    : c(_VSTD::move(__q.c), __a),
8300b57cec5SDimitry Andric      comp(_VSTD::move(__q.comp))
8310b57cec5SDimitry Andric{
832349cc55cSDimitry Andric}
833349cc55cSDimitry Andric
834349cc55cSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
835349cc55cSDimitry Andric
836349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
837349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
838349cc55cSDimitry Andricinline
839349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
840349cc55cSDimitry Andric        _InputIter __f, _InputIter __l, const _Alloc& __a,
841349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
842349cc55cSDimitry Andric    : c(__f, __l, __a),
843349cc55cSDimitry Andric      comp()
844349cc55cSDimitry Andric{
8450b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
8460b57cec5SDimitry Andric}
8470b57cec5SDimitry Andric
848349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
849349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
850349cc55cSDimitry Andricinline
851349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
852349cc55cSDimitry Andric        _InputIter __f, _InputIter __l,
853349cc55cSDimitry Andric        const value_compare& __comp, const _Alloc& __a,
854349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
855349cc55cSDimitry Andric    : c(__f, __l, __a),
856349cc55cSDimitry Andric      comp(__comp)
857349cc55cSDimitry Andric{
858349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
859349cc55cSDimitry Andric}
860349cc55cSDimitry Andric
861349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
862349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
863349cc55cSDimitry Andricinline
864349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
865349cc55cSDimitry Andric        _InputIter __f, _InputIter __l,
866349cc55cSDimitry Andric        const value_compare& __comp, const container_type& __c, const _Alloc& __a,
867349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
868349cc55cSDimitry Andric    : c(__c, __a),
869349cc55cSDimitry Andric      comp(__comp)
870349cc55cSDimitry Andric{
871349cc55cSDimitry Andric    c.insert(c.end(), __f, __l);
872349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
873349cc55cSDimitry Andric}
874349cc55cSDimitry Andric
875349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
876349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
877349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
878349cc55cSDimitry Andricinline
879349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
880349cc55cSDimitry Andric        _InputIter __f, _InputIter __l, const value_compare& __comp,
881349cc55cSDimitry Andric        container_type&& __c, const _Alloc& __a,
882349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
883349cc55cSDimitry Andric    : c(_VSTD::move(__c), __a),
884349cc55cSDimitry Andric      comp(__comp)
885349cc55cSDimitry Andric{
886349cc55cSDimitry Andric    c.insert(c.end(), __f, __l);
887349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
888349cc55cSDimitry Andric}
8890b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
8900b57cec5SDimitry Andric
8910b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8920b57cec5SDimitry Andricinline
8930b57cec5SDimitry Andricvoid
8940b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
8950b57cec5SDimitry Andric{
8960b57cec5SDimitry Andric    c.push_back(__v);
8970b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
8980b57cec5SDimitry Andric}
8990b57cec5SDimitry Andric
9000b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
9010b57cec5SDimitry Andric
9020b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9030b57cec5SDimitry Andricinline
9040b57cec5SDimitry Andricvoid
9050b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
9060b57cec5SDimitry Andric{
9070b57cec5SDimitry Andric    c.push_back(_VSTD::move(__v));
9080b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
9090b57cec5SDimitry Andric}
9100b57cec5SDimitry Andric
9110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9120b57cec5SDimitry Andrictemplate <class... _Args>
9130b57cec5SDimitry Andricinline
9140b57cec5SDimitry Andricvoid
9150b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
9160b57cec5SDimitry Andric{
9170b57cec5SDimitry Andric    c.emplace_back(_VSTD::forward<_Args>(__args)...);
9180b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
9190b57cec5SDimitry Andric}
9200b57cec5SDimitry Andric
9210b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
9220b57cec5SDimitry Andric
9230b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9240b57cec5SDimitry Andricinline
9250b57cec5SDimitry Andricvoid
9260b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop()
9270b57cec5SDimitry Andric{
9280b57cec5SDimitry Andric    _VSTD::pop_heap(c.begin(), c.end(), comp);
9290b57cec5SDimitry Andric    c.pop_back();
9300b57cec5SDimitry Andric}
9310b57cec5SDimitry Andric
9320b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9330b57cec5SDimitry Andricinline
9340b57cec5SDimitry Andricvoid
9350b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
9360b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
9370b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value)
9380b57cec5SDimitry Andric{
9390b57cec5SDimitry Andric    using _VSTD::swap;
9400b57cec5SDimitry Andric    swap(c, __q.c);
9410b57cec5SDimitry Andric    swap(comp, __q.comp);
9420b57cec5SDimitry Andric}
9430b57cec5SDimitry Andric
9440b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9450b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
946349cc55cSDimitry Andric__enable_if_t<
947fe6060f1SDimitry Andric    __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
9480b57cec5SDimitry Andric    void
949fe6060f1SDimitry Andric>
9500b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x,
9510b57cec5SDimitry Andric     priority_queue<_Tp, _Container, _Compare>& __y)
9520b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
9530b57cec5SDimitry Andric{
9540b57cec5SDimitry Andric    __x.swap(__y);
9550b57cec5SDimitry Andric}
9560b57cec5SDimitry Andric
9570b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
9580b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
9590b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
9600b57cec5SDimitry Andric{
9610b57cec5SDimitry Andric};
9620b57cec5SDimitry Andric
9630b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
9640b57cec5SDimitry Andric
965bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
966bdd1243dSDimitry Andric#  include <concepts>
967bdd1243dSDimitry Andric#  include <functional>
968bdd1243dSDimitry Andric#endif
969bdd1243dSDimitry Andric
9700b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE
971