xref: /freebsd/contrib/llvm-project/libcxx/include/queue (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
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>
2610b57cec5SDimitry Andric#include <__config>
26281ad6265SDimitry Andric#include <__functional/operations.h>
263*0fca6ea1SDimitry Andric#include <__fwd/deque.h>
264*0fca6ea1SDimitry Andric#include <__fwd/queue.h>
26506c3fb27SDimitry Andric#include <__iterator/back_insert_iterator.h>
26604eeddc0SDimitry Andric#include <__iterator/iterator_traits.h>
267fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
26806c3fb27SDimitry Andric#include <__ranges/access.h>
26906c3fb27SDimitry Andric#include <__ranges/concepts.h>
27006c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h>
27106c3fb27SDimitry Andric#include <__ranges/from_range.h>
272fe6060f1SDimitry Andric#include <__utility/forward.h>
273fe6060f1SDimitry Andric#include <deque>
274fe6060f1SDimitry Andric#include <vector>
27504eeddc0SDimitry Andric#include <version>
2760b57cec5SDimitry Andric
27781ad6265SDimitry Andric// standard-mandated includes
278bdd1243dSDimitry Andric
279bdd1243dSDimitry Andric// [queue.syn]
28081ad6265SDimitry Andric#include <compare>
28181ad6265SDimitry Andric#include <initializer_list>
28281ad6265SDimitry Andric
2830b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2840b57cec5SDimitry Andric#  pragma GCC system_header
2850b57cec5SDimitry Andric#endif
2860b57cec5SDimitry Andric
287b3edf446SDimitry Andric_LIBCPP_PUSH_MACROS
288b3edf446SDimitry Andric#include <__undef_macros>
289b3edf446SDimitry Andric
2900b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
2910b57cec5SDimitry Andric
2920b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
293cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
296cb14a3feSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
2970b57cec5SDimitry Andric
2980b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
299cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue {
3000b57cec5SDimitry Andricpublic:
3010b57cec5SDimitry Andric  typedef _Container container_type;
3020b57cec5SDimitry Andric  typedef typename container_type::value_type value_type;
3030b57cec5SDimitry Andric  typedef typename container_type::reference reference;
3040b57cec5SDimitry Andric  typedef typename container_type::const_reference const_reference;
3050b57cec5SDimitry Andric  typedef typename container_type::size_type size_type;
306*0fca6ea1SDimitry Andric  static_assert(is_same<_Tp, value_type>::value, "");
3070b57cec5SDimitry Andric
3080b57cec5SDimitry Andricprotected:
3090b57cec5SDimitry Andric  container_type c;
3100b57cec5SDimitry Andric
3110b57cec5SDimitry Andricpublic:
312cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {}
3130b57cec5SDimitry Andric
314cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
3150b57cec5SDimitry Andric
31606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
317*0fca6ea1SDimitry Andric  template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
318cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
31904eeddc0SDimitry Andric
32006c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
321cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {}
32206c3fb27SDimitry Andric
32304eeddc0SDimitry Andric  template <class _InputIterator,
32404eeddc0SDimitry Andric            class _Alloc,
325*0fca6ea1SDimitry Andric            __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
326*0fca6ea1SDimitry Andric            __enable_if_t<uses_allocator<container_type, _Alloc>::value, int>        = 0>
327cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc)
328cb14a3feSDimitry Andric      : c(__first, __second, __alloc) {}
32906c3fb27SDimitry Andric
33006c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
33106c3fb27SDimitry Andric            class _Alloc,
332*0fca6ea1SDimitry Andric            __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
333cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
33406c3fb27SDimitry Andric      : c(from_range, std::forward<_Range>(__range), __alloc) {}
33506c3fb27SDimitry Andric
33604eeddc0SDimitry Andric#endif
33704eeddc0SDimitry Andric
338cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) {
339cb14a3feSDimitry Andric    c = __q.c;
340cb14a3feSDimitry Andric    return *this;
341cb14a3feSDimitry Andric  }
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
344*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)
3455f757f3fSDimitry Andric      : c(std::move(__q.c)) {}
3460b57cec5SDimitry Andric
347*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) {
348cb14a3feSDimitry Andric    c = std::move(__q.c);
349cb14a3feSDimitry Andric    return *this;
350cb14a3feSDimitry Andric  }
3510b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3520b57cec5SDimitry Andric
353cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {}
3540b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
355cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}
3560b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3570b57cec5SDimitry Andric
358*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
359*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}
360*0fca6ea1SDimitry Andric
361*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
362*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {}
363*0fca6ea1SDimitry Andric
364*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
365*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}
366*0fca6ea1SDimitry Andric
367*0fca6ea1SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
368*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
369*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {}
370*0fca6ea1SDimitry Andric
371*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
372*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {}
3730b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3740b57cec5SDimitry Andric
375*0fca6ea1SDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
376cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
3770b57cec5SDimitry Andric
378cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
379cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); }
380cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); }
381cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); }
3820b57cec5SDimitry Andric
383cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); }
3840b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
385cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); }
38606c3fb27SDimitry Andric
38706c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
38806c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
389cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
390cb14a3feSDimitry Andric    if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
39106c3fb27SDimitry Andric      c.append_range(std::forward<_Range>(__range));
39206c3fb27SDimitry Andric    } else {
39306c3fb27SDimitry Andric      ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
39406c3fb27SDimitry Andric    }
39506c3fb27SDimitry Andric  }
39606c3fb27SDimitry Andric#  endif
39706c3fb27SDimitry Andric
3980b57cec5SDimitry Andric  template <class... _Args>
3995f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
40006c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 17
401cb14a3feSDimitry Andric  decltype(auto)
402cb14a3feSDimitry Andric  emplace(_Args&&... __args) {
403cb14a3feSDimitry Andric    return c.emplace_back(std::forward<_Args>(__args)...);
404cb14a3feSDimitry Andric  }
4050b57cec5SDimitry Andric#  else
406cb14a3feSDimitry Andric  void
407cb14a3feSDimitry Andric  emplace(_Args&&... __args) {
408cb14a3feSDimitry Andric    c.emplace_back(std::forward<_Args>(__args)...);
409cb14a3feSDimitry Andric  }
4100b57cec5SDimitry Andric#  endif
4110b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
412cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
4130b57cec5SDimitry Andric
414*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) {
4155f757f3fSDimitry Andric    using std::swap;
4160b57cec5SDimitry Andric    swap(c, __q.c);
4170b57cec5SDimitry Andric  }
4180b57cec5SDimitry Andric
419bdd1243dSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
420bdd1243dSDimitry Andric
42106c3fb27SDimitry Andric  template <class _T1, class _OtherContainer>
422cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
42306c3fb27SDimitry Andric  operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
4240b57cec5SDimitry Andric
42506c3fb27SDimitry Andric  template <class _T1, class _OtherContainer>
426cb14a3feSDimitry Andric  friend _LIBCPP_HIDE_FROM_ABI bool
42706c3fb27SDimitry Andric  operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
4280b57cec5SDimitry Andric};
4290b57cec5SDimitry Andric
43006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17
431cb14a3feSDimitry Andrictemplate <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> >
432cb14a3feSDimitry Andricqueue(_Container) -> queue<typename _Container::value_type, _Container>;
4330b57cec5SDimitry Andric
4340b57cec5SDimitry Andrictemplate <class _Container,
4350b57cec5SDimitry Andric          class _Alloc,
436349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
437cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
438cb14a3feSDimitry Andricqueue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
4390b57cec5SDimitry Andric#endif
4400b57cec5SDimitry Andric
44106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
442*0fca6ea1SDimitry Andrictemplate <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
443cb14a3feSDimitry Andricqueue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;
44404eeddc0SDimitry Andric
44506c3fb27SDimitry Andrictemplate <ranges::input_range _Range>
446cb14a3feSDimitry Andricqueue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>;
44706c3fb27SDimitry Andric
44804eeddc0SDimitry Andrictemplate <class _InputIterator,
44904eeddc0SDimitry Andric          class _Alloc,
450*0fca6ea1SDimitry Andric          __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
451*0fca6ea1SDimitry Andric          __enable_if_t<__is_allocator<_Alloc>::value, int>                        = 0>
452*0fca6ea1SDimitry Andricqueue(_InputIterator,
453*0fca6ea1SDimitry Andric      _InputIterator,
454*0fca6ea1SDimitry Andric      _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
45506c3fb27SDimitry Andric
456*0fca6ea1SDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
457*0fca6ea1SDimitry Andricqueue(from_range_t,
458*0fca6ea1SDimitry Andric      _Range&&,
459*0fca6ea1SDimitry Andric      _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
46004eeddc0SDimitry Andric#endif
46104eeddc0SDimitry Andric
4620b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
463cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4640b57cec5SDimitry Andric  return __x.c == __y.c;
4650b57cec5SDimitry Andric}
4660b57cec5SDimitry Andric
4670b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
468cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4690b57cec5SDimitry Andric  return __x.c < __y.c;
4700b57cec5SDimitry Andric}
4710b57cec5SDimitry Andric
4720b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
473cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4740b57cec5SDimitry Andric  return !(__x == __y);
4750b57cec5SDimitry Andric}
4760b57cec5SDimitry Andric
4770b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
478cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4790b57cec5SDimitry Andric  return __y < __x;
4800b57cec5SDimitry Andric}
4810b57cec5SDimitry Andric
4820b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
483cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4840b57cec5SDimitry Andric  return !(__x < __y);
4850b57cec5SDimitry Andric}
4860b57cec5SDimitry Andric
4870b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
488cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
4890b57cec5SDimitry Andric  return !(__y < __x);
4900b57cec5SDimitry Andric}
4910b57cec5SDimitry Andric
49206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20
49306c3fb27SDimitry Andric
49406c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container>
49506c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
49606c3fb27SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
49706c3fb27SDimitry Andric  // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors
49806c3fb27SDimitry Andric  return __x.__get_container() <=> __y.__get_container();
49906c3fb27SDimitry Andric}
50006c3fb27SDimitry Andric
50106c3fb27SDimitry Andric#endif
50206c3fb27SDimitry Andric
503*0fca6ea1SDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
504cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
505cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
5060b57cec5SDimitry Andric  __x.swap(__y);
5070b57cec5SDimitry Andric}
5080b57cec5SDimitry Andric
5090b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
510cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {
5110b57cec5SDimitry Andric};
5120b57cec5SDimitry Andric
513*0fca6ea1SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
514cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue {
5150b57cec5SDimitry Andricpublic:
5160b57cec5SDimitry Andric  typedef _Container container_type;
5170b57cec5SDimitry Andric  typedef _Compare value_compare;
5180b57cec5SDimitry Andric  typedef typename container_type::value_type value_type;
5190b57cec5SDimitry Andric  typedef typename container_type::reference reference;
5200b57cec5SDimitry Andric  typedef typename container_type::const_reference const_reference;
5210b57cec5SDimitry Andric  typedef typename container_type::size_type size_type;
522*0fca6ea1SDimitry Andric  static_assert(is_same<_Tp, value_type>::value, "");
5230b57cec5SDimitry Andric
5240b57cec5SDimitry Andricprotected:
5250b57cec5SDimitry Andric  container_type c;
5260b57cec5SDimitry Andric  value_compare comp;
5270b57cec5SDimitry Andric
5280b57cec5SDimitry Andricpublic:
529cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_(
530cb14a3feSDimitry Andric      is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value)
5310b57cec5SDimitry Andric      : c(), comp() {}
5320b57cec5SDimitry Andric
533cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
5340b57cec5SDimitry Andric
535cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {
536cb14a3feSDimitry Andric    c    = __q.c;
537cb14a3feSDimitry Andric    comp = __q.comp;
538cb14a3feSDimitry Andric    return *this;
539cb14a3feSDimitry Andric  }
5400b57cec5SDimitry Andric
5410b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
542*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(
543cb14a3feSDimitry Andric      is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)
5445f757f3fSDimitry Andric      : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
5450b57cec5SDimitry Andric
546*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept(
547*0fca6ea1SDimitry Andric      is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) {
548cb14a3feSDimitry Andric    c    = std::move(__q.c);
549cb14a3feSDimitry Andric    comp = std::move(__q.comp);
550cb14a3feSDimitry Andric    return *this;
551cb14a3feSDimitry Andric  }
5520b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5530b57cec5SDimitry Andric
554cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}
555cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);
5560b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
557cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
5580b57cec5SDimitry Andric#endif
559*0fca6ea1SDimitry Andric  template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
560cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
561*0fca6ea1SDimitry Andric
562*0fca6ea1SDimitry Andric  template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
5635f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
564cb14a3feSDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
565*0fca6ea1SDimitry Andric
5660b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
567*0fca6ea1SDimitry Andric  template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
5685f757f3fSDimitry Andric  _LIBCPP_HIDE_FROM_ABI
569cb14a3feSDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
5700b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
57106c3fb27SDimitry Andric
57206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
57306c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
574cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
575cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range)), comp(__comp) {
57606c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
57706c3fb27SDimitry Andric  }
57806c3fb27SDimitry Andric#endif
57906c3fb27SDimitry Andric
580*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
581*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
582*0fca6ea1SDimitry Andric
583*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
584*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);
585*0fca6ea1SDimitry Andric
586*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
587*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);
588*0fca6ea1SDimitry Andric
589*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
590*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
591*0fca6ea1SDimitry Andric
5920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
593*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
594*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);
595*0fca6ea1SDimitry Andric
596*0fca6ea1SDimitry Andric  template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
597*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);
598349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
599349cc55cSDimitry Andric
600*0fca6ea1SDimitry Andric  template <
601*0fca6ea1SDimitry Andric      class _InputIter,
602*0fca6ea1SDimitry Andric      class _Alloc,
603*0fca6ea1SDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
604*0fca6ea1SDimitry Andric                    int> = 0>
605*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);
606349cc55cSDimitry Andric
607*0fca6ea1SDimitry Andric  template <
608*0fca6ea1SDimitry Andric      class _InputIter,
609*0fca6ea1SDimitry Andric      class _Alloc,
610*0fca6ea1SDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
611*0fca6ea1SDimitry Andric                    int> = 0>
612*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);
613349cc55cSDimitry Andric
614*0fca6ea1SDimitry Andric  template <
615*0fca6ea1SDimitry Andric      class _InputIter,
616*0fca6ea1SDimitry Andric      class _Alloc,
617*0fca6ea1SDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
618*0fca6ea1SDimitry Andric                    int> = 0>
619cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(
620*0fca6ea1SDimitry Andric      _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
621349cc55cSDimitry Andric
622349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
623*0fca6ea1SDimitry Andric  template <
624*0fca6ea1SDimitry Andric      class _InputIter,
625*0fca6ea1SDimitry Andric      class _Alloc,
626*0fca6ea1SDimitry Andric      __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
627*0fca6ea1SDimitry Andric                    int> = 0>
628*0fca6ea1SDimitry Andric  _LIBCPP_HIDE_FROM_ABI
629*0fca6ea1SDimitry Andric  priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);
6300b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6310b57cec5SDimitry Andric
63206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
63306c3fb27SDimitry Andric
63406c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
63506c3fb27SDimitry Andric            class _Alloc,
63606c3fb27SDimitry Andric            class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
637cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)
638cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) {
63906c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
64006c3fb27SDimitry Andric  }
64106c3fb27SDimitry Andric
64206c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range,
64306c3fb27SDimitry Andric            class _Alloc,
64406c3fb27SDimitry Andric            class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
645cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)
646cb14a3feSDimitry Andric      : c(from_range, std::forward<_Range>(__range), __a), comp() {
64706c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
64806c3fb27SDimitry Andric  }
64906c3fb27SDimitry Andric
65006c3fb27SDimitry Andric#endif
65106c3fb27SDimitry Andric
652*0fca6ea1SDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
653cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
654cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
6550b57cec5SDimitry Andric
656cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
6570b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
658cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);
65906c3fb27SDimitry Andric
66006c3fb27SDimitry Andric#  if _LIBCPP_STD_VER >= 23
66106c3fb27SDimitry Andric  template <_ContainerCompatibleRange<_Tp> _Range>
662cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
663cb14a3feSDimitry Andric    if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
66406c3fb27SDimitry Andric      c.append_range(std::forward<_Range>(__range));
66506c3fb27SDimitry Andric    } else {
66606c3fb27SDimitry Andric      ranges::copy(std::forward<_Range>(__range), std::back_inserter(c));
66706c3fb27SDimitry Andric    }
66806c3fb27SDimitry Andric
66906c3fb27SDimitry Andric    std::make_heap(c.begin(), c.end(), comp);
67006c3fb27SDimitry Andric  }
67106c3fb27SDimitry Andric#  endif
67206c3fb27SDimitry Andric
6730b57cec5SDimitry Andric  template <class... _Args>
674cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);
6750b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
676cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void pop();
6770b57cec5SDimitry Andric
678cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
679*0fca6ea1SDimitry Andric      _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);
680bdd1243dSDimitry Andric
681bdd1243dSDimitry Andric  _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
6820b57cec5SDimitry Andric};
6830b57cec5SDimitry Andric
684349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17
6850b57cec5SDimitry Andrictemplate <class _Compare,
6860b57cec5SDimitry Andric          class _Container,
687349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
688cb14a3feSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value> >
689cb14a3feSDimitry Andricpriority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6900b57cec5SDimitry Andric
6910b57cec5SDimitry Andrictemplate <class _InputIterator,
692fe6060f1SDimitry Andric          class _Compare   = less<__iter_value_type<_InputIterator>>,
693fe6060f1SDimitry Andric          class _Container = vector<__iter_value_type<_InputIterator>>,
69406c3fb27SDimitry Andric          class            = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
695349cc55cSDimitry Andric          class            = enable_if_t<!__is_allocator<_Compare>::value>,
696cb14a3feSDimitry Andric          class            = enable_if_t<!__is_allocator<_Container>::value> >
6970b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
698fe6060f1SDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
6990b57cec5SDimitry Andric
7000b57cec5SDimitry Andrictemplate <class _Compare,
7010b57cec5SDimitry Andric          class _Container,
7020b57cec5SDimitry Andric          class _Alloc,
703349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
704349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
705cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
706cb14a3feSDimitry Andricpriority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>;
707349cc55cSDimitry Andric
708cb14a3feSDimitry Andrictemplate <class _InputIterator,
709cb14a3feSDimitry Andric          class _Allocator,
71006c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
711cb14a3feSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value> >
712349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator)
713349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
714349cc55cSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
715349cc55cSDimitry Andric                      less<__iter_value_type<_InputIterator>>>;
716349cc55cSDimitry Andric
717cb14a3feSDimitry Andrictemplate <class _InputIterator,
718cb14a3feSDimitry Andric          class _Compare,
719cb14a3feSDimitry Andric          class _Allocator,
72006c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
721349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
722cb14a3feSDimitry Andric          class = enable_if_t<__is_allocator<_Allocator>::value> >
723349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
724349cc55cSDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>,
725cb14a3feSDimitry Andric                      vector<__iter_value_type<_InputIterator>, _Allocator>,
726cb14a3feSDimitry Andric                      _Compare>;
727349cc55cSDimitry Andric
728cb14a3feSDimitry Andrictemplate <class _InputIterator,
729cb14a3feSDimitry Andric          class _Compare,
730cb14a3feSDimitry Andric          class _Container,
731cb14a3feSDimitry Andric          class _Alloc,
73206c3fb27SDimitry Andric          class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
733349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
734349cc55cSDimitry Andric          class = enable_if_t<!__is_allocator<_Container>::value>,
735cb14a3feSDimitry Andric          class = enable_if_t<uses_allocator<_Container, _Alloc>::value> >
736349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
737349cc55cSDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
7380b57cec5SDimitry Andric#endif
7390b57cec5SDimitry Andric
74006c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23
74106c3fb27SDimitry Andric
74206c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
74306c3fb27SDimitry Andric          class _Compare = less<ranges::range_value_t<_Range>>,
74406c3fb27SDimitry Andric          class          = enable_if_t<!__is_allocator<_Compare>::value>>
74506c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare())
74606c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>;
74706c3fb27SDimitry Andric
74806c3fb27SDimitry Andrictemplate <ranges::input_range _Range,
74906c3fb27SDimitry Andric          class _Compare,
75006c3fb27SDimitry Andric          class _Alloc,
75106c3fb27SDimitry Andric          class = enable_if_t<!__is_allocator<_Compare>::value>,
75206c3fb27SDimitry Andric          class = enable_if_t<__is_allocator<_Alloc>::value>>
75306c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc)
754cb14a3feSDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>;
75506c3fb27SDimitry Andric
756cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>>
75706c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc)
75806c3fb27SDimitry Andric    -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
75906c3fb27SDimitry Andric
76006c3fb27SDimitry Andric#endif
76106c3fb27SDimitry Andric
7620b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
763cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)
764cb14a3feSDimitry Andric    : c(__c), comp(__comp) {
7655f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7660b57cec5SDimitry Andric}
7670b57cec5SDimitry Andric
7680b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7690b57cec5SDimitry Andric
7700b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
771cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)
772cb14a3feSDimitry Andric    : c(std::move(__c)), comp(__comp) {
7735f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7740b57cec5SDimitry Andric}
7750b57cec5SDimitry Andric
7760b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7770b57cec5SDimitry Andric
7780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
779*0fca6ea1SDimitry Andrictemplate <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
780cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
781cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp)
782cb14a3feSDimitry Andric    : c(__f, __l), comp(__comp) {
7835f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7840b57cec5SDimitry Andric}
7850b57cec5SDimitry Andric
7860b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
787*0fca6ea1SDimitry Andrictemplate <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
788cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
789cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
790cb14a3feSDimitry Andric    : c(__c), comp(__comp) {
7910b57cec5SDimitry Andric  c.insert(c.end(), __f, __l);
7925f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
7930b57cec5SDimitry Andric}
7940b57cec5SDimitry Andric
7950b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7960b57cec5SDimitry Andric
7970b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
798*0fca6ea1SDimitry Andrictemplate <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
799cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
800cb14a3feSDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)
801cb14a3feSDimitry Andric    : c(std::move(__c)), comp(__comp) {
8020b57cec5SDimitry Andric  c.insert(c.end(), __f, __l);
8035f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8040b57cec5SDimitry Andric}
8050b57cec5SDimitry Andric
8060b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8070b57cec5SDimitry Andric
8080b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
809*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
810*0fca6ea1SDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {}
8110b57cec5SDimitry Andric
8120b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
813*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
814*0fca6ea1SDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a)
815cb14a3feSDimitry Andric    : c(__a), comp(__comp) {}
8160b57cec5SDimitry Andric
8170b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
818*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
819cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
820*0fca6ea1SDimitry Andric    const value_compare& __comp, const container_type& __c, const _Alloc& __a)
821cb14a3feSDimitry Andric    : c(__c, __a), comp(__comp) {
8225f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8230b57cec5SDimitry Andric}
8240b57cec5SDimitry Andric
8250b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
826*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
827*0fca6ea1SDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)
828cb14a3feSDimitry Andric    : c(__q.c, __a), comp(__q.comp) {}
8290b57cec5SDimitry Andric
8300b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
8310b57cec5SDimitry Andric
8320b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
833*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
834cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
835*0fca6ea1SDimitry Andric    const value_compare& __comp, container_type&& __c, const _Alloc& __a)
836cb14a3feSDimitry Andric    : c(std::move(__c), __a), comp(__comp) {
8375f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8380b57cec5SDimitry Andric}
8390b57cec5SDimitry Andric
8400b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
841*0fca6ea1SDimitry Andrictemplate <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
842*0fca6ea1SDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)
843cb14a3feSDimitry Andric    : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
844349cc55cSDimitry Andric
845349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG
846349cc55cSDimitry Andric
847349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
848*0fca6ea1SDimitry Andrictemplate <
849*0fca6ea1SDimitry Andric    class _InputIter,
850*0fca6ea1SDimitry Andric    class _Alloc,
851*0fca6ea1SDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
852*0fca6ea1SDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a)
853cb14a3feSDimitry Andric    : c(__f, __l, __a), comp() {
8545f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
8550b57cec5SDimitry Andric}
8560b57cec5SDimitry Andric
857349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
858*0fca6ea1SDimitry Andrictemplate <
859*0fca6ea1SDimitry Andric    class _InputIter,
860*0fca6ea1SDimitry Andric    class _Alloc,
861*0fca6ea1SDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
862cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
863*0fca6ea1SDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)
864cb14a3feSDimitry Andric    : c(__f, __l, __a), comp(__comp) {
8655f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
866349cc55cSDimitry Andric}
867349cc55cSDimitry Andric
868349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
869*0fca6ea1SDimitry Andrictemplate <
870*0fca6ea1SDimitry Andric    class _InputIter,
871*0fca6ea1SDimitry Andric    class _Alloc,
872*0fca6ea1SDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
873cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
874*0fca6ea1SDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)
875cb14a3feSDimitry Andric    : c(__c, __a), comp(__comp) {
876349cc55cSDimitry Andric  c.insert(c.end(), __f, __l);
8775f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
878349cc55cSDimitry Andric}
879349cc55cSDimitry Andric
880349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
881349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
882*0fca6ea1SDimitry Andrictemplate <
883*0fca6ea1SDimitry Andric    class _InputIter,
884*0fca6ea1SDimitry Andric    class _Alloc,
885*0fca6ea1SDimitry Andric    __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
886cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(
887*0fca6ea1SDimitry Andric    _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a)
888cb14a3feSDimitry Andric    : c(std::move(__c), __a), comp(__comp) {
889349cc55cSDimitry Andric  c.insert(c.end(), __f, __l);
8905f757f3fSDimitry Andric  std::make_heap(c.begin(), c.end(), comp);
891349cc55cSDimitry Andric}
8920b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
8930b57cec5SDimitry Andric
8940b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
895cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
8960b57cec5SDimitry Andric  c.push_back(__v);
8975f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
8980b57cec5SDimitry Andric}
8990b57cec5SDimitry Andric
9000b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
9010b57cec5SDimitry Andric
9020b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
903cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {
9045f757f3fSDimitry Andric  c.push_back(std::move(__v));
9055f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
9060b57cec5SDimitry Andric}
9070b57cec5SDimitry Andric
9080b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
9090b57cec5SDimitry Andrictemplate <class... _Args>
910cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) {
9115f757f3fSDimitry Andric  c.emplace_back(std::forward<_Args>(__args)...);
9125f757f3fSDimitry Andric  std::push_heap(c.begin(), c.end(), comp);
9130b57cec5SDimitry Andric}
9140b57cec5SDimitry Andric
9150b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
9160b57cec5SDimitry Andric
9170b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
918cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::pop() {
9195f757f3fSDimitry Andric  std::pop_heap(c.begin(), c.end(), comp);
9200b57cec5SDimitry Andric  c.pop_back();
9210b57cec5SDimitry Andric}
9220b57cec5SDimitry Andric
9230b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
924cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
925*0fca6ea1SDimitry Andric    _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) {
9265f757f3fSDimitry Andric  using std::swap;
9270b57cec5SDimitry Andric  swap(c, __q.c);
9280b57cec5SDimitry Andric  swap(comp, __q.comp);
9290b57cec5SDimitry Andric}
9300b57cec5SDimitry Andric
931cb14a3feSDimitry Andrictemplate <class _Tp,
932cb14a3feSDimitry Andric          class _Container,
933cb14a3feSDimitry Andric          class _Compare,
934*0fca6ea1SDimitry Andric          __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0>
935cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void
936cb14a3feSDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)
937cb14a3feSDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
9380b57cec5SDimitry Andric  __x.swap(__y);
9390b57cec5SDimitry Andric}
9400b57cec5SDimitry Andric
9410b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
9420b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
943cb14a3feSDimitry Andric    : public uses_allocator<_Container, _Alloc> {};
9440b57cec5SDimitry Andric
9450b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
9460b57cec5SDimitry Andric
947b3edf446SDimitry Andric_LIBCPP_POP_MACROS
948b3edf446SDimitry Andric
949bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
950bdd1243dSDimitry Andric#  include <concepts>
95106c3fb27SDimitry Andric#  include <cstdlib>
952bdd1243dSDimitry Andric#  include <functional>
95306c3fb27SDimitry Andric#  include <type_traits>
954bdd1243dSDimitry Andric#endif
955bdd1243dSDimitry Andric
9560b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE
957