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
4606c3fb27SDimitry 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
5906c3fb27SDimitry Andric    template<container-compatible-range<T> R, class Alloc>
6006c3fb27SDimitry 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);
7206c3fb27SDimitry Andric    template<container-compatible-range<T> R>
7306c3fb27SDimitry 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
8606c3fb27SDimitry Andrictemplate<ranges::input_range R>
8706c3fb27SDimitry Andric  queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23
8806c3fb27SDimitry 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
9706c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
9806c3fb27SDimitry Andric    queue(from_range_t, R&&, Allocator)
9906c3fb27SDimitry Andric      -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23
10006c3fb27SDimitry 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
11906c3fb27SDimitry Andrictemplate<class T, three_way_comparable Container>
12006c3fb27SDimitry Andric  compare_three_way_result_t<Container>
12106c3fb27SDimitry Andric    operator<=>(const queue<T, Container>& x, const queue<T, Container>& y);  // since C++20
12206c3fb27SDimitry 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);
15706c3fb27SDimitry Andric    template <container-compatible-range<T> R>
15806c3fb27SDimitry 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);
18106c3fb27SDimitry Andric    template <container-compatible-range<T> R, class Alloc>
18206c3fb27SDimitry Andric      priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23
18306c3fb27SDimitry Andric    template <container-compatible-range<T> R, class Alloc>
18406c3fb27SDimitry 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);
19606c3fb27SDimitry Andric    template<container-compatible-range<T> R>
19706c3fb27SDimitry 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
21606c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>>
21706c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Compare = Compare())
21806c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23
21906c3fb27SDimitry 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
23906c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare, class Allocator>
24006c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Compare, Allocator)
24106c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
24206c3fb27SDimitry Andric                        Compare>; // C++23
24306c3fb27SDimitry Andric
24406c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator>
24506c3fb27SDimitry Andric  priority_queue(from_range_t, R&&, Allocator)
24606c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23
24706c3fb27SDimitry 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>
26006c3fb27SDimitry 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>
26406c3fb27SDimitry Andric#include <__iterator/back_insert_iterator.h>
26504eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
266fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
26706c3fb27SDimitry Andric#include <__ranges/access.h>
26806c3fb27SDimitry Andric#include <__ranges/concepts.h>
26906c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
27006c3fb27SDimitry 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
288cb14a3feSDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> >
289cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue;
2900b57cec5SDimitry Andric
2910b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
292cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
295cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
2960b57cec5SDimitry Andric
2970b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
298cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue {
2990b57cec5SDimitry Andricpublic:
3000b57cec5SDimitry Andric  typedef _Container container_type;
3010b57cec5SDimitry Andric  typedef typename container_type::value_type value_type;
3020b57cec5SDimitry Andric  typedef typename container_type::reference reference;
3030b57cec5SDimitry Andric  typedef typename container_type::const_reference const_reference;
3040b57cec5SDimitry Andric  typedef typename container_type::size_type size_type;
3050b57cec5SDimitry Andric  static_assert((is_same<_Tp, value_type>::value), "");
3060b57cec5SDimitry Andric
3070b57cec5SDimitry Andricprotected:
3080b57cec5SDimitry Andric  container_type c;
3090b57cec5SDimitry Andric
3100b57cec5SDimitry Andricpublic:
311cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {}
3120b57cec5SDimitry Andric
313cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
3140b57cec5SDimitry Andric
31506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
316cb14a3feSDimitry Andric  template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
317cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
31804eeddc0SDimitry Andric
31906c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
320cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {}
32106c3fb27SDimitry Andric
32204eeddc0SDimitry Andric  template <class _InputIterator,
32304eeddc0SDimitry Andric            class _Alloc,
32406c3fb27SDimitry Andric            class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
32504eeddc0SDimitry Andric            class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
326cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc)
327cb14a3feSDimitry Andric      : c(__first, __second, __alloc) {}
32806c3fb27SDimitry Andric
32906c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
33006c3fb27SDimitry Andric            class _Alloc,
33106c3fb27SDimitry Andric            class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
332cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
33306c3fb27SDimitry Andric      : c(from_range, std::forward<_Range>(__range), __alloc) {}
33406c3fb27SDimitry Andric
33504eeddc0SDimitry Andric#endif
33604eeddc0SDimitry Andric
337cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {
338cb14a3feSDimitry Andric    c = __q.c;
339cb14a3feSDimitry Andric    return *this;
340cb14a3feSDimitry Andric  }
3410b57cec5SDimitry Andric
3420b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
343cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
3445f757f3fSDimitry Andric      : c(std::move(__q.c)) {}
3450b57cec5SDimitry Andric
346cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) {
347cb14a3feSDimitry Andric    c = std::move(__q.c);
348cb14a3feSDimitry Andric    return *this;
349cb14a3feSDimitry Andric  }
3500b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3510b57cec5SDimitry Andric
352cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}
3530b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
354cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}
3550b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3560b57cec5SDimitry Andric  template <class _Alloc>
357cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a,
358349cc55cSDimitry Andric                                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3590b57cec5SDimitry Andric      : c(__a) {}
3600b57cec5SDimitry Andric  template <class _Alloc>
3615f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
362cb14a3feSDimitry Andric  queue(const queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3630b57cec5SDimitry Andric      : c(__q.c, __a) {}
3640b57cec5SDimitry Andric  template <class _Alloc>
3655f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
366cb14a3feSDimitry Andric  queue(const container_type& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3670b57cec5SDimitry Andric      : c(__c, __a) {}
3680b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3690b57cec5SDimitry Andric  template <class _Alloc>
3705f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
371cb14a3feSDimitry Andric  queue(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3725f757f3fSDimitry Andric      : c(std::move(__c), __a) {}
3730b57cec5SDimitry Andric  template <class _Alloc>
3745f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
375cb14a3feSDimitry Andric  queue(queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3765f757f3fSDimitry Andric      : c(std::move(__q.c), __a) {}
3770b57cec5SDimitry Andric
3780b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3790b57cec5SDimitry Andric
380cb14a3feSDimitry Andric  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
381cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
3820b57cec5SDimitry Andric
383cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
384cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); }
385cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); }
386cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }
3870b57cec5SDimitry Andric
388cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
3890b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
390cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }
39106c3fb27SDimitry Andric
39206c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
39306c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
394cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
395cb14a3feSDimitry Andric    if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
39606c3fb27SDimitry Andric      c.append_range(std::forward<_Range>(__range));
39706c3fb27SDimitry Andric    } else {
39806c3fb27SDimitry Andric      ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
39906c3fb27SDimitry Andric    }
40006c3fb27SDimitry Andric  }
40106c3fb27SDimitry Andric#  endif
40206c3fb27SDimitry Andric
4030b57cec5SDimitry Andric  template <class... _Args>
4045f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
40506c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 17
406cb14a3feSDimitry Andric      decltype(auto)
407cb14a3feSDimitry Andric      emplace(_Args&&... __args) {
408cb14a3feSDimitry Andric    return c.emplace_back(std::forward<_Args>(__args)...);
409cb14a3feSDimitry Andric  }
4100b57cec5SDimitry Andric#  else
411cb14a3feSDimitry Andric      void
412cb14a3feSDimitry Andric      emplace(_Args&&... __args) {
413cb14a3feSDimitry Andric    c.emplace_back(std::forward<_Args>(__args)...);
414cb14a3feSDimitry Andric  }
4150b57cec5SDimitry Andric#  endif
4160b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
417cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
4180b57cec5SDimitry Andric
419cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) {
4205f757f3fSDimitry Andric    using std::swap;
4210b57cec5SDimitry Andric    swap(c, __q.c);
4220b57cec5SDimitry Andric  }
4230b57cec5SDimitry Andric
424bdd1243dSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
425bdd1243dSDimitry Andric
42606c3fb27SDimitry Andric  template <class _T1, class _OtherContainer>
427cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
42806c3fb27SDimitry Andric  operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
4290b57cec5SDimitry Andric
43006c3fb27SDimitry Andric  template <class _T1, class _OtherContainer>
431cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
43206c3fb27SDimitry Andric  operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
4330b57cec5SDimitry Andric};
4340b57cec5SDimitry Andric
43506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
436cb14a3feSDimitry Andrictemplate <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >
437cb14a3feSDimitry Andricqueue(_Container) -> queue<typename _Container::value_type, _Container>;
4380b57cec5SDimitry Andric
4390b57cec5SDimitry Andrictemplate <class _Container,
4400b57cec5SDimitry Andric          class _Alloc,
441349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
442cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
443cb14a3feSDimitry Andricqueue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
4440b57cec5SDimitry Andric#endif
4450b57cec5SDimitry Andric
44606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
447cb14a3feSDimitry Andrictemplate <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
448cb14a3feSDimitry Andricqueue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;
44904eeddc0SDimitry Andric
45006c3fb27SDimitry Andrictemplate <ranges::input_range _Range>
451cb14a3feSDimitry Andricqueue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>;
45206c3fb27SDimitry Andric
45304eeddc0SDimitry Andrictemplate <class _InputIterator,
45404eeddc0SDimitry Andric          class _Alloc,
45506c3fb27SDimitry Andric          class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
45604eeddc0SDimitry Andric          class = __enable_if_t<__is_allocator<_Alloc>::value>>
45704eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc)
45804eeddc0SDimitry Andric    -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
45906c3fb27SDimitry Andric
460cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>>
46106c3fb27SDimitry Andricqueue(from_range_t, _Range&&, _Alloc)
46206c3fb27SDimitry Andric    -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
46304eeddc0SDimitry Andric#endif
46404eeddc0SDimitry Andric
4650b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
466cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4670b57cec5SDimitry Andric  return __x.c == __y.c;
4680b57cec5SDimitry Andric}
4690b57cec5SDimitry Andric
4700b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
471cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4720b57cec5SDimitry Andric  return __x.c < __y.c;
4730b57cec5SDimitry Andric}
4740b57cec5SDimitry Andric
4750b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
476cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4770b57cec5SDimitry Andric  return !(__x == __y);
4780b57cec5SDimitry Andric}
4790b57cec5SDimitry Andric
4800b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
481cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4820b57cec5SDimitry Andric  return __y < __x;
4830b57cec5SDimitry Andric}
4840b57cec5SDimitry Andric
4850b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
486cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4870b57cec5SDimitry Andric  return !(__x < __y);
4880b57cec5SDimitry Andric}
4890b57cec5SDimitry Andric
4900b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
491cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4920b57cec5SDimitry Andric  return !(__y < __x);
4930b57cec5SDimitry Andric}
4940b57cec5SDimitry Andric
49506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
49606c3fb27SDimitry Andric
49706c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container>
49806c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
49906c3fb27SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
50006c3fb27SDimitry Andric  // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors
50106c3fb27SDimitry Andric  return __x.__get_container() <=> __y.__get_container();
50206c3fb27SDimitry Andric}
50306c3fb27SDimitry Andric
50406c3fb27SDimitry Andric#endif
50506c3fb27SDimitry Andric
5065f757f3fSDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
507cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
508cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
5090b57cec5SDimitry Andric  __x.swap(__y);
5100b57cec5SDimitry Andric}
5110b57cec5SDimitry Andric
5120b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
513cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {
5140b57cec5SDimitry Andric};
5150b57cec5SDimitry Andric
516cb14a3feSDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> >
517cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue {
5180b57cec5SDimitry Andricpublic:
5190b57cec5SDimitry Andric  typedef _Container container_type;
5200b57cec5SDimitry Andric  typedef _Compare value_compare;
5210b57cec5SDimitry Andric  typedef typename container_type::value_type value_type;
5220b57cec5SDimitry Andric  typedef typename container_type::reference reference;
5230b57cec5SDimitry Andric  typedef typename container_type::const_reference const_reference;
5240b57cec5SDimitry Andric  typedef typename container_type::size_type size_type;
5250b57cec5SDimitry Andric  static_assert((is_same<_Tp, value_type>::value), "");
5260b57cec5SDimitry Andric
5270b57cec5SDimitry Andricprotected:
5280b57cec5SDimitry Andric  container_type c;
5290b57cec5SDimitry Andric  value_compare comp;
5300b57cec5SDimitry Andric
5310b57cec5SDimitry Andricpublic:
532cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_(
533cb14a3feSDimitry Andric      is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value)
5340b57cec5SDimitry Andric      : c(), comp() {}
5350b57cec5SDimitry Andric
536cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
5370b57cec5SDimitry Andric
538cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {
539cb14a3feSDimitry Andric    c    = __q.c;
540cb14a3feSDimitry Andric    comp = __q.comp;
541cb14a3feSDimitry Andric    return *this;
542cb14a3feSDimitry Andric  }
5430b57cec5SDimitry Andric
5440b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
545cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_(
546cb14a3feSDimitry Andric      is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value)
5475f757f3fSDimitry Andric      : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
5480b57cec5SDimitry Andric
549cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q)
550cb14a3feSDimitry Andric      _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) {
551cb14a3feSDimitry Andric    c    = std::move(__q.c);
552cb14a3feSDimitry Andric    comp = std::move(__q.comp);
553cb14a3feSDimitry Andric    return *this;
554cb14a3feSDimitry Andric  }
5550b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5560b57cec5SDimitry Andric
557cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}
558cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);
5590b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
560cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
5610b57cec5SDimitry Andric#endif
56206c3fb27SDimitry Andric  template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
563cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
56406c3fb27SDimitry Andric  template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
5655f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
566cb14a3feSDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
5670b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
56806c3fb27SDimitry Andric  template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
5695f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
570cb14a3feSDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
5710b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
57206c3fb27SDimitry Andric
57306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
57406c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
575cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
576cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range)), comp(__comp) {
57706c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
57806c3fb27SDimitry Andric  }
57906c3fb27SDimitry Andric#endif
58006c3fb27SDimitry Andric
5810b57cec5SDimitry Andric  template <class _Alloc>
582cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a,
583349cc55cSDimitry Andric                                                __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5840b57cec5SDimitry Andric  template <class _Alloc>
5855f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
586cb14a3feSDimitry Andric  priority_queue(const value_compare& __comp,
5870b57cec5SDimitry Andric                 const _Alloc& __a,
588349cc55cSDimitry Andric                 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5890b57cec5SDimitry Andric  template <class _Alloc>
5905f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
591cb14a3feSDimitry Andric  priority_queue(const value_compare& __comp,
592cb14a3feSDimitry Andric                 const container_type& __c,
593cb14a3feSDimitry Andric                 const _Alloc& __a,
594349cc55cSDimitry Andric                 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
595cb14a3feSDimitry Andric  template <class _Alloc>
596cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
597cb14a3feSDimitry Andric      const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5980b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5990b57cec5SDimitry Andric  template <class _Alloc>
6005f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
601cb14a3feSDimitry Andric  priority_queue(const value_compare& __comp,
602cb14a3feSDimitry Andric                 container_type&& __c,
6030b57cec5SDimitry Andric                 const _Alloc& __a,
604349cc55cSDimitry Andric                 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6050b57cec5SDimitry Andric  template <class _Alloc>
606cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
607cb14a3feSDimitry Andric      priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
608349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
609349cc55cSDimitry Andric
61006c3fb27SDimitry Andric  template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
6115f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
612cb14a3feSDimitry Andric  priority_queue(_InputIter __f,
613cb14a3feSDimitry Andric                 _InputIter __l,
614cb14a3feSDimitry Andric                 const _Alloc& __a,
615349cc55cSDimitry Andric                 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
616349cc55cSDimitry Andric
61706c3fb27SDimitry Andric  template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
618cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
619cb14a3feSDimitry Andric      _InputIter __f,
620cb14a3feSDimitry Andric      _InputIter __l,
621cb14a3feSDimitry Andric      const value_compare& __comp,
622cb14a3feSDimitry Andric      const _Alloc& __a,
623349cc55cSDimitry Andric      __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
624349cc55cSDimitry Andric
62506c3fb27SDimitry Andric  template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
626cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
627cb14a3feSDimitry Andric      _InputIter __f,
628cb14a3feSDimitry Andric      _InputIter __l,
629cb14a3feSDimitry Andric      const value_compare& __comp,
630cb14a3feSDimitry Andric      const container_type& __c,
631cb14a3feSDimitry Andric      const _Alloc& __a,
632349cc55cSDimitry Andric      __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
633349cc55cSDimitry Andric
634349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
63506c3fb27SDimitry Andric  template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
636cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
637cb14a3feSDimitry Andric      _InputIter __f,
638cb14a3feSDimitry Andric      _InputIter __l,
639cb14a3feSDimitry Andric      const value_compare& __comp,
640cb14a3feSDimitry Andric      container_type&& __c,
641cb14a3feSDimitry Andric      const _Alloc& __a,
642349cc55cSDimitry Andric      __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6430b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6440b57cec5SDimitry Andric
64506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
64606c3fb27SDimitry Andric
64706c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
64806c3fb27SDimitry Andric            class _Alloc,
64906c3fb27SDimitry Andric            class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
650cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)
651cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) {
65206c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
65306c3fb27SDimitry Andric  }
65406c3fb27SDimitry Andric
65506c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
65606c3fb27SDimitry Andric            class _Alloc,
65706c3fb27SDimitry Andric            class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
658cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)
659cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range), __a), comp() {
66006c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
66106c3fb27SDimitry Andric  }
66206c3fb27SDimitry Andric
66306c3fb27SDimitry Andric#endif
66406c3fb27SDimitry Andric
665cb14a3feSDimitry Andric  _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
666cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
667cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
6680b57cec5SDimitry Andric
669cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
6700b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
671cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);
67206c3fb27SDimitry Andric
67306c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
67406c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
675cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
676cb14a3feSDimitry Andric    if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
67706c3fb27SDimitry Andric      c.append_range(std::forward<_Range>(__range));
67806c3fb27SDimitry Andric    } else {
67906c3fb27SDimitry Andric      ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
68006c3fb27SDimitry Andric    }
68106c3fb27SDimitry Andric
68206c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
68306c3fb27SDimitry Andric  }
68406c3fb27SDimitry Andric#  endif
68506c3fb27SDimitry Andric
6860b57cec5SDimitry Andric  template <class... _Args>
687cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);
6880b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
689cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop();
6900b57cec5SDimitry Andric
691cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
692cb14a3feSDimitry Andric      _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value);
693bdd1243dSDimitry Andric
694bdd1243dSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
6950b57cec5SDimitry Andric};
6960b57cec5SDimitry Andric
697349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
6980b57cec5SDimitry Andrictemplate <class _Compare,
6990b57cec5SDimitry Andric          class _Container,
700349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
701cb14a3feSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value> >
702cb14a3feSDimitry Andricpriority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
7030b57cec5SDimitry Andric
7040b57cec5SDimitry Andrictemplate <class _InputIterator,
705fe6060f1SDimitry Andric          class _Compare   = less<__iter_value_type<_InputIterator>>,
706fe6060f1SDimitry Andric          class _Container = vector<__iter_value_type<_InputIterator>>,
70706c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
708349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Compare>::value>,
709cb14a3feSDimitry Andric          class            = enable_if_t<!__is_allocator<_Container>::value> >
7100b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
711fe6060f1SDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
7120b57cec5SDimitry Andric
7130b57cec5SDimitry Andrictemplate <class _Compare,
7140b57cec5SDimitry Andric          class _Container,
7150b57cec5SDimitry Andric          class _Alloc,
716349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
717349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
718cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
719cb14a3feSDimitry Andricpriority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
720349cc55cSDimitry Andric
721cb14a3feSDimitry Andrictemplate <class _InputIterator,
722cb14a3feSDimitry Andric          class _Allocator,
72306c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
724cb14a3feSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value> >
725349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator)
726349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
727349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
728349cc55cSDimitry Andric                      less<__iter_value_type<_InputIterator>>>;
729349cc55cSDimitry Andric
730cb14a3feSDimitry Andrictemplate <class _InputIterator,
731cb14a3feSDimitry Andric          class _Compare,
732cb14a3feSDimitry Andric          class _Allocator,
73306c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
734349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
735cb14a3feSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value> >
736349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
737349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
738cb14a3feSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
739cb14a3feSDimitry Andric                      _Compare>;
740349cc55cSDimitry Andric
741cb14a3feSDimitry Andrictemplate <class _InputIterator,
742cb14a3feSDimitry Andric          class _Compare,
743cb14a3feSDimitry Andric          class _Container,
744cb14a3feSDimitry Andric          class _Alloc,
74506c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
746349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
747349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
748cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
749349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
750349cc55cSDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
7510b57cec5SDimitry Andric#endif
7520b57cec5SDimitry Andric
75306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
75406c3fb27SDimitry Andric
75506c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
75606c3fb27SDimitry Andric          class _Compare = less<ranges::range_value_t<_Range>>,
75706c3fb27SDimitry Andric          class          = enable_if_t<!__is_allocator<_Compare>::value>>
75806c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare())
75906c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>;
76006c3fb27SDimitry Andric
76106c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
76206c3fb27SDimitry Andric          class _Compare,
76306c3fb27SDimitry Andric          class _Alloc,
76406c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
76506c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Alloc>::value>>
76606c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc)
767cb14a3feSDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>;
76806c3fb27SDimitry Andric
769cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>>
77006c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc)
77106c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
77206c3fb27SDimitry Andric
77306c3fb27SDimitry Andric#endif
77406c3fb27SDimitry Andric
7750b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
776cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)
777cb14a3feSDimitry Andric    : c(__c), comp(__comp) {
7785f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7790b57cec5SDimitry Andric}
7800b57cec5SDimitry Andric
7810b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7820b57cec5SDimitry Andric
7830b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
784cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)
785cb14a3feSDimitry Andric    : c(std::move(__c)), comp(__comp) {
7865f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7870b57cec5SDimitry Andric}
7880b57cec5SDimitry Andric
7890b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7900b57cec5SDimitry Andric
7910b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
792349cc55cSDimitry Andrictemplate <class _InputIter, class>
793cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
794cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp)
795cb14a3feSDimitry Andric    : c(__f, __l), comp(__comp) {
7965f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7970b57cec5SDimitry Andric}
7980b57cec5SDimitry Andric
7990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
800349cc55cSDimitry Andrictemplate <class _InputIter, class>
801cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
802cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
803cb14a3feSDimitry Andric    : c(__c), comp(__comp) {
8040b57cec5SDimitry Andric  c.insert(c.end(), __f, __l);
8055f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8060b57cec5SDimitry Andric}
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8090b57cec5SDimitry Andric
8100b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
811349cc55cSDimitry Andrictemplate <class _InputIter, class>
812cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
813cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)
814cb14a3feSDimitry Andric    : c(std::move(__c)), comp(__comp) {
8150b57cec5SDimitry Andric  c.insert(c.end(), __f, __l);
8165f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8170b57cec5SDimitry Andric}
8180b57cec5SDimitry Andric
8190b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8200b57cec5SDimitry Andric
8210b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8220b57cec5SDimitry Andrictemplate <class _Alloc>
823cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
824cb14a3feSDimitry Andric    const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
825cb14a3feSDimitry Andric    : c(__a) {}
8260b57cec5SDimitry Andric
8270b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8280b57cec5SDimitry Andrictemplate <class _Alloc>
829cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
830cb14a3feSDimitry Andric    const value_compare& __comp, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
831cb14a3feSDimitry Andric    : c(__a), comp(__comp) {}
8320b57cec5SDimitry Andric
8330b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8340b57cec5SDimitry Andrictemplate <class _Alloc>
835cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
836cb14a3feSDimitry Andric    const value_compare& __comp,
8370b57cec5SDimitry Andric    const container_type& __c,
8380b57cec5SDimitry Andric    const _Alloc& __a,
839349cc55cSDimitry Andric    __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
840cb14a3feSDimitry Andric    : c(__c, __a), comp(__comp) {
8415f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8420b57cec5SDimitry Andric}
8430b57cec5SDimitry Andric
8440b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8450b57cec5SDimitry Andrictemplate <class _Alloc>
846cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
847cb14a3feSDimitry Andric    const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
848cb14a3feSDimitry Andric    : c(__q.c, __a), comp(__q.comp) {}
8490b57cec5SDimitry Andric
8500b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8510b57cec5SDimitry Andric
8520b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8530b57cec5SDimitry Andrictemplate <class _Alloc>
854cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
855cb14a3feSDimitry Andric    const value_compare& __comp,
8560b57cec5SDimitry Andric    container_type&& __c,
8570b57cec5SDimitry Andric    const _Alloc& __a,
858349cc55cSDimitry Andric    __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
859cb14a3feSDimitry Andric    : c(std::move(__c), __a), comp(__comp) {
8605f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8610b57cec5SDimitry Andric}
8620b57cec5SDimitry Andric
8630b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
8640b57cec5SDimitry Andrictemplate <class _Alloc>
865cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
866cb14a3feSDimitry Andric    priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
867cb14a3feSDimitry Andric    : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
868349cc55cSDimitry Andric
869349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
870349cc55cSDimitry Andric
871349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
872349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
873cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
874cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
875cb14a3feSDimitry Andric    : c(__f, __l, __a), comp() {
8765f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8770b57cec5SDimitry Andric}
8780b57cec5SDimitry Andric
879349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
880349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
881cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
882cb14a3feSDimitry Andric    _InputIter __f,
883cb14a3feSDimitry Andric    _InputIter __l,
884cb14a3feSDimitry Andric    const value_compare& __comp,
885cb14a3feSDimitry Andric    const _Alloc& __a,
886349cc55cSDimitry Andric    __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
887cb14a3feSDimitry Andric    : c(__f, __l, __a), comp(__comp) {
8885f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
889349cc55cSDimitry Andric}
890349cc55cSDimitry Andric
891349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
892349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
893cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
894cb14a3feSDimitry Andric    _InputIter __f,
895cb14a3feSDimitry Andric    _InputIter __l,
896cb14a3feSDimitry Andric    const value_compare& __comp,
897cb14a3feSDimitry Andric    const container_type& __c,
898cb14a3feSDimitry Andric    const _Alloc& __a,
899349cc55cSDimitry Andric    __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
900cb14a3feSDimitry Andric    : c(__c, __a), comp(__comp) {
901349cc55cSDimitry Andric  c.insert(c.end(), __f, __l);
9025f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
903349cc55cSDimitry Andric}
904349cc55cSDimitry Andric
905349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
906349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
907349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class>
908cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
909cb14a3feSDimitry Andric    _InputIter __f,
910cb14a3feSDimitry Andric    _InputIter __l,
911cb14a3feSDimitry Andric    const value_compare& __comp,
912cb14a3feSDimitry Andric    container_type&& __c,
913cb14a3feSDimitry Andric    const _Alloc& __a,
914349cc55cSDimitry Andric    __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
915cb14a3feSDimitry Andric    : c(std::move(__c), __a), comp(__comp) {
916349cc55cSDimitry Andric  c.insert(c.end(), __f, __l);
9175f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
918349cc55cSDimitry Andric}
9190b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
9200b57cec5SDimitry Andric
9210b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
922cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
9230b57cec5SDimitry Andric  c.push_back(__v);
9245f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
9250b57cec5SDimitry Andric}
9260b57cec5SDimitry Andric
9270b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
9280b57cec5SDimitry Andric
9290b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
930cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {
9315f757f3fSDimitry Andric  c.push_back(std::move(__v));
9325f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
9330b57cec5SDimitry Andric}
9340b57cec5SDimitry Andric
9350b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9360b57cec5SDimitry Andrictemplate <class... _Args>
937cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) {
9385f757f3fSDimitry Andric  c.emplace_back(std::forward<_Args>(__args)...);
9395f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
9400b57cec5SDimitry Andric}
9410b57cec5SDimitry Andric
9420b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
9430b57cec5SDimitry Andric
9440b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
945cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::pop() {
9465f757f3fSDimitry Andric  std::pop_heap(c.begin(), c.end(), comp);
9470b57cec5SDimitry Andric  c.pop_back();
9480b57cec5SDimitry Andric}
9490b57cec5SDimitry Andric
9500b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
951cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
952cb14a3feSDimitry Andric    _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) {
9535f757f3fSDimitry Andric  using std::swap;
9540b57cec5SDimitry Andric  swap(c, __q.c);
9550b57cec5SDimitry Andric  swap(comp, __q.comp);
9560b57cec5SDimitry Andric}
9570b57cec5SDimitry Andric
958cb14a3feSDimitry Andrictemplate <class _Tp,
959cb14a3feSDimitry Andric          class _Container,
960cb14a3feSDimitry Andric          class _Compare,
9615f757f3fSDimitry Andric          __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0>
962cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
963cb14a3feSDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)
964cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
9650b57cec5SDimitry Andric  __x.swap(__y);
9660b57cec5SDimitry Andric}
9670b57cec5SDimitry Andric
9680b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
9690b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
970cb14a3feSDimitry Andric    : public uses_allocator<_Container, _Alloc> {};
9710b57cec5SDimitry Andric
9720b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
9730b57cec5SDimitry Andric
974bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
975bdd1243dSDimitry Andric#  include <concepts>
97606c3fb27SDimitry Andric#  include <cstdlib>
977bdd1243dSDimitry Andric#  include <functional>
97806c3fb27SDimitry Andric#  include <type_traits>
979bdd1243dSDimitry Andric#endif
980bdd1243dSDimitry Andric
9810b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE
982