xref: /freebsd/contrib/llvm-project/libcxx/include/queue (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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
46*06c3fb27SDimitry Andric    template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23
470b57cec5SDimitry Andric    template <class Alloc>
480b57cec5SDimitry Andric        explicit queue(const Alloc& a);
490b57cec5SDimitry Andric    template <class Alloc>
500b57cec5SDimitry Andric        queue(const container_type& c, const Alloc& a);
510b57cec5SDimitry Andric    template <class Alloc>
520b57cec5SDimitry Andric        queue(container_type&& c, const Alloc& a);
530b57cec5SDimitry Andric    template <class Alloc>
540b57cec5SDimitry Andric        queue(const queue& q, const Alloc& a);
550b57cec5SDimitry Andric    template <class Alloc>
560b57cec5SDimitry Andric        queue(queue&& q, const Alloc& a);
5704eeddc0SDimitry Andric    template <class InputIterator, class Alloc>
5804eeddc0SDimitry Andric        queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
59*06c3fb27SDimitry Andric    template<container-compatible-range<T> R, class Alloc>
60*06c3fb27SDimitry Andric        queue(from_range_t, R&& rg, const Alloc&); // since C++23
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric    bool      empty() const;
630b57cec5SDimitry Andric    size_type size() const;
640b57cec5SDimitry Andric
650b57cec5SDimitry Andric    reference       front();
660b57cec5SDimitry Andric    const_reference front() const;
670b57cec5SDimitry Andric    reference       back();
680b57cec5SDimitry Andric    const_reference back() const;
690b57cec5SDimitry Andric
700b57cec5SDimitry Andric    void push(const value_type& v);
710b57cec5SDimitry Andric    void push(value_type&& v);
72*06c3fb27SDimitry Andric    template<container-compatible-range<T> R>
73*06c3fb27SDimitry Andric      void push_range(R&& rg); // C++23
740b57cec5SDimitry Andric    template <class... Args> reference emplace(Args&&... args); // reference in C++17
750b57cec5SDimitry Andric    void pop();
760b57cec5SDimitry Andric
770b57cec5SDimitry Andric    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
780b57cec5SDimitry Andric};
790b57cec5SDimitry Andric
800b57cec5SDimitry Andrictemplate<class Container>
810b57cec5SDimitry Andric  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
820b57cec5SDimitry Andric
8304eeddc0SDimitry Andrictemplate<class InputIterator>
8404eeddc0SDimitry Andric  queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
8504eeddc0SDimitry Andric
86*06c3fb27SDimitry Andrictemplate<ranges::input_range R>
87*06c3fb27SDimitry Andric  queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23
88*06c3fb27SDimitry Andric
890b57cec5SDimitry Andrictemplate<class Container, class Allocator>
900b57cec5SDimitry Andric  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
910b57cec5SDimitry Andric
9204eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator>
9304eeddc0SDimitry Andric  queue(InputIterator, InputIterator, Allocator)
9404eeddc0SDimitry Andric  -> queue<iter-value-type<InputIterator>,
9504eeddc0SDimitry Andric           deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
9604eeddc0SDimitry Andric
97*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
98*06c3fb27SDimitry Andric    queue(from_range_t, R&&, Allocator)
99*06c3fb27SDimitry Andric      -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23
100*06c3fb27SDimitry 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  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andrictemplate <class T, class Container>
1110b57cec5SDimitry Andric  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
1120b57cec5SDimitry Andric
1130b57cec5SDimitry Andrictemplate <class T, class Container>
1140b57cec5SDimitry Andric  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
1150b57cec5SDimitry Andric
1160b57cec5SDimitry Andrictemplate <class T, class Container>
1170b57cec5SDimitry Andric  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
1180b57cec5SDimitry Andric
119*06c3fb27SDimitry Andrictemplate<class T, three_way_comparable Container>
120*06c3fb27SDimitry Andric  compare_three_way_result_t<Container>
121*06c3fb27SDimitry Andric    operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);  // since C++20
122*06c3fb27SDimitry Andric
1230b57cec5SDimitry Andrictemplate <class T, class Container>
1240b57cec5SDimitry Andric  void swap(queue<T, Container>& x, queue<T, Container>& y)
1250b57cec5SDimitry Andric  noexcept(noexcept(x.swap(y)));
1260b57cec5SDimitry Andric
1270b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>,
1280b57cec5SDimitry Andric          class Compare = less<typename Container::value_type>>
1290b57cec5SDimitry Andricclass priority_queue
1300b57cec5SDimitry Andric{
1310b57cec5SDimitry Andricpublic:
1320b57cec5SDimitry Andric    typedef Container                                container_type;
1330b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
1340b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
1350b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
1360b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
1370b57cec5SDimitry Andric
1380b57cec5SDimitry Andricprotected:
1390b57cec5SDimitry Andric    container_type c;
1400b57cec5SDimitry Andric    Compare comp;
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andricpublic:
143e8d8bef9SDimitry Andric    priority_queue() : priority_queue(Compare()) {} // C++20
144e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
145e8d8bef9SDimitry Andric    priority_queue(const Compare& x, const Container&);
146e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
147e8d8bef9SDimitry Andric    priority_queue(const Compare& x, Container&&); // C++20
1480b57cec5SDimitry Andric    template <class InputIterator>
1490b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
1500b57cec5SDimitry Andric                       const Compare& comp = Compare());
1510b57cec5SDimitry Andric    template <class InputIterator>
1520b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
153349cc55cSDimitry Andric                       const Compare& comp, const Container& c);
1540b57cec5SDimitry Andric    template <class InputIterator>
1550b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
156349cc55cSDimitry Andric                       const Compare& comp, Container&& c);
157*06c3fb27SDimitry Andric    template <container-compatible-range<T> R>
158*06c3fb27SDimitry Andric        priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23
1590b57cec5SDimitry Andric    template <class Alloc>
1600b57cec5SDimitry Andric        explicit priority_queue(const Alloc& a);
1610b57cec5SDimitry Andric    template <class Alloc>
1620b57cec5SDimitry Andric        priority_queue(const Compare& comp, const Alloc& a);
1630b57cec5SDimitry Andric    template <class Alloc>
164349cc55cSDimitry Andric        priority_queue(const Compare& comp, const Container& c,
1650b57cec5SDimitry Andric                       const Alloc& a);
1660b57cec5SDimitry Andric    template <class Alloc>
167349cc55cSDimitry Andric        priority_queue(const Compare& comp, Container&& c,
1680b57cec5SDimitry Andric                       const Alloc& a);
169349cc55cSDimitry Andric    template <class InputIterator>
170349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
171349cc55cSDimitry Andric                       const Alloc& a);
172349cc55cSDimitry Andric    template <class InputIterator>
173349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
174349cc55cSDimitry Andric                       const Compare& comp, const Alloc& a);
175349cc55cSDimitry Andric    template <class InputIterator>
176349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
177349cc55cSDimitry Andric                       const Compare& comp, const Container& c, const Alloc& a);
178349cc55cSDimitry Andric    template <class InputIterator>
179349cc55cSDimitry Andric        priority_queue(InputIterator first, InputIterator last,
180349cc55cSDimitry Andric                       const Compare& comp, Container&& c, const Alloc& a);
181*06c3fb27SDimitry Andric    template <container-compatible-range<T> R, class Alloc>
182*06c3fb27SDimitry Andric      priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23
183*06c3fb27SDimitry Andric    template <container-compatible-range<T> R, class Alloc>
184*06c3fb27SDimitry Andric      priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23
1850b57cec5SDimitry Andric    template <class Alloc>
1860b57cec5SDimitry Andric        priority_queue(const priority_queue& q, const Alloc& a);
1870b57cec5SDimitry Andric    template <class Alloc>
1880b57cec5SDimitry Andric        priority_queue(priority_queue&& q, const Alloc& a);
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andric    bool            empty() const;
1910b57cec5SDimitry Andric    size_type       size() const;
1920b57cec5SDimitry Andric    const_reference top() const;
1930b57cec5SDimitry Andric
1940b57cec5SDimitry Andric    void push(const value_type& v);
1950b57cec5SDimitry Andric    void push(value_type&& v);
196*06c3fb27SDimitry Andric    template<container-compatible-range<T> R>
197*06c3fb27SDimitry Andric      void push_range(R&& rg); // C++23
1980b57cec5SDimitry Andric    template <class... Args> void emplace(Args&&... args);
1990b57cec5SDimitry Andric    void pop();
2000b57cec5SDimitry Andric
2010b57cec5SDimitry Andric    void swap(priority_queue& q)
2020b57cec5SDimitry Andric        noexcept(is_nothrow_swappable_v<Container> &&
2030b57cec5SDimitry Andric                 is_nothrow_swappable_v<Comp>)
2040b57cec5SDimitry Andric};
2050b57cec5SDimitry Andric
2060b57cec5SDimitry Andrictemplate <class Compare, class Container>
2070b57cec5SDimitry Andricpriority_queue(Compare, Container)
2080b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
2090b57cec5SDimitry Andric
2100b57cec5SDimitry Andrictemplate<class InputIterator,
211349cc55cSDimitry Andric         class Compare = less<iter-value-type<InputIterator>>,
212349cc55cSDimitry Andric         class Container = vector<iter-value-type<InputIterator>>>
2130b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
214349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
2150b57cec5SDimitry Andric
216*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>>
217*06c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Compare = Compare())
218*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23
219*06c3fb27SDimitry Andric
2200b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator>
2210b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator)
2220b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
2230b57cec5SDimitry Andric
224349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator>
225349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator)
226349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
227349cc55cSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>,
228349cc55cSDimitry Andric                      less<iter-value-type<InputIterator>>>; // C++17
229349cc55cSDimitry Andric
230349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator>
231349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator)
232349cc55cSDimitry Andric    -> priority_queue<iter-value-type<InputIterator>,
233349cc55cSDimitry Andric                      vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
234349cc55cSDimitry Andric
235349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator>
236349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
237349cc55cSDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
238349cc55cSDimitry Andric
239*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare, class Allocator>
240*06c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Compare, Allocator)
241*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
242*06c3fb27SDimitry Andric                        Compare>; // C++23
243*06c3fb27SDimitry Andric
244*06c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
245*06c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Allocator)
246*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23
247*06c3fb27SDimitry Andric
2480b57cec5SDimitry Andrictemplate <class T, class Container, class Compare>
2490b57cec5SDimitry Andric  void swap(priority_queue<T, Container, Compare>& x,
2500b57cec5SDimitry Andric            priority_queue<T, Container, Compare>& y)
2510b57cec5SDimitry Andric            noexcept(noexcept(x.swap(y)));
2520b57cec5SDimitry Andric
2530b57cec5SDimitry Andric}  // std
2540b57cec5SDimitry Andric
2550b57cec5SDimitry Andric*/
2560b57cec5SDimitry Andric
25781ad6265SDimitry Andric#include <__algorithm/make_heap.h>
25881ad6265SDimitry Andric#include <__algorithm/pop_heap.h>
25981ad6265SDimitry Andric#include <__algorithm/push_heap.h>
260*06c3fb27SDimitry Andric#include <__algorithm/ranges_copy.h>
26181ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler
2620b57cec5SDimitry Andric#include <__config>
26381ad6265SDimitry Andric#include <__functional/operations.h>
264*06c3fb27SDimitry Andric#include <__iterator/back_insert_iterator.h>
26504eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
266fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
267*06c3fb27SDimitry Andric#include <__ranges/access.h>
268*06c3fb27SDimitry Andric#include <__ranges/concepts.h>
269*06c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
270*06c3fb27SDimitry Andric#include <__ranges/from_range.h>
271fe6060f1SDimitry Andric#include <__utility/forward.h>
272fe6060f1SDimitry Andric#include <deque>
273fe6060f1SDimitry Andric#include <vector>
27404eeddc0SDimitry Andric#include <version>
2750b57cec5SDimitry Andric
27681ad6265SDimitry Andric// standard-mandated includes
277bdd1243dSDimitry Andric
278bdd1243dSDimitry Andric// [queue.syn]
27981ad6265SDimitry Andric#include <compare>
28081ad6265SDimitry Andric#include <initializer_list>
28181ad6265SDimitry Andric
2820b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2830b57cec5SDimitry Andric#  pragma GCC system_header
2840b57cec5SDimitry Andric#endif
2850b57cec5SDimitry Andric
2860b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2870b57cec5SDimitry Andric
2880b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
2890b57cec5SDimitry Andric
2900b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2910b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2920b57cec5SDimitry Andricbool
2930b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2960b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2970b57cec5SDimitry Andricbool
2980b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2990b57cec5SDimitry Andric
3000b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
3010b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue
3020b57cec5SDimitry Andric{
3030b57cec5SDimitry Andricpublic:
3040b57cec5SDimitry Andric    typedef _Container                               container_type;
3050b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
3060b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
3070b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
3080b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
3090b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
3100b57cec5SDimitry Andric
3110b57cec5SDimitry Andricprotected:
3120b57cec5SDimitry Andric    container_type c;
3130b57cec5SDimitry Andric
3140b57cec5SDimitry Andricpublic:
3150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3160b57cec5SDimitry Andric    queue()
3170b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
3180b57cec5SDimitry Andric        : c() {}
3190b57cec5SDimitry Andric
3200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3210b57cec5SDimitry Andric    queue(const queue& __q) : c(__q.c) {}
3220b57cec5SDimitry Andric
323*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
32404eeddc0SDimitry Andric    template <class _InputIterator,
325*06c3fb27SDimitry Andric              class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
32604eeddc0SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
32704eeddc0SDimitry Andric    queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
32804eeddc0SDimitry Andric
329*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range>
330*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
331*06c3fb27SDimitry Andric    queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {}
332*06c3fb27SDimitry Andric
33304eeddc0SDimitry Andric    template <class _InputIterator,
33404eeddc0SDimitry Andric              class _Alloc,
335*06c3fb27SDimitry Andric              class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
33604eeddc0SDimitry Andric              class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
33704eeddc0SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
33804eeddc0SDimitry Andric    queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {}
339*06c3fb27SDimitry Andric
340*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range,
341*06c3fb27SDimitry Andric              class _Alloc,
342*06c3fb27SDimitry Andric              class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
343*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
344*06c3fb27SDimitry Andric    queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
345*06c3fb27SDimitry Andric      : c(from_range, std::forward<_Range>(__range), __alloc) {}
346*06c3fb27SDimitry Andric
34704eeddc0SDimitry Andric#endif
34804eeddc0SDimitry Andric
3490b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3500b57cec5SDimitry Andric    queue& operator=(const queue& __q) {c = __q.c; return *this;}
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3530b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3540b57cec5SDimitry Andric    queue(queue&& __q)
3550b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
3560b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)) {}
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3590b57cec5SDimitry Andric    queue& operator=(queue&& __q)
3600b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
3610b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); return *this;}
3620b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3630b57cec5SDimitry Andric
3640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3650b57cec5SDimitry Andric    explicit queue(const container_type& __c)  : c(__c) {}
3660b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3670b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3680b57cec5SDimitry Andric    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
3690b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3700b57cec5SDimitry Andric    template <class _Alloc>
3710b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3720b57cec5SDimitry Andric        explicit queue(const _Alloc& __a,
373349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3740b57cec5SDimitry Andric            : c(__a) {}
3750b57cec5SDimitry Andric    template <class _Alloc>
3760b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3770b57cec5SDimitry Andric        queue(const queue& __q, const _Alloc& __a,
378349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3790b57cec5SDimitry Andric            : c(__q.c, __a) {}
3800b57cec5SDimitry Andric    template <class _Alloc>
3810b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3820b57cec5SDimitry Andric        queue(const container_type& __c, const _Alloc& __a,
383349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3840b57cec5SDimitry Andric            : c(__c, __a) {}
3850b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3860b57cec5SDimitry Andric    template <class _Alloc>
3870b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3880b57cec5SDimitry Andric        queue(container_type&& __c, const _Alloc& __a,
389349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3900b57cec5SDimitry Andric            : c(_VSTD::move(__c), __a) {}
3910b57cec5SDimitry Andric    template <class _Alloc>
3920b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3930b57cec5SDimitry Andric        queue(queue&& __q, const _Alloc& __a,
394349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3950b57cec5SDimitry Andric            : c(_VSTD::move(__q.c), __a) {}
3960b57cec5SDimitry Andric
3970b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3980b57cec5SDimitry Andric
3990b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
4000b57cec5SDimitry Andric    bool      empty() const {return c.empty();}
4010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4020b57cec5SDimitry Andric    size_type size() const  {return c.size();}
4030b57cec5SDimitry Andric
4040b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4050b57cec5SDimitry Andric    reference       front()       {return c.front();}
4060b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4070b57cec5SDimitry Andric    const_reference front() const {return c.front();}
4080b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4090b57cec5SDimitry Andric    reference       back()        {return c.back();}
4100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4110b57cec5SDimitry Andric    const_reference back() const  {return c.back();}
4120b57cec5SDimitry Andric
4130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4140b57cec5SDimitry Andric    void push(const value_type& __v) {c.push_back(__v);}
4150b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4160b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4170b57cec5SDimitry Andric    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
418*06c3fb27SDimitry Andric
419*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
420*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range>
421*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
422*06c3fb27SDimitry Andric    void push_range(_Range&& __range) {
423*06c3fb27SDimitry Andric      if constexpr (requires (container_type& __c) {
424*06c3fb27SDimitry Andric        __c.append_range(std::forward<_Range>(__range));
425*06c3fb27SDimitry Andric      }) {
426*06c3fb27SDimitry Andric        c.append_range(std::forward<_Range>(__range));
427*06c3fb27SDimitry Andric      } else {
428*06c3fb27SDimitry Andric        ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
429*06c3fb27SDimitry Andric      }
430*06c3fb27SDimitry Andric    }
431*06c3fb27SDimitry Andric#endif
432*06c3fb27SDimitry Andric
4330b57cec5SDimitry Andric    template <class... _Args>
4340b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
435*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
4360b57cec5SDimitry Andric        decltype(auto) emplace(_Args&&... __args)
4370b57cec5SDimitry Andric            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
4380b57cec5SDimitry Andric#else
4390b57cec5SDimitry Andric        void     emplace(_Args&&... __args)
4400b57cec5SDimitry Andric            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
4410b57cec5SDimitry Andric#endif
4420b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
4430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4440b57cec5SDimitry Andric    void pop() {c.pop_front();}
4450b57cec5SDimitry Andric
4460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4470b57cec5SDimitry Andric    void swap(queue& __q)
4480b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
4490b57cec5SDimitry Andric    {
4500b57cec5SDimitry Andric        using _VSTD::swap;
4510b57cec5SDimitry Andric        swap(c, __q.c);
4520b57cec5SDimitry Andric    }
4530b57cec5SDimitry Andric
454bdd1243dSDimitry Andric    _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
455bdd1243dSDimitry Andric
456*06c3fb27SDimitry Andric    template <class _T1, class _OtherContainer>
4570b57cec5SDimitry Andric    friend
4580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4590b57cec5SDimitry Andric    bool
460*06c3fb27SDimitry Andric    operator==(const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y);
4610b57cec5SDimitry Andric
462*06c3fb27SDimitry Andric    template <class _T1, class _OtherContainer>
4630b57cec5SDimitry Andric    friend
4640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4650b57cec5SDimitry Andric    bool
466*06c3fb27SDimitry Andric    operator< (const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y);
4670b57cec5SDimitry Andric};
4680b57cec5SDimitry Andric
469*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
4700b57cec5SDimitry Andrictemplate<class _Container,
471349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>
4720b57cec5SDimitry Andric>
4730b57cec5SDimitry Andricqueue(_Container)
4740b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
4750b57cec5SDimitry Andric
4760b57cec5SDimitry Andrictemplate<class _Container,
4770b57cec5SDimitry Andric         class _Alloc,
478349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
479349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
4800b57cec5SDimitry Andric>
4810b57cec5SDimitry Andricqueue(_Container, _Alloc)
4820b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
4830b57cec5SDimitry Andric#endif
4840b57cec5SDimitry Andric
485*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
48604eeddc0SDimitry Andrictemplate <class _InputIterator,
487*06c3fb27SDimitry Andric          class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
48804eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator)
48904eeddc0SDimitry Andric    -> queue<__iter_value_type<_InputIterator>>;
49004eeddc0SDimitry Andric
491*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range>
492*06c3fb27SDimitry Andricqueue(from_range_t, _Range&&)
493*06c3fb27SDimitry Andric    -> queue<ranges::range_value_t<_Range>>;
494*06c3fb27SDimitry Andric
49504eeddc0SDimitry Andrictemplate <class _InputIterator,
49604eeddc0SDimitry Andric          class _Alloc,
497*06c3fb27SDimitry Andric          class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
49804eeddc0SDimitry Andric          class = __enable_if_t<__is_allocator<_Alloc>::value>>
49904eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc)
50004eeddc0SDimitry Andric    -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
501*06c3fb27SDimitry Andric
502*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
503*06c3fb27SDimitry Andric          class _Alloc,
504*06c3fb27SDimitry Andric          class = __enable_if_t<__is_allocator<_Alloc>::value>>
505*06c3fb27SDimitry Andricqueue(from_range_t, _Range&&, _Alloc)
506*06c3fb27SDimitry Andric    -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
50704eeddc0SDimitry Andric#endif
50804eeddc0SDimitry Andric
5090b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5100b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5110b57cec5SDimitry Andricbool
5120b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5130b57cec5SDimitry Andric{
5140b57cec5SDimitry Andric    return __x.c == __y.c;
5150b57cec5SDimitry Andric}
5160b57cec5SDimitry Andric
5170b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5180b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5190b57cec5SDimitry Andricbool
5200b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5210b57cec5SDimitry Andric{
5220b57cec5SDimitry Andric    return __x.c < __y.c;
5230b57cec5SDimitry Andric}
5240b57cec5SDimitry Andric
5250b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5260b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5270b57cec5SDimitry Andricbool
5280b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5290b57cec5SDimitry Andric{
5300b57cec5SDimitry Andric    return !(__x == __y);
5310b57cec5SDimitry Andric}
5320b57cec5SDimitry Andric
5330b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5340b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5350b57cec5SDimitry Andricbool
5360b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5370b57cec5SDimitry Andric{
5380b57cec5SDimitry Andric    return __y < __x;
5390b57cec5SDimitry Andric}
5400b57cec5SDimitry Andric
5410b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5420b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5430b57cec5SDimitry Andricbool
5440b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5450b57cec5SDimitry Andric{
5460b57cec5SDimitry Andric    return !(__x < __y);
5470b57cec5SDimitry Andric}
5480b57cec5SDimitry Andric
5490b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5500b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
5510b57cec5SDimitry Andricbool
5520b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
5530b57cec5SDimitry Andric{
5540b57cec5SDimitry Andric    return !(__y < __x);
5550b57cec5SDimitry Andric}
5560b57cec5SDimitry Andric
557*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
558*06c3fb27SDimitry Andric
559*06c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container>
560*06c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
561*06c3fb27SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
562*06c3fb27SDimitry Andric    // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors
563*06c3fb27SDimitry Andric    return __x.__get_container() <=> __y.__get_container();
564*06c3fb27SDimitry Andric}
565*06c3fb27SDimitry Andric
566*06c3fb27SDimitry Andric#endif
567*06c3fb27SDimitry Andric
5680b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
5690b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
570349cc55cSDimitry Andric__enable_if_t<__is_swappable<_Container>::value, void>
5710b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
5720b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
5730b57cec5SDimitry Andric{
5740b57cec5SDimitry Andric    __x.swap(__y);
5750b57cec5SDimitry Andric}
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
5780b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
5790b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
5800b57cec5SDimitry Andric{
5810b57cec5SDimitry Andric};
5820b57cec5SDimitry Andric
5830b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>,
5840b57cec5SDimitry Andric          class _Compare = less<typename _Container::value_type> >
5850b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue
5860b57cec5SDimitry Andric{
5870b57cec5SDimitry Andricpublic:
5880b57cec5SDimitry Andric    typedef _Container                               container_type;
5890b57cec5SDimitry Andric    typedef _Compare                                 value_compare;
5900b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
5910b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
5920b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
5930b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
5940b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
5950b57cec5SDimitry Andric
5960b57cec5SDimitry Andricprotected:
5970b57cec5SDimitry Andric    container_type c;
5980b57cec5SDimitry Andric    value_compare comp;
5990b57cec5SDimitry Andric
6000b57cec5SDimitry Andricpublic:
6010b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6020b57cec5SDimitry Andric    priority_queue()
6030b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
6040b57cec5SDimitry Andric                   is_nothrow_default_constructible<value_compare>::value)
6050b57cec5SDimitry Andric        : c(), comp() {}
6060b57cec5SDimitry Andric
6070b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6080b57cec5SDimitry Andric    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
6090b57cec5SDimitry Andric
6100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6110b57cec5SDimitry Andric    priority_queue& operator=(const priority_queue& __q)
6120b57cec5SDimitry Andric        {c = __q.c; comp = __q.comp; return *this;}
6130b57cec5SDimitry Andric
6140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6160b57cec5SDimitry Andric    priority_queue(priority_queue&& __q)
6170b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
6180b57cec5SDimitry Andric                   is_nothrow_move_constructible<value_compare>::value)
6190b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
6200b57cec5SDimitry Andric
6210b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6220b57cec5SDimitry Andric    priority_queue& operator=(priority_queue&& __q)
6230b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
6240b57cec5SDimitry Andric                   is_nothrow_move_assignable<value_compare>::value)
6250b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
6260b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6270b57cec5SDimitry Andric
6280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6290b57cec5SDimitry Andric    explicit priority_queue(const value_compare& __comp)
6300b57cec5SDimitry Andric        : c(), comp(__comp) {}
6310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
6320b57cec5SDimitry Andric    priority_queue(const value_compare& __comp, const container_type& __c);
6330b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6340b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
635e8d8bef9SDimitry Andric    priority_queue(const value_compare& __comp, container_type&& __c);
6360b57cec5SDimitry Andric#endif
637*06c3fb27SDimitry Andric    template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
6380b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6390b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
6400b57cec5SDimitry Andric                       const value_compare& __comp = value_compare());
641*06c3fb27SDimitry Andric    template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
6420b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6430b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
6440b57cec5SDimitry Andric                       const value_compare& __comp, const container_type& __c);
6450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
646*06c3fb27SDimitry Andric    template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
6470b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6480b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
6490b57cec5SDimitry Andric                       const value_compare& __comp, container_type&& __c);
6500b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
651*06c3fb27SDimitry Andric
652*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
653*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range>
654*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
655*06c3fb27SDimitry Andric    priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
656*06c3fb27SDimitry Andric    : c(from_range, std::forward<_Range>(__range)),
657*06c3fb27SDimitry Andric      comp(__comp) {
658*06c3fb27SDimitry Andric      std::make_heap(c.begin(), c.end(), comp);
659*06c3fb27SDimitry Andric    }
660*06c3fb27SDimitry Andric#endif
661*06c3fb27SDimitry Andric
6620b57cec5SDimitry Andric    template <class _Alloc>
6630b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6640b57cec5SDimitry Andric        explicit priority_queue(const _Alloc& __a,
665349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6660b57cec5SDimitry Andric    template <class _Alloc>
6670b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6680b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const _Alloc& __a,
669349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6700b57cec5SDimitry Andric    template <class _Alloc>
6710b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6720b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const container_type& __c,
6730b57cec5SDimitry Andric                       const _Alloc& __a,
674349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6750b57cec5SDimitry Andric    template <class _Alloc>
6760b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6770b57cec5SDimitry Andric        priority_queue(const priority_queue& __q, const _Alloc& __a,
678349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6790b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6800b57cec5SDimitry Andric    template <class _Alloc>
6810b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6820b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, container_type&& __c,
6830b57cec5SDimitry Andric                       const _Alloc& __a,
684349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6850b57cec5SDimitry Andric    template <class _Alloc>
6860b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
6870b57cec5SDimitry Andric        priority_queue(priority_queue&& __q, const _Alloc& __a,
688349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
689349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
690349cc55cSDimitry Andric
691*06c3fb27SDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
692349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
693349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a,
694349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
695349cc55cSDimitry Andric
696*06c3fb27SDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
697349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
698349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
699349cc55cSDimitry Andric                       const value_compare& __comp, const _Alloc& __a,
700349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
701349cc55cSDimitry Andric
702*06c3fb27SDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
703349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
704349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
705349cc55cSDimitry Andric                       const value_compare& __comp, const container_type& __c, const _Alloc& __a,
706349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
707349cc55cSDimitry Andric
708349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
709*06c3fb27SDimitry Andric    template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
710349cc55cSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
711349cc55cSDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
712349cc55cSDimitry Andric                       const value_compare& __comp, container_type&& __c, const _Alloc& __a,
713349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
7140b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
7150b57cec5SDimitry Andric
716*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
717*06c3fb27SDimitry Andric
718*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range,
719*06c3fb27SDimitry Andric              class _Alloc,
720*06c3fb27SDimitry Andric              class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
721*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
722*06c3fb27SDimitry Andric    priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)
723*06c3fb27SDimitry Andric    : c(from_range, std::forward<_Range>(__range), __a),
724*06c3fb27SDimitry Andric      comp(__comp) {
725*06c3fb27SDimitry Andric      std::make_heap(c.begin(), c.end(), comp);
726*06c3fb27SDimitry Andric    }
727*06c3fb27SDimitry Andric
728*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range,
729*06c3fb27SDimitry Andric              class _Alloc,
730*06c3fb27SDimitry Andric              class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
731*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
732*06c3fb27SDimitry Andric    priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)
733*06c3fb27SDimitry Andric    : c(from_range, std::forward<_Range>(__range), __a),
734*06c3fb27SDimitry Andric      comp() {
735*06c3fb27SDimitry Andric      std::make_heap(c.begin(), c.end(), comp);
736*06c3fb27SDimitry Andric    }
737*06c3fb27SDimitry Andric
738*06c3fb27SDimitry Andric#endif
739*06c3fb27SDimitry Andric
7400b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
7410b57cec5SDimitry Andric    bool            empty() const {return c.empty();}
7420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7430b57cec5SDimitry Andric    size_type       size() const  {return c.size();}
7440b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7450b57cec5SDimitry Andric    const_reference top() const   {return c.front();}
7460b57cec5SDimitry Andric
7470b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7480b57cec5SDimitry Andric    void push(const value_type& __v);
7490b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7510b57cec5SDimitry Andric    void push(value_type&& __v);
752*06c3fb27SDimitry Andric
753*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
754*06c3fb27SDimitry Andric    template <_ContainerCompatibleRange<_Tp> _Range>
755*06c3fb27SDimitry Andric    _LIBCPP_HIDE_FROM_ABI
756*06c3fb27SDimitry Andric    void push_range(_Range&& __range) {
757*06c3fb27SDimitry Andric      if constexpr (requires (container_type& __c) {
758*06c3fb27SDimitry Andric        __c.append_range(std::forward<_Range>(__range));
759*06c3fb27SDimitry Andric      }) {
760*06c3fb27SDimitry Andric        c.append_range(std::forward<_Range>(__range));
761*06c3fb27SDimitry Andric      } else {
762*06c3fb27SDimitry Andric        ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
763*06c3fb27SDimitry Andric      }
764*06c3fb27SDimitry Andric
765*06c3fb27SDimitry Andric      std::make_heap(c.begin(), c.end(), comp);
766*06c3fb27SDimitry Andric    }
767*06c3fb27SDimitry Andric#endif
768*06c3fb27SDimitry Andric
7690b57cec5SDimitry Andric    template <class... _Args>
7700b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7710b57cec5SDimitry Andric    void emplace(_Args&&... __args);
7720b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7730b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7740b57cec5SDimitry Andric    void pop();
7750b57cec5SDimitry Andric
7760b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
7770b57cec5SDimitry Andric    void swap(priority_queue& __q)
7780b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
7790b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value);
780bdd1243dSDimitry Andric
781bdd1243dSDimitry Andric    _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
7820b57cec5SDimitry Andric};
7830b57cec5SDimitry Andric
784349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
7850b57cec5SDimitry Andrictemplate <class _Compare,
7860b57cec5SDimitry Andric          class _Container,
787349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
788349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>
7890b57cec5SDimitry Andric>
7900b57cec5SDimitry Andricpriority_queue(_Compare, _Container)
7910b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
7920b57cec5SDimitry Andric
7930b57cec5SDimitry Andrictemplate<class _InputIterator,
794fe6060f1SDimitry Andric         class _Compare = less<__iter_value_type<_InputIterator>>,
795fe6060f1SDimitry Andric         class _Container = vector<__iter_value_type<_InputIterator>>,
796*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
797349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
798349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>
7990b57cec5SDimitry Andric>
8000b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
801fe6060f1SDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
8020b57cec5SDimitry Andric
8030b57cec5SDimitry Andrictemplate<class _Compare,
8040b57cec5SDimitry Andric         class _Container,
8050b57cec5SDimitry Andric         class _Alloc,
806349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
807349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
808349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
8090b57cec5SDimitry Andric>
8100b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc)
8110b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
812349cc55cSDimitry Andric
813349cc55cSDimitry Andrictemplate<class _InputIterator, class _Allocator,
814*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
815349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>
816349cc55cSDimitry Andric>
817349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator)
818349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
819349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
820349cc55cSDimitry Andric                      less<__iter_value_type<_InputIterator>>>;
821349cc55cSDimitry Andric
822349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Allocator,
823*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
824349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
825349cc55cSDimitry Andric         class = enable_if_t<__is_allocator<_Allocator>::value>
826349cc55cSDimitry Andric>
827349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
828349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
829349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>;
830349cc55cSDimitry Andric
831349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Container, class _Alloc,
832*06c3fb27SDimitry Andric         class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
833349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Compare>::value>,
834349cc55cSDimitry Andric         class = enable_if_t<!__is_allocator<_Container>::value>,
835349cc55cSDimitry Andric         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
836349cc55cSDimitry Andric>
837349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
838349cc55cSDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
8390b57cec5SDimitry Andric#endif
8400b57cec5SDimitry Andric
841*06c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
842*06c3fb27SDimitry Andric
843*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
844*06c3fb27SDimitry Andric          class _Compare = less<ranges::range_value_t<_Range>>,
845*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>>
846*06c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare())
847*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>;
848*06c3fb27SDimitry Andric
849*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
850*06c3fb27SDimitry Andric          class _Compare,
851*06c3fb27SDimitry Andric          class _Alloc,
852*06c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
853*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Alloc>::value>>
854*06c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc)
855*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>,
856*06c3fb27SDimitry Andric                        _Compare>;
857*06c3fb27SDimitry Andric
858*06c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
859*06c3fb27SDimitry Andric          class _Alloc,
860*06c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Alloc>::value>>
861*06c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc)
862*06c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
863*06c3fb27SDimitry Andric
864*06c3fb27SDimitry Andric#endif
865*06c3fb27SDimitry Andric
8660b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8670b57cec5SDimitry Andricinline
8680b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
8690b57cec5SDimitry Andric                                                          const container_type& __c)
8700b57cec5SDimitry Andric    : c(__c),
8710b57cec5SDimitry Andric      comp(__comp)
8720b57cec5SDimitry Andric{
8730b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
8740b57cec5SDimitry Andric}
8750b57cec5SDimitry Andric
8760b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8770b57cec5SDimitry Andric
8780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8790b57cec5SDimitry Andricinline
8800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
8810b57cec5SDimitry Andric                                                          container_type&& __c)
8820b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
8830b57cec5SDimitry Andric      comp(__comp)
8840b57cec5SDimitry Andric{
8850b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
8860b57cec5SDimitry Andric}
8870b57cec5SDimitry Andric
8880b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8890b57cec5SDimitry Andric
8900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
891349cc55cSDimitry Andrictemplate <class _InputIter, class>
8920b57cec5SDimitry Andricinline
8930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
8940b57cec5SDimitry Andric                                                          const value_compare& __comp)
8950b57cec5SDimitry Andric    : c(__f, __l),
8960b57cec5SDimitry Andric      comp(__comp)
8970b57cec5SDimitry Andric{
8980b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
8990b57cec5SDimitry Andric}
9000b57cec5SDimitry Andric
9010b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
902349cc55cSDimitry Andrictemplate <class _InputIter, class>
9030b57cec5SDimitry Andricinline
9040b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
9050b57cec5SDimitry Andric                                                          const value_compare& __comp,
9060b57cec5SDimitry Andric                                                          const container_type& __c)
9070b57cec5SDimitry Andric    : c(__c),
9080b57cec5SDimitry Andric      comp(__comp)
9090b57cec5SDimitry Andric{
9100b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
9110b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
9120b57cec5SDimitry Andric}
9130b57cec5SDimitry Andric
9140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
9150b57cec5SDimitry Andric
9160b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
917349cc55cSDimitry Andrictemplate <class _InputIter, class>
9180b57cec5SDimitry Andricinline
9190b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
9200b57cec5SDimitry Andric                                                          const value_compare& __comp,
9210b57cec5SDimitry Andric                                                          container_type&& __c)
9220b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
9230b57cec5SDimitry Andric      comp(__comp)
9240b57cec5SDimitry Andric{
9250b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
9260b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
9270b57cec5SDimitry Andric}
9280b57cec5SDimitry Andric
9290b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
9300b57cec5SDimitry Andric
9310b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9320b57cec5SDimitry Andrictemplate <class _Alloc>
9330b57cec5SDimitry Andricinline
9340b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
935349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9360b57cec5SDimitry Andric    : c(__a)
9370b57cec5SDimitry Andric{
9380b57cec5SDimitry Andric}
9390b57cec5SDimitry Andric
9400b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9410b57cec5SDimitry Andrictemplate <class _Alloc>
9420b57cec5SDimitry Andricinline
9430b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
9440b57cec5SDimitry Andric                                                          const _Alloc& __a,
945349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9460b57cec5SDimitry Andric    : c(__a),
9470b57cec5SDimitry Andric      comp(__comp)
9480b57cec5SDimitry Andric{
9490b57cec5SDimitry Andric}
9500b57cec5SDimitry Andric
9510b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9520b57cec5SDimitry Andrictemplate <class _Alloc>
9530b57cec5SDimitry Andricinline
9540b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
9550b57cec5SDimitry Andric                                                          const container_type& __c,
9560b57cec5SDimitry Andric                                                          const _Alloc& __a,
957349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9580b57cec5SDimitry Andric    : c(__c, __a),
9590b57cec5SDimitry Andric      comp(__comp)
9600b57cec5SDimitry Andric{
9610b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
9620b57cec5SDimitry Andric}
9630b57cec5SDimitry Andric
9640b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9650b57cec5SDimitry Andrictemplate <class _Alloc>
9660b57cec5SDimitry Andricinline
9670b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
9680b57cec5SDimitry Andric                                                          const _Alloc& __a,
969349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9700b57cec5SDimitry Andric    : c(__q.c, __a),
9710b57cec5SDimitry Andric      comp(__q.comp)
9720b57cec5SDimitry Andric{
9730b57cec5SDimitry Andric}
9740b57cec5SDimitry Andric
9750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
9760b57cec5SDimitry Andric
9770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9780b57cec5SDimitry Andrictemplate <class _Alloc>
9790b57cec5SDimitry Andricinline
9800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
9810b57cec5SDimitry Andric                                                          container_type&& __c,
9820b57cec5SDimitry Andric                                                          const _Alloc& __a,
983349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9840b57cec5SDimitry Andric    : c(_VSTD::move(__c), __a),
9850b57cec5SDimitry Andric      comp(__comp)
9860b57cec5SDimitry Andric{
9870b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
9880b57cec5SDimitry Andric}
9890b57cec5SDimitry Andric
9900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9910b57cec5SDimitry Andrictemplate <class _Alloc>
9920b57cec5SDimitry Andricinline
9930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
9940b57cec5SDimitry Andric                                                          const _Alloc& __a,
995349cc55cSDimitry Andric                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
9960b57cec5SDimitry Andric    : c(_VSTD::move(__q.c), __a),
9970b57cec5SDimitry Andric      comp(_VSTD::move(__q.comp))
9980b57cec5SDimitry Andric{
999349cc55cSDimitry Andric}
1000349cc55cSDimitry Andric
1001349cc55cSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
1002349cc55cSDimitry Andric
1003349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
1004349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
1005349cc55cSDimitry Andricinline
1006349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
1007349cc55cSDimitry Andric        _InputIter __f, _InputIter __l, const _Alloc& __a,
1008349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
1009349cc55cSDimitry Andric    : c(__f, __l, __a),
1010349cc55cSDimitry Andric      comp()
1011349cc55cSDimitry Andric{
10120b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
10130b57cec5SDimitry Andric}
10140b57cec5SDimitry Andric
1015349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
1016349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
1017349cc55cSDimitry Andricinline
1018349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
1019349cc55cSDimitry Andric        _InputIter __f, _InputIter __l,
1020349cc55cSDimitry Andric        const value_compare& __comp, const _Alloc& __a,
1021349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
1022349cc55cSDimitry Andric    : c(__f, __l, __a),
1023349cc55cSDimitry Andric      comp(__comp)
1024349cc55cSDimitry Andric{
1025349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
1026349cc55cSDimitry Andric}
1027349cc55cSDimitry Andric
1028349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
1029349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
1030349cc55cSDimitry Andricinline
1031349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
1032349cc55cSDimitry Andric        _InputIter __f, _InputIter __l,
1033349cc55cSDimitry Andric        const value_compare& __comp, const container_type& __c, const _Alloc& __a,
1034349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
1035349cc55cSDimitry Andric    : c(__c, __a),
1036349cc55cSDimitry Andric      comp(__comp)
1037349cc55cSDimitry Andric{
1038349cc55cSDimitry Andric    c.insert(c.end(), __f, __l);
1039349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
1040349cc55cSDimitry Andric}
1041349cc55cSDimitry Andric
1042349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1043349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
1044349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
1045349cc55cSDimitry Andricinline
1046349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(
1047349cc55cSDimitry Andric        _InputIter __f, _InputIter __l, const value_compare& __comp,
1048349cc55cSDimitry Andric        container_type&& __c, const _Alloc& __a,
1049349cc55cSDimitry Andric        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
1050349cc55cSDimitry Andric    : c(_VSTD::move(__c), __a),
1051349cc55cSDimitry Andric      comp(__comp)
1052349cc55cSDimitry Andric{
1053349cc55cSDimitry Andric    c.insert(c.end(), __f, __l);
1054349cc55cSDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
1055349cc55cSDimitry Andric}
10560b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
10570b57cec5SDimitry Andric
10580b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
10590b57cec5SDimitry Andricinline
10600b57cec5SDimitry Andricvoid
10610b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
10620b57cec5SDimitry Andric{
10630b57cec5SDimitry Andric    c.push_back(__v);
10640b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
10650b57cec5SDimitry Andric}
10660b57cec5SDimitry Andric
10670b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
10680b57cec5SDimitry Andric
10690b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
10700b57cec5SDimitry Andricinline
10710b57cec5SDimitry Andricvoid
10720b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
10730b57cec5SDimitry Andric{
10740b57cec5SDimitry Andric    c.push_back(_VSTD::move(__v));
10750b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
10760b57cec5SDimitry Andric}
10770b57cec5SDimitry Andric
10780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
10790b57cec5SDimitry Andrictemplate <class... _Args>
10800b57cec5SDimitry Andricinline
10810b57cec5SDimitry Andricvoid
10820b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
10830b57cec5SDimitry Andric{
10840b57cec5SDimitry Andric    c.emplace_back(_VSTD::forward<_Args>(__args)...);
10850b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
10860b57cec5SDimitry Andric}
10870b57cec5SDimitry Andric
10880b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
10890b57cec5SDimitry Andric
10900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
10910b57cec5SDimitry Andricinline
10920b57cec5SDimitry Andricvoid
10930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop()
10940b57cec5SDimitry Andric{
10950b57cec5SDimitry Andric    _VSTD::pop_heap(c.begin(), c.end(), comp);
10960b57cec5SDimitry Andric    c.pop_back();
10970b57cec5SDimitry Andric}
10980b57cec5SDimitry Andric
10990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
11000b57cec5SDimitry Andricinline
11010b57cec5SDimitry Andricvoid
11020b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
11030b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
11040b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value)
11050b57cec5SDimitry Andric{
11060b57cec5SDimitry Andric    using _VSTD::swap;
11070b57cec5SDimitry Andric    swap(c, __q.c);
11080b57cec5SDimitry Andric    swap(comp, __q.comp);
11090b57cec5SDimitry Andric}
11100b57cec5SDimitry Andric
11110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
11120b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
1113349cc55cSDimitry Andric__enable_if_t<
1114fe6060f1SDimitry Andric    __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
11150b57cec5SDimitry Andric    void
1116fe6060f1SDimitry Andric>
11170b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x,
11180b57cec5SDimitry Andric     priority_queue<_Tp, _Container, _Compare>& __y)
11190b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
11200b57cec5SDimitry Andric{
11210b57cec5SDimitry Andric    __x.swap(__y);
11220b57cec5SDimitry Andric}
11230b57cec5SDimitry Andric
11240b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
11250b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
11260b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
11270b57cec5SDimitry Andric{
11280b57cec5SDimitry Andric};
11290b57cec5SDimitry Andric
11300b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
11310b57cec5SDimitry Andric
1132bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1133bdd1243dSDimitry Andric#  include <concepts>
1134*06c3fb27SDimitry Andric#  include <cstdlib>
1135bdd1243dSDimitry Andric#  include <functional>
1136*06c3fb27SDimitry Andric#  include <type_traits>
1137bdd1243dSDimitry Andric#endif
1138bdd1243dSDimitry Andric
11390b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE
1140