xref: /llvm-project-15.0.7/libcxx/include/queue (revision 2e2f3158)
13e519524SHoward Hinnant// -*- C++ -*-
2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===//
33e519524SHoward Hinnant//
457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information.
657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
73e519524SHoward Hinnant//
83e519524SHoward Hinnant//===----------------------------------------------------------------------===//
93e519524SHoward Hinnant
103e519524SHoward Hinnant#ifndef _LIBCPP_QUEUE
113e519524SHoward Hinnant#define _LIBCPP_QUEUE
123e519524SHoward Hinnant
133e519524SHoward Hinnant/*
143e519524SHoward Hinnant    queue synopsis
153e519524SHoward Hinnant
163e519524SHoward Hinnantnamespace std
173e519524SHoward Hinnant{
183e519524SHoward Hinnant
193e519524SHoward Hinnanttemplate <class T, class Container = deque<T>>
203e519524SHoward Hinnantclass queue
213e519524SHoward Hinnant{
223e519524SHoward Hinnantpublic:
233e519524SHoward Hinnant    typedef Container                                container_type;
243e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
253e519524SHoward Hinnant    typedef typename container_type::reference       reference;
263e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
273e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
283e519524SHoward Hinnant
293e519524SHoward Hinnantprotected:
303e519524SHoward Hinnant    container_type c;
313e519524SHoward Hinnant
323e519524SHoward Hinnantpublic:
336971d826SHoward Hinnant    queue() = default;
346971d826SHoward Hinnant    ~queue() = default;
356971d826SHoward Hinnant
366971d826SHoward Hinnant    queue(const queue& q) = default;
376971d826SHoward Hinnant    queue(queue&& q) = default;
386971d826SHoward Hinnant
396971d826SHoward Hinnant    queue& operator=(const queue& q) = default;
406971d826SHoward Hinnant    queue& operator=(queue&& q) = default;
416971d826SHoward Hinnant
423e519524SHoward Hinnant    explicit queue(const container_type& c);
436971d826SHoward Hinnant    explicit queue(container_type&& c)
44f3aed369SNikolas Klauser    template<class InputIterator>
45f3aed369SNikolas Klauser        queue(InputIterator first, InputIterator last); // since C++23
463e519524SHoward Hinnant    template <class Alloc>
473e519524SHoward Hinnant        explicit queue(const Alloc& a);
483e519524SHoward Hinnant    template <class Alloc>
493e519524SHoward Hinnant        queue(const container_type& c, const Alloc& a);
503e519524SHoward Hinnant    template <class Alloc>
513e519524SHoward Hinnant        queue(container_type&& c, const Alloc& a);
523e519524SHoward Hinnant    template <class Alloc>
536971d826SHoward Hinnant        queue(const queue& q, const Alloc& a);
546971d826SHoward Hinnant    template <class Alloc>
553e519524SHoward Hinnant        queue(queue&& q, const Alloc& a);
56f3aed369SNikolas Klauser    template <class InputIterator, class Alloc>
57f3aed369SNikolas Klauser        queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
583e519524SHoward Hinnant
593e519524SHoward Hinnant    bool      empty() const;
603e519524SHoward Hinnant    size_type size() const;
613e519524SHoward Hinnant
623e519524SHoward Hinnant    reference       front();
633e519524SHoward Hinnant    const_reference front() const;
643e519524SHoward Hinnant    reference       back();
653e519524SHoward Hinnant    const_reference back() const;
663e519524SHoward Hinnant
673e519524SHoward Hinnant    void push(const value_type& v);
683e519524SHoward Hinnant    void push(value_type&& v);
6963b560beSMarshall Clow    template <class... Args> reference emplace(Args&&... args); // reference in C++17
703e519524SHoward Hinnant    void pop();
713e519524SHoward Hinnant
72f07dd8d0SEric Fiselier    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
733e519524SHoward Hinnant};
743e519524SHoward Hinnant
755b8b8b5dSMarshall Clowtemplate<class Container>
765b8b8b5dSMarshall Clow  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
775b8b8b5dSMarshall Clow
78f3aed369SNikolas Klausertemplate<class InputIterator>
79f3aed369SNikolas Klauser  queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
80f3aed369SNikolas Klauser
815b8b8b5dSMarshall Clowtemplate<class Container, class Allocator>
825b8b8b5dSMarshall Clow  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
835b8b8b5dSMarshall Clow
84f3aed369SNikolas Klausertemplate<class InputIterator, class Allocator>
85f3aed369SNikolas Klauser  queue(InputIterator, InputIterator, Allocator)
86f3aed369SNikolas Klauser  -> queue<iter-value-type<InputIterator>,
87f3aed369SNikolas Klauser           deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
88f3aed369SNikolas Klauser
893e519524SHoward Hinnanttemplate <class T, class Container>
903e519524SHoward Hinnant  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
913e519524SHoward Hinnant
923e519524SHoward Hinnanttemplate <class T, class Container>
933e519524SHoward Hinnant  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
943e519524SHoward Hinnant
953e519524SHoward Hinnanttemplate <class T, class Container>
963e519524SHoward Hinnant  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
973e519524SHoward Hinnant
983e519524SHoward Hinnanttemplate <class T, class Container>
993e519524SHoward Hinnant  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
1003e519524SHoward Hinnant
1013e519524SHoward Hinnanttemplate <class T, class Container>
1023e519524SHoward Hinnant  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
1033e519524SHoward Hinnant
1043e519524SHoward Hinnanttemplate <class T, class Container>
1053e519524SHoward Hinnant  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
1063e519524SHoward Hinnant
1073e519524SHoward Hinnanttemplate <class T, class Container>
1086971d826SHoward Hinnant  void swap(queue<T, Container>& x, queue<T, Container>& y)
1096971d826SHoward Hinnant  noexcept(noexcept(x.swap(y)));
1103e519524SHoward Hinnant
1113e519524SHoward Hinnanttemplate <class T, class Container = vector<T>,
1123e519524SHoward Hinnant          class Compare = less<typename Container::value_type>>
1133e519524SHoward Hinnantclass priority_queue
1143e519524SHoward Hinnant{
1153e519524SHoward Hinnantpublic:
1163e519524SHoward Hinnant    typedef Container                                container_type;
1173e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
1183e519524SHoward Hinnant    typedef typename container_type::reference       reference;
1193e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
1203e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
1213e519524SHoward Hinnant
1223e519524SHoward Hinnantprotected:
1233e519524SHoward Hinnant    container_type c;
1243e519524SHoward Hinnant    Compare comp;
1253e519524SHoward Hinnant
1263e519524SHoward Hinnantpublic:
127a11f8b1aSMarek Kurdej    priority_queue() : priority_queue(Compare()) {} // C++20
128a11f8b1aSMarek Kurdej    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
129a11f8b1aSMarek Kurdej    priority_queue(const Compare& x, const Container&);
130a11f8b1aSMarek Kurdej    explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20
131a11f8b1aSMarek Kurdej    priority_queue(const Compare& x, Container&&); // C++20
1323e519524SHoward Hinnant    template <class InputIterator>
1333e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1343e519524SHoward Hinnant                       const Compare& comp = Compare());
1353e519524SHoward Hinnant    template <class InputIterator>
1363e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1373894a8a4SArthur O'Dwyer                       const Compare& comp, const Container& c);
1383e519524SHoward Hinnant    template <class InputIterator>
1393e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1403894a8a4SArthur O'Dwyer                       const Compare& comp, Container&& c);
1413e519524SHoward Hinnant    template <class Alloc>
1423e519524SHoward Hinnant        explicit priority_queue(const Alloc& a);
1433e519524SHoward Hinnant    template <class Alloc>
1443e519524SHoward Hinnant        priority_queue(const Compare& comp, const Alloc& a);
1453e519524SHoward Hinnant    template <class Alloc>
1463894a8a4SArthur O'Dwyer        priority_queue(const Compare& comp, const Container& c,
1473e519524SHoward Hinnant                       const Alloc& a);
1483e519524SHoward Hinnant    template <class Alloc>
1493894a8a4SArthur O'Dwyer        priority_queue(const Compare& comp, Container&& c,
1503e519524SHoward Hinnant                       const Alloc& a);
1513894a8a4SArthur O'Dwyer    template <class InputIterator>
1523894a8a4SArthur O'Dwyer        priority_queue(InputIterator first, InputIterator last,
1533894a8a4SArthur O'Dwyer                       const Alloc& a);
1543894a8a4SArthur O'Dwyer    template <class InputIterator>
1553894a8a4SArthur O'Dwyer        priority_queue(InputIterator first, InputIterator last,
1563894a8a4SArthur O'Dwyer                       const Compare& comp, const Alloc& a);
1573894a8a4SArthur O'Dwyer    template <class InputIterator>
1583894a8a4SArthur O'Dwyer        priority_queue(InputIterator first, InputIterator last,
1593894a8a4SArthur O'Dwyer                       const Compare& comp, const Container& c, const Alloc& a);
1603894a8a4SArthur O'Dwyer    template <class InputIterator>
1613894a8a4SArthur O'Dwyer        priority_queue(InputIterator first, InputIterator last,
1623894a8a4SArthur O'Dwyer                       const Compare& comp, Container&& c, const Alloc& a);
1633e519524SHoward Hinnant    template <class Alloc>
1646971d826SHoward Hinnant        priority_queue(const priority_queue& q, const Alloc& a);
1656971d826SHoward Hinnant    template <class Alloc>
1663e519524SHoward Hinnant        priority_queue(priority_queue&& q, const Alloc& a);
1673e519524SHoward Hinnant
1683e519524SHoward Hinnant    bool            empty() const;
1693e519524SHoward Hinnant    size_type       size() const;
1703e519524SHoward Hinnant    const_reference top() const;
1713e519524SHoward Hinnant
1723e519524SHoward Hinnant    void push(const value_type& v);
1733e519524SHoward Hinnant    void push(value_type&& v);
1743e519524SHoward Hinnant    template <class... Args> void emplace(Args&&... args);
1753e519524SHoward Hinnant    void pop();
1763e519524SHoward Hinnant
1776971d826SHoward Hinnant    void swap(priority_queue& q)
178f07dd8d0SEric Fiselier        noexcept(is_nothrow_swappable_v<Container> &&
179f07dd8d0SEric Fiselier                 is_nothrow_swappable_v<Comp>)
1803e519524SHoward Hinnant};
1813e519524SHoward Hinnant
1825b8b8b5dSMarshall Clowtemplate <class Compare, class Container>
1835b8b8b5dSMarshall Clowpriority_queue(Compare, Container)
1845b8b8b5dSMarshall Clow    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1855b8b8b5dSMarshall Clow
1865b8b8b5dSMarshall Clowtemplate<class InputIterator,
1873894a8a4SArthur O'Dwyer         class Compare = less<iter-value-type<InputIterator>>,
1883894a8a4SArthur O'Dwyer         class Container = vector<iter-value-type<InputIterator>>>
1895b8b8b5dSMarshall Clowpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
1903894a8a4SArthur O'Dwyer    -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
1915b8b8b5dSMarshall Clow
1925b8b8b5dSMarshall Clowtemplate<class Compare, class Container, class Allocator>
1935b8b8b5dSMarshall Clowpriority_queue(Compare, Container, Allocator)
1945b8b8b5dSMarshall Clow    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1955b8b8b5dSMarshall Clow
1963894a8a4SArthur O'Dwyertemplate<class InputIterator, class Allocator>
1973894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Allocator)
1983894a8a4SArthur O'Dwyer    -> priority_queue<iter-value-type<InputIterator>,
1993894a8a4SArthur O'Dwyer                      vector<iter-value-type<InputIterator>, Allocator>,
20068072a71SKonstantin Varlamov                      less<iter-value-type<InputIterator>>>; // C++17
2013894a8a4SArthur O'Dwyer
2023894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Allocator>
2033894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Allocator)
2043894a8a4SArthur O'Dwyer    -> priority_queue<iter-value-type<InputIterator>,
20568072a71SKonstantin Varlamov                      vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17
2063894a8a4SArthur O'Dwyer
2073894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Container, class Allocator>
2083894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
20968072a71SKonstantin Varlamov    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
2103894a8a4SArthur O'Dwyer
2113e519524SHoward Hinnanttemplate <class T, class Container, class Compare>
2123e519524SHoward Hinnant  void swap(priority_queue<T, Container, Compare>& x,
2136971d826SHoward Hinnant            priority_queue<T, Container, Compare>& y)
2146971d826SHoward Hinnant            noexcept(noexcept(x.swap(y)));
2153e519524SHoward Hinnant
2163e519524SHoward Hinnant}  // std
2173e519524SHoward Hinnant
2183e519524SHoward Hinnant*/
2193e519524SHoward Hinnant
220*2e2f3158SNikolas Klauser#include <__algorithm/make_heap.h>
221*2e2f3158SNikolas Klauser#include <__algorithm/pop_heap.h>
222*2e2f3158SNikolas Klauser#include <__algorithm/push_heap.h>
2233e519524SHoward Hinnant#include <__config>
224f3aed369SNikolas Klauser#include <__iterator/iterator_traits.h>
225050b064fSChristopher Di Bella#include <__memory/uses_allocator.h>
2266adbc83eSChristopher Di Bella#include <__utility/forward.h>
2272d0f1fa4SArthur O'Dwyer#include <compare>
2283e519524SHoward Hinnant#include <deque>
2293e519524SHoward Hinnant#include <functional>
230f3aed369SNikolas Klauser#include <type_traits>
231bfbd73f8SArthur O'Dwyer#include <vector>
232bd6e6846SMark de Wever#include <version>
2333e519524SHoward Hinnant
234073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2353e519524SHoward Hinnant#  pragma GCC system_header
236073458b1SHoward Hinnant#endif
2373e519524SHoward Hinnant
2383e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD
2393e519524SHoward Hinnant
240e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
2413e519524SHoward Hinnant
2423e519524SHoward Hinnanttemplate <class _Tp, class _Container>
243aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
2443e519524SHoward Hinnantbool
2453e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2463e519524SHoward Hinnant
2473e519524SHoward Hinnanttemplate <class _Tp, class _Container>
248aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
2493e519524SHoward Hinnantbool
2503e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2513e519524SHoward Hinnant
2523afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/>
253e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue
2543e519524SHoward Hinnant{
2553e519524SHoward Hinnantpublic:
2563e519524SHoward Hinnant    typedef _Container                               container_type;
2573e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
2583e519524SHoward Hinnant    typedef typename container_type::reference       reference;
2593e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
2603e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
261c1fe2c43SMarshall Clow    static_assert((is_same<_Tp, value_type>::value), "" );
2623e519524SHoward Hinnant
2633e519524SHoward Hinnantprotected:
2643e519524SHoward Hinnant    container_type c;
2653e519524SHoward Hinnant
2663e519524SHoward Hinnantpublic:
267392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2686971d826SHoward Hinnant    queue()
2696971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2706971d826SHoward Hinnant        : c() {}
2716971d826SHoward Hinnant
2726971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2736971d826SHoward Hinnant    queue(const queue& __q) : c(__q.c) {}
2746971d826SHoward Hinnant
275f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20
276f3aed369SNikolas Klauser    template <class _InputIterator,
277f3aed369SNikolas Klauser              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
278f3aed369SNikolas Klauser    _LIBCPP_HIDE_FROM_ABI
279f3aed369SNikolas Klauser    queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
280f3aed369SNikolas Klauser
281f3aed369SNikolas Klauser    template <class _InputIterator,
282f3aed369SNikolas Klauser              class _Alloc,
283f3aed369SNikolas Klauser              class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
284f3aed369SNikolas Klauser              class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
285f3aed369SNikolas Klauser    _LIBCPP_HIDE_FROM_ABI
286f3aed369SNikolas Klauser    queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {}
287f3aed369SNikolas Klauser#endif
288f3aed369SNikolas Klauser
289f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
290f5427b26SEric Fiselier    queue& operator=(const queue& __q) {c = __q.c; return *this;}
291f5427b26SEric Fiselier
292f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
2936971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2946971d826SHoward Hinnant    queue(queue&& __q)
2956971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
296ce48a113SHoward Hinnant        : c(_VSTD::move(__q.c)) {}
2976971d826SHoward Hinnant
2986971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2996971d826SHoward Hinnant    queue& operator=(queue&& __q)
3006971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
301ce48a113SHoward Hinnant        {c = _VSTD::move(__q.c); return *this;}
302f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
3036971d826SHoward Hinnant
304392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3053e519524SHoward Hinnant    explicit queue(const container_type& __c)  : c(__c) {}
306f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
307392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
308ce48a113SHoward Hinnant    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
309f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
3103e519524SHoward Hinnant    template <class _Alloc>
311392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
3123e519524SHoward Hinnant        explicit queue(const _Alloc& __a,
313b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3143e519524SHoward Hinnant            : c(__a) {}
3153e519524SHoward Hinnant    template <class _Alloc>
316392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
3173e519524SHoward Hinnant        queue(const queue& __q, const _Alloc& __a,
318b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3193e519524SHoward Hinnant            : c(__q.c, __a) {}
3203e519524SHoward Hinnant    template <class _Alloc>
321392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
3223e519524SHoward Hinnant        queue(const container_type& __c, const _Alloc& __a,
323b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
3243e519524SHoward Hinnant            : c(__c, __a) {}
325f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
3263e519524SHoward Hinnant    template <class _Alloc>
327392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
3283e519524SHoward Hinnant        queue(container_type&& __c, const _Alloc& __a,
329b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
330ce48a113SHoward Hinnant            : c(_VSTD::move(__c), __a) {}
3313e519524SHoward Hinnant    template <class _Alloc>
332392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
3333e519524SHoward Hinnant        queue(queue&& __q, const _Alloc& __a,
334b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
335ce48a113SHoward Hinnant            : c(_VSTD::move(__q.c), __a) {}
3363e519524SHoward Hinnant
337f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
3383e519524SHoward Hinnant
33972c8fad4SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
3403e519524SHoward Hinnant    bool      empty() const {return c.empty();}
341392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3423e519524SHoward Hinnant    size_type size() const  {return c.size();}
3433e519524SHoward Hinnant
344392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3453e519524SHoward Hinnant    reference       front()       {return c.front();}
346392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3473e519524SHoward Hinnant    const_reference front() const {return c.front();}
348392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3493e519524SHoward Hinnant    reference       back()        {return c.back();}
350392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3513e519524SHoward Hinnant    const_reference back() const  {return c.back();}
3523e519524SHoward Hinnant
353392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3543e519524SHoward Hinnant    void push(const value_type& __v) {c.push_back(__v);}
355f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
356392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
357ce48a113SHoward Hinnant    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3583e519524SHoward Hinnant    template <class... _Args>
359392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
36063b560beSMarshall Clow#if _LIBCPP_STD_VER > 14
361e34f5ffeSMarshall Clow        decltype(auto) emplace(_Args&&... __args)
3620e411641SEric Fiselier            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
36363b560beSMarshall Clow#else
36463b560beSMarshall Clow        void     emplace(_Args&&... __args)
36563b560beSMarshall Clow            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
36663b560beSMarshall Clow#endif
367f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
368392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3693e519524SHoward Hinnant    void pop() {c.pop_front();}
3703e519524SHoward Hinnant
371392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3723e519524SHoward Hinnant    void swap(queue& __q)
3736971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3743e519524SHoward Hinnant    {
375ce48a113SHoward Hinnant        using _VSTD::swap;
3763e519524SHoward Hinnant        swap(c, __q.c);
3773e519524SHoward Hinnant    }
3783e519524SHoward Hinnant
3793e519524SHoward Hinnant    template <class _T1, class _C1>
3803e519524SHoward Hinnant    friend
381392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3823e519524SHoward Hinnant    bool
3833e519524SHoward Hinnant    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3843e519524SHoward Hinnant
3853e519524SHoward Hinnant    template <class _T1, class _C1>
3863e519524SHoward Hinnant    friend
387392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3883e519524SHoward Hinnant    bool
3893e519524SHoward Hinnant    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3903e519524SHoward Hinnant};
3913e519524SHoward Hinnant
392f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14
3935b8b8b5dSMarshall Clowtemplate<class _Container,
3944e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>
3955b8b8b5dSMarshall Clow>
3965b8b8b5dSMarshall Clowqueue(_Container)
3975b8b8b5dSMarshall Clow    -> queue<typename _Container::value_type, _Container>;
3985b8b8b5dSMarshall Clow
3995b8b8b5dSMarshall Clowtemplate<class _Container,
4005b8b8b5dSMarshall Clow         class _Alloc,
4014e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>,
4024e0ea2cfSLouis Dionne         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
4035b8b8b5dSMarshall Clow>
4045b8b8b5dSMarshall Clowqueue(_Container, _Alloc)
4055b8b8b5dSMarshall Clow    -> queue<typename _Container::value_type, _Container>;
4065b8b8b5dSMarshall Clow#endif
4075b8b8b5dSMarshall Clow
408f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20
409f3aed369SNikolas Klausertemplate <class _InputIterator,
410f3aed369SNikolas Klauser          class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>>
411f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator)
412f3aed369SNikolas Klauser    -> queue<__iter_value_type<_InputIterator>>;
413f3aed369SNikolas Klauser
414f3aed369SNikolas Klausertemplate <class _InputIterator,
415f3aed369SNikolas Klauser          class _Alloc,
416f3aed369SNikolas Klauser          class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
417f3aed369SNikolas Klauser          class = __enable_if_t<__is_allocator<_Alloc>::value>>
418f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator, _Alloc)
419f3aed369SNikolas Klauser    -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
420f3aed369SNikolas Klauser#endif
421f3aed369SNikolas Klauser
4223e519524SHoward Hinnanttemplate <class _Tp, class _Container>
423392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4243e519524SHoward Hinnantbool
4253e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4263e519524SHoward Hinnant{
4273e519524SHoward Hinnant    return __x.c == __y.c;
4283e519524SHoward Hinnant}
4293e519524SHoward Hinnant
4303e519524SHoward Hinnanttemplate <class _Tp, class _Container>
431392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4323e519524SHoward Hinnantbool
4333e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4343e519524SHoward Hinnant{
4353e519524SHoward Hinnant    return __x.c < __y.c;
4363e519524SHoward Hinnant}
4373e519524SHoward Hinnant
4383e519524SHoward Hinnanttemplate <class _Tp, class _Container>
439392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4403e519524SHoward Hinnantbool
4413e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4423e519524SHoward Hinnant{
4433e519524SHoward Hinnant    return !(__x == __y);
4443e519524SHoward Hinnant}
4453e519524SHoward Hinnant
4463e519524SHoward Hinnanttemplate <class _Tp, class _Container>
447392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4483e519524SHoward Hinnantbool
4493e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4503e519524SHoward Hinnant{
4513e519524SHoward Hinnant    return __y < __x;
4523e519524SHoward Hinnant}
4533e519524SHoward Hinnant
4543e519524SHoward Hinnanttemplate <class _Tp, class _Container>
455392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4563e519524SHoward Hinnantbool
4573e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4583e519524SHoward Hinnant{
4593e519524SHoward Hinnant    return !(__x < __y);
4603e519524SHoward Hinnant}
4613e519524SHoward Hinnant
4623e519524SHoward Hinnanttemplate <class _Tp, class _Container>
463392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
4643e519524SHoward Hinnantbool
4653e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4663e519524SHoward Hinnant{
4673e519524SHoward Hinnant    return !(__y < __x);
4683e519524SHoward Hinnant}
4693e519524SHoward Hinnant
4703e519524SHoward Hinnanttemplate <class _Tp, class _Container>
471392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
472b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void>
4733e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4746971d826SHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4753e519524SHoward Hinnant{
4763e519524SHoward Hinnant    __x.swap(__y);
4773e519524SHoward Hinnant}
4783e519524SHoward Hinnant
4793e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc>
480e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4813e519524SHoward Hinnant    : public uses_allocator<_Container, _Alloc>
4823e519524SHoward Hinnant{
4833e519524SHoward Hinnant};
4843e519524SHoward Hinnant
4853e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>,
4863e519524SHoward Hinnant          class _Compare = less<typename _Container::value_type> >
487e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue
4883e519524SHoward Hinnant{
4893e519524SHoward Hinnantpublic:
4903e519524SHoward Hinnant    typedef _Container                               container_type;
4913e519524SHoward Hinnant    typedef _Compare                                 value_compare;
4923e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
4933e519524SHoward Hinnant    typedef typename container_type::reference       reference;
4943e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
4953e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
496c1fe2c43SMarshall Clow    static_assert((is_same<_Tp, value_type>::value), "" );
4973e519524SHoward Hinnant
4983e519524SHoward Hinnantprotected:
4993e519524SHoward Hinnant    container_type c;
5003e519524SHoward Hinnant    value_compare comp;
5013e519524SHoward Hinnant
5023e519524SHoward Hinnantpublic:
503392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5046971d826SHoward Hinnant    priority_queue()
5056971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
5066971d826SHoward Hinnant                   is_nothrow_default_constructible<value_compare>::value)
5076971d826SHoward Hinnant        : c(), comp() {}
5086971d826SHoward Hinnant
5096971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5106971d826SHoward Hinnant    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
5116971d826SHoward Hinnant
512f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
513f5427b26SEric Fiselier    priority_queue& operator=(const priority_queue& __q)
514f5427b26SEric Fiselier        {c = __q.c; comp = __q.comp; return *this;}
515f5427b26SEric Fiselier
516f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
5176971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5186971d826SHoward Hinnant    priority_queue(priority_queue&& __q)
5196971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
5206971d826SHoward Hinnant                   is_nothrow_move_constructible<value_compare>::value)
521ce48a113SHoward Hinnant        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
5226971d826SHoward Hinnant
5236971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5246971d826SHoward Hinnant    priority_queue& operator=(priority_queue&& __q)
5256971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
5266971d826SHoward Hinnant                   is_nothrow_move_assignable<value_compare>::value)
527ce48a113SHoward Hinnant        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
528f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
5296971d826SHoward Hinnant
5306971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5316971d826SHoward Hinnant    explicit priority_queue(const value_compare& __comp)
5323e519524SHoward Hinnant        : c(), comp(__comp) {}
533cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
5343e519524SHoward Hinnant    priority_queue(const value_compare& __comp, const container_type& __c);
535f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
536cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
537a11f8b1aSMarek Kurdej    priority_queue(const value_compare& __comp, container_type&& __c);
5383e519524SHoward Hinnant#endif
539b4e88d4dSLouis Dionne    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
540cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5413e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
5423e519524SHoward Hinnant                       const value_compare& __comp = value_compare());
543b4e88d4dSLouis Dionne    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
544cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5453e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
5463e519524SHoward Hinnant                       const value_compare& __comp, const container_type& __c);
547f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
548b4e88d4dSLouis Dionne    template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
549cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5503e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
5513e519524SHoward Hinnant                       const value_compare& __comp, container_type&& __c);
552f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
5533e519524SHoward Hinnant    template <class _Alloc>
554cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5553e519524SHoward Hinnant        explicit priority_queue(const _Alloc& __a,
556b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5573e519524SHoward Hinnant    template <class _Alloc>
558cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5593e519524SHoward Hinnant        priority_queue(const value_compare& __comp, const _Alloc& __a,
560b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5613e519524SHoward Hinnant    template <class _Alloc>
562cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5633e519524SHoward Hinnant        priority_queue(const value_compare& __comp, const container_type& __c,
5643e519524SHoward Hinnant                       const _Alloc& __a,
565b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5663e519524SHoward Hinnant    template <class _Alloc>
567cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5683e519524SHoward Hinnant        priority_queue(const priority_queue& __q, const _Alloc& __a,
569b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
570f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
5713e519524SHoward Hinnant    template <class _Alloc>
572cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5733e519524SHoward Hinnant        priority_queue(const value_compare& __comp, container_type&& __c,
5743e519524SHoward Hinnant                       const _Alloc& __a,
575b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5763e519524SHoward Hinnant    template <class _Alloc>
577cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5783e519524SHoward Hinnant        priority_queue(priority_queue&& __q, const _Alloc& __a,
579b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
580f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
5813e519524SHoward Hinnant
582b4e88d4dSLouis Dionne    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5833894a8a4SArthur O'Dwyer        _LIBCPP_INLINE_VISIBILITY
5843894a8a4SArthur O'Dwyer        priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a,
585b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5863894a8a4SArthur O'Dwyer
587b4e88d4dSLouis Dionne    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5883894a8a4SArthur O'Dwyer        _LIBCPP_INLINE_VISIBILITY
5893894a8a4SArthur O'Dwyer        priority_queue(_InputIter __f, _InputIter __l,
5903894a8a4SArthur O'Dwyer                       const value_compare& __comp, const _Alloc& __a,
591b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5923894a8a4SArthur O'Dwyer
593b4e88d4dSLouis Dionne    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
5943894a8a4SArthur O'Dwyer        _LIBCPP_INLINE_VISIBILITY
5953894a8a4SArthur O'Dwyer        priority_queue(_InputIter __f, _InputIter __l,
5963894a8a4SArthur O'Dwyer                       const value_compare& __comp, const container_type& __c, const _Alloc& __a,
597b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
5983894a8a4SArthur O'Dwyer
5993894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG
600b4e88d4dSLouis Dionne    template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> >
6013894a8a4SArthur O'Dwyer        _LIBCPP_INLINE_VISIBILITY
6023894a8a4SArthur O'Dwyer        priority_queue(_InputIter __f, _InputIter __l,
6033894a8a4SArthur O'Dwyer                       const value_compare& __comp, container_type&& __c, const _Alloc& __a,
604b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
6053894a8a4SArthur O'Dwyer#endif  // _LIBCPP_CXX03_LANG
6063894a8a4SArthur O'Dwyer
60772c8fad4SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
6083e519524SHoward Hinnant    bool            empty() const {return c.empty();}
609392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6103e519524SHoward Hinnant    size_type       size() const  {return c.size();}
611392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
6123e519524SHoward Hinnant    const_reference top() const   {return c.front();}
6133e519524SHoward Hinnant
614cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
6153e519524SHoward Hinnant    void push(const value_type& __v);
616f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
617cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
6183e519524SHoward Hinnant    void push(value_type&& __v);
619f5427b26SEric Fiselier    template <class... _Args>
620f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
621f5427b26SEric Fiselier    void emplace(_Args&&... __args);
622f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
623cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
6243e519524SHoward Hinnant    void pop();
6253e519524SHoward Hinnant
626cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
6276971d826SHoward Hinnant    void swap(priority_queue& __q)
6286971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
6296971d826SHoward Hinnant                   __is_nothrow_swappable<value_compare>::value);
6303e519524SHoward Hinnant};
6313e519524SHoward Hinnant
63201666904SLouis Dionne#if _LIBCPP_STD_VER >= 17
6335b8b8b5dSMarshall Clowtemplate <class _Compare,
6345b8b8b5dSMarshall Clow          class _Container,
6354e0ea2cfSLouis Dionne          class = enable_if_t<!__is_allocator<_Compare>::value>,
6364e0ea2cfSLouis Dionne          class = enable_if_t<!__is_allocator<_Container>::value>
6375b8b8b5dSMarshall Clow>
6385b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container)
6395b8b8b5dSMarshall Clow    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6405b8b8b5dSMarshall Clow
6415b8b8b5dSMarshall Clowtemplate<class _InputIterator,
642199d2ebeSArthur O'Dwyer         class _Compare = less<__iter_value_type<_InputIterator>>,
643199d2ebeSArthur O'Dwyer         class _Container = vector<__iter_value_type<_InputIterator>>,
6444e0ea2cfSLouis Dionne         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
6454e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Compare>::value>,
6464e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>
6475b8b8b5dSMarshall Clow>
6485b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
649199d2ebeSArthur O'Dwyer    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
6505b8b8b5dSMarshall Clow
6515b8b8b5dSMarshall Clowtemplate<class _Compare,
6525b8b8b5dSMarshall Clow         class _Container,
6535b8b8b5dSMarshall Clow         class _Alloc,
6544e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Compare>::value>,
6554e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>,
6564e0ea2cfSLouis Dionne         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
6575b8b8b5dSMarshall Clow>
6585b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc)
6595b8b8b5dSMarshall Clow    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6603894a8a4SArthur O'Dwyer
6613894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator,
6624e0ea2cfSLouis Dionne         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
6634e0ea2cfSLouis Dionne         class = enable_if_t<__is_allocator<_Allocator>::value>
6643894a8a4SArthur O'Dwyer>
6653894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator)
6663894a8a4SArthur O'Dwyer    -> priority_queue<__iter_value_type<_InputIterator>,
6673894a8a4SArthur O'Dwyer                      vector<__iter_value_type<_InputIterator>, _Allocator>,
6683894a8a4SArthur O'Dwyer                      less<__iter_value_type<_InputIterator>>>;
6693894a8a4SArthur O'Dwyer
6703894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator,
6714e0ea2cfSLouis Dionne         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
6724e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Compare>::value>,
6734e0ea2cfSLouis Dionne         class = enable_if_t<__is_allocator<_Allocator>::value>
6743894a8a4SArthur O'Dwyer>
6753894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator)
6763894a8a4SArthur O'Dwyer    -> priority_queue<__iter_value_type<_InputIterator>,
6773894a8a4SArthur O'Dwyer                      vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>;
6783894a8a4SArthur O'Dwyer
6793894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc,
6804e0ea2cfSLouis Dionne         class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>,
6814e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Compare>::value>,
6824e0ea2cfSLouis Dionne         class = enable_if_t<!__is_allocator<_Container>::value>,
6834e0ea2cfSLouis Dionne         class = enable_if_t<uses_allocator<_Container, _Alloc>::value>
6843894a8a4SArthur O'Dwyer>
6853894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
6863894a8a4SArthur O'Dwyer    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
6875b8b8b5dSMarshall Clow#endif
6885b8b8b5dSMarshall Clow
6893e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
690cd31b434SEvgeniy Stepanovinline
6913e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
6923e519524SHoward Hinnant                                                          const container_type& __c)
6933e519524SHoward Hinnant    : c(__c),
6943e519524SHoward Hinnant      comp(__comp)
6953e519524SHoward Hinnant{
696ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6973e519524SHoward Hinnant}
6983e519524SHoward Hinnant
699f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
7003e519524SHoward Hinnant
7013e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
702cd31b434SEvgeniy Stepanovinline
7033e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7043e519524SHoward Hinnant                                                          container_type&& __c)
705ce48a113SHoward Hinnant    : c(_VSTD::move(__c)),
7063e519524SHoward Hinnant      comp(__comp)
7073e519524SHoward Hinnant{
708ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7093e519524SHoward Hinnant}
7103e519524SHoward Hinnant
711f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
7123e519524SHoward Hinnant
7133e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7143894a8a4SArthur O'Dwyertemplate <class _InputIter, class>
715cd31b434SEvgeniy Stepanovinline
7163e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7173e519524SHoward Hinnant                                                          const value_compare& __comp)
7183e519524SHoward Hinnant    : c(__f, __l),
7193e519524SHoward Hinnant      comp(__comp)
7203e519524SHoward Hinnant{
721ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7223e519524SHoward Hinnant}
7233e519524SHoward Hinnant
7243e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7253894a8a4SArthur O'Dwyertemplate <class _InputIter, class>
726cd31b434SEvgeniy Stepanovinline
7273e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7283e519524SHoward Hinnant                                                          const value_compare& __comp,
7293e519524SHoward Hinnant                                                          const container_type& __c)
7303e519524SHoward Hinnant    : c(__c),
7313e519524SHoward Hinnant      comp(__comp)
7323e519524SHoward Hinnant{
7333e519524SHoward Hinnant    c.insert(c.end(), __f, __l);
734ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7353e519524SHoward Hinnant}
7363e519524SHoward Hinnant
737f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
7383e519524SHoward Hinnant
7393e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7403894a8a4SArthur O'Dwyertemplate <class _InputIter, class>
741cd31b434SEvgeniy Stepanovinline
7423e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
7433e519524SHoward Hinnant                                                          const value_compare& __comp,
7443e519524SHoward Hinnant                                                          container_type&& __c)
745ce48a113SHoward Hinnant    : c(_VSTD::move(__c)),
7463e519524SHoward Hinnant      comp(__comp)
7473e519524SHoward Hinnant{
7483e519524SHoward Hinnant    c.insert(c.end(), __f, __l);
749ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7503e519524SHoward Hinnant}
7513e519524SHoward Hinnant
752f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
7533e519524SHoward Hinnant
7543e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7553e519524SHoward Hinnanttemplate <class _Alloc>
756cd31b434SEvgeniy Stepanovinline
7573e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
758b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7593e519524SHoward Hinnant    : c(__a)
7603e519524SHoward Hinnant{
7613e519524SHoward Hinnant}
7623e519524SHoward Hinnant
7633e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7643e519524SHoward Hinnanttemplate <class _Alloc>
765cd31b434SEvgeniy Stepanovinline
7663e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7673e519524SHoward Hinnant                                                          const _Alloc& __a,
768b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7693e519524SHoward Hinnant    : c(__a),
7703e519524SHoward Hinnant      comp(__comp)
7713e519524SHoward Hinnant{
7723e519524SHoward Hinnant}
7733e519524SHoward Hinnant
7743e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7753e519524SHoward Hinnanttemplate <class _Alloc>
776cd31b434SEvgeniy Stepanovinline
7773e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7783e519524SHoward Hinnant                                                          const container_type& __c,
7793e519524SHoward Hinnant                                                          const _Alloc& __a,
780b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7813e519524SHoward Hinnant    : c(__c, __a),
7823e519524SHoward Hinnant      comp(__comp)
7833e519524SHoward Hinnant{
784ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7853e519524SHoward Hinnant}
7863e519524SHoward Hinnant
7873e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7883e519524SHoward Hinnanttemplate <class _Alloc>
789cd31b434SEvgeniy Stepanovinline
7903e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
7913e519524SHoward Hinnant                                                          const _Alloc& __a,
792b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
7933e519524SHoward Hinnant    : c(__q.c, __a),
7943e519524SHoward Hinnant      comp(__q.comp)
7953e519524SHoward Hinnant{
7963e519524SHoward Hinnant}
7973e519524SHoward Hinnant
798f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
7993e519524SHoward Hinnant
8003e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
8013e519524SHoward Hinnanttemplate <class _Alloc>
802cd31b434SEvgeniy Stepanovinline
8033e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
8043e519524SHoward Hinnant                                                          container_type&& __c,
8053e519524SHoward Hinnant                                                          const _Alloc& __a,
806b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
807ce48a113SHoward Hinnant    : c(_VSTD::move(__c), __a),
8083e519524SHoward Hinnant      comp(__comp)
8093e519524SHoward Hinnant{
810ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
8113e519524SHoward Hinnant}
8123e519524SHoward Hinnant
8133e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
8143e519524SHoward Hinnanttemplate <class _Alloc>
815cd31b434SEvgeniy Stepanovinline
8163e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
8173e519524SHoward Hinnant                                                          const _Alloc& __a,
818b4e88d4dSLouis Dionne                       __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
819ce48a113SHoward Hinnant    : c(_VSTD::move(__q.c), __a),
820ce48a113SHoward Hinnant      comp(_VSTD::move(__q.comp))
8213e519524SHoward Hinnant{
8223894a8a4SArthur O'Dwyer}
8233894a8a4SArthur O'Dwyer
8243894a8a4SArthur O'Dwyer#endif  // _LIBCPP_CXX03_LANG
8253894a8a4SArthur O'Dwyer
8263894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare>
8273894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class>
8283894a8a4SArthur O'Dwyerinline
8293894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue(
8303894a8a4SArthur O'Dwyer        _InputIter __f, _InputIter __l, const _Alloc& __a,
831b4e88d4dSLouis Dionne        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8323894a8a4SArthur O'Dwyer    : c(__f, __l, __a),
8333894a8a4SArthur O'Dwyer      comp()
8343894a8a4SArthur O'Dwyer{
835ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
8363e519524SHoward Hinnant}
8373e519524SHoward Hinnant
8383894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare>
8393894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class>
8403894a8a4SArthur O'Dwyerinline
8413894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue(
8423894a8a4SArthur O'Dwyer        _InputIter __f, _InputIter __l,
8433894a8a4SArthur O'Dwyer        const value_compare& __comp, const _Alloc& __a,
844b4e88d4dSLouis Dionne        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8453894a8a4SArthur O'Dwyer    : c(__f, __l, __a),
8463894a8a4SArthur O'Dwyer      comp(__comp)
8473894a8a4SArthur O'Dwyer{
8483894a8a4SArthur O'Dwyer    _VSTD::make_heap(c.begin(), c.end(), comp);
8493894a8a4SArthur O'Dwyer}
8503894a8a4SArthur O'Dwyer
8513894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare>
8523894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class>
8533894a8a4SArthur O'Dwyerinline
8543894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue(
8553894a8a4SArthur O'Dwyer        _InputIter __f, _InputIter __l,
8563894a8a4SArthur O'Dwyer        const value_compare& __comp, const container_type& __c, const _Alloc& __a,
857b4e88d4dSLouis Dionne        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8583894a8a4SArthur O'Dwyer    : c(__c, __a),
8593894a8a4SArthur O'Dwyer      comp(__comp)
8603894a8a4SArthur O'Dwyer{
8613894a8a4SArthur O'Dwyer    c.insert(c.end(), __f, __l);
8623894a8a4SArthur O'Dwyer    _VSTD::make_heap(c.begin(), c.end(), comp);
8633894a8a4SArthur O'Dwyer}
8643894a8a4SArthur O'Dwyer
8653894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG
8663894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare>
8673894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class>
8683894a8a4SArthur O'Dwyerinline
8693894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue(
8703894a8a4SArthur O'Dwyer        _InputIter __f, _InputIter __l, const value_compare& __comp,
8713894a8a4SArthur O'Dwyer        container_type&& __c, const _Alloc& __a,
872b4e88d4dSLouis Dionne        __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
8733894a8a4SArthur O'Dwyer    : c(_VSTD::move(__c), __a),
8743894a8a4SArthur O'Dwyer      comp(__comp)
8753894a8a4SArthur O'Dwyer{
8763894a8a4SArthur O'Dwyer    c.insert(c.end(), __f, __l);
8773894a8a4SArthur O'Dwyer    _VSTD::make_heap(c.begin(), c.end(), comp);
8783894a8a4SArthur O'Dwyer}
879f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
8803e519524SHoward Hinnant
8813e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
882cd31b434SEvgeniy Stepanovinline
8833e519524SHoward Hinnantvoid
8843e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
8853e519524SHoward Hinnant{
8863e519524SHoward Hinnant    c.push_back(__v);
887ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
8883e519524SHoward Hinnant}
8893e519524SHoward Hinnant
890f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
8913e519524SHoward Hinnant
8923e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
893cd31b434SEvgeniy Stepanovinline
8943e519524SHoward Hinnantvoid
8953e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
8963e519524SHoward Hinnant{
897ce48a113SHoward Hinnant    c.push_back(_VSTD::move(__v));
898ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
8993e519524SHoward Hinnant}
9003e519524SHoward Hinnant
9013e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
9023e519524SHoward Hinnanttemplate <class... _Args>
903cd31b434SEvgeniy Stepanovinline
9043e519524SHoward Hinnantvoid
9053e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
9063e519524SHoward Hinnant{
907ce48a113SHoward Hinnant    c.emplace_back(_VSTD::forward<_Args>(__args)...);
908ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
9093e519524SHoward Hinnant}
9103e519524SHoward Hinnant
911f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG
9123e519524SHoward Hinnant
9133e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
914cd31b434SEvgeniy Stepanovinline
9153e519524SHoward Hinnantvoid
9163e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop()
9173e519524SHoward Hinnant{
918ce48a113SHoward Hinnant    _VSTD::pop_heap(c.begin(), c.end(), comp);
9193e519524SHoward Hinnant    c.pop_back();
9203e519524SHoward Hinnant}
9213e519524SHoward Hinnant
9223e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
923cd31b434SEvgeniy Stepanovinline
9243e519524SHoward Hinnantvoid
9253e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
9266971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
9276971d826SHoward Hinnant                   __is_nothrow_swappable<value_compare>::value)
9283e519524SHoward Hinnant{
929ce48a113SHoward Hinnant    using _VSTD::swap;
9303e519524SHoward Hinnant    swap(c, __q.c);
9313e519524SHoward Hinnant    swap(comp, __q.comp);
9323e519524SHoward Hinnant}
9333e519524SHoward Hinnant
9343e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
935392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
936b4e88d4dSLouis Dionne__enable_if_t<
937199d2ebeSArthur O'Dwyer    __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
9383e519524SHoward Hinnant    void
939199d2ebeSArthur O'Dwyer>
9403e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x,
9413e519524SHoward Hinnant     priority_queue<_Tp, _Container, _Compare>& __y)
9426971d826SHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
9433e519524SHoward Hinnant{
9443e519524SHoward Hinnant    __x.swap(__y);
9453e519524SHoward Hinnant}
9463e519524SHoward Hinnant
9473e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc>
948e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
9493e519524SHoward Hinnant    : public uses_allocator<_Container, _Alloc>
9503e519524SHoward Hinnant{
9513e519524SHoward Hinnant};
9523e519524SHoward Hinnant
9533e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD
9543e519524SHoward Hinnant
9553e519524SHoward Hinnant#endif // _LIBCPP_QUEUE
956