xref: /llvm-project-15.0.7/libcxx/include/queue (revision a11f8b1a)
13e519524SHoward Hinnant// -*- C++ -*-
23e519524SHoward Hinnant//===--------------------------- queue ------------------------------------===//
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)
443e519524SHoward Hinnant    template <class Alloc>
453e519524SHoward Hinnant        explicit queue(const Alloc& a);
463e519524SHoward Hinnant    template <class Alloc>
473e519524SHoward Hinnant        queue(const container_type& c, const Alloc& a);
483e519524SHoward Hinnant    template <class Alloc>
493e519524SHoward Hinnant        queue(container_type&& c, const Alloc& a);
503e519524SHoward Hinnant    template <class Alloc>
516971d826SHoward Hinnant        queue(const queue& q, const Alloc& a);
526971d826SHoward Hinnant    template <class Alloc>
533e519524SHoward Hinnant        queue(queue&& q, const Alloc& a);
543e519524SHoward Hinnant
553e519524SHoward Hinnant    bool      empty() const;
563e519524SHoward Hinnant    size_type size() const;
573e519524SHoward Hinnant
583e519524SHoward Hinnant    reference       front();
593e519524SHoward Hinnant    const_reference front() const;
603e519524SHoward Hinnant    reference       back();
613e519524SHoward Hinnant    const_reference back() const;
623e519524SHoward Hinnant
633e519524SHoward Hinnant    void push(const value_type& v);
643e519524SHoward Hinnant    void push(value_type&& v);
6563b560beSMarshall Clow    template <class... Args> reference emplace(Args&&... args); // reference in C++17
663e519524SHoward Hinnant    void pop();
673e519524SHoward Hinnant
68f07dd8d0SEric Fiselier    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
693e519524SHoward Hinnant};
703e519524SHoward Hinnant
715b8b8b5dSMarshall Clowtemplate<class Container>
725b8b8b5dSMarshall Clow  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
735b8b8b5dSMarshall Clow
745b8b8b5dSMarshall Clowtemplate<class Container, class Allocator>
755b8b8b5dSMarshall Clow  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
765b8b8b5dSMarshall Clow
773e519524SHoward Hinnanttemplate <class T, class Container>
783e519524SHoward Hinnant  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
793e519524SHoward Hinnant
803e519524SHoward Hinnanttemplate <class T, class Container>
813e519524SHoward Hinnant  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
823e519524SHoward Hinnant
833e519524SHoward Hinnanttemplate <class T, class Container>
843e519524SHoward Hinnant  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
853e519524SHoward Hinnant
863e519524SHoward Hinnanttemplate <class T, class Container>
873e519524SHoward Hinnant  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
883e519524SHoward Hinnant
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>
966971d826SHoward Hinnant  void swap(queue<T, Container>& x, queue<T, Container>& y)
976971d826SHoward Hinnant  noexcept(noexcept(x.swap(y)));
983e519524SHoward Hinnant
993e519524SHoward Hinnanttemplate <class T, class Container = vector<T>,
1003e519524SHoward Hinnant          class Compare = less<typename Container::value_type>>
1013e519524SHoward Hinnantclass priority_queue
1023e519524SHoward Hinnant{
1033e519524SHoward Hinnantpublic:
1043e519524SHoward Hinnant    typedef Container                                container_type;
1053e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
1063e519524SHoward Hinnant    typedef typename container_type::reference       reference;
1073e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
1083e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
1093e519524SHoward Hinnant
1103e519524SHoward Hinnantprotected:
1113e519524SHoward Hinnant    container_type c;
1123e519524SHoward Hinnant    Compare comp;
1133e519524SHoward Hinnant
1143e519524SHoward Hinnantpublic:
115*a11f8b1aSMarek Kurdej    priority_queue() : priority_queue(Compare()) {} // C++20
116*a11f8b1aSMarek Kurdej    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
117*a11f8b1aSMarek Kurdej    priority_queue(const Compare& x, const Container&);
118*a11f8b1aSMarek Kurdej    explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20
119*a11f8b1aSMarek Kurdej    priority_queue(const Compare& x, Container&&); // C++20
1203e519524SHoward Hinnant    template <class InputIterator>
1213e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1223e519524SHoward Hinnant                       const Compare& comp = Compare());
1233e519524SHoward Hinnant    template <class InputIterator>
1243e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1253e519524SHoward Hinnant                       const Compare& comp, const container_type& c);
1263e519524SHoward Hinnant    template <class InputIterator>
1273e519524SHoward Hinnant        priority_queue(InputIterator first, InputIterator last,
1283e519524SHoward Hinnant                       const Compare& comp, container_type&& c);
1293e519524SHoward Hinnant    template <class Alloc>
1303e519524SHoward Hinnant        explicit priority_queue(const Alloc& a);
1313e519524SHoward Hinnant    template <class Alloc>
1323e519524SHoward Hinnant        priority_queue(const Compare& comp, const Alloc& a);
1333e519524SHoward Hinnant    template <class Alloc>
1343e519524SHoward Hinnant        priority_queue(const Compare& comp, const container_type& c,
1353e519524SHoward Hinnant                       const Alloc& a);
1363e519524SHoward Hinnant    template <class Alloc>
1373e519524SHoward Hinnant        priority_queue(const Compare& comp, container_type&& c,
1383e519524SHoward Hinnant                       const Alloc& a);
1393e519524SHoward Hinnant    template <class Alloc>
1406971d826SHoward Hinnant        priority_queue(const priority_queue& q, const Alloc& a);
1416971d826SHoward Hinnant    template <class Alloc>
1423e519524SHoward Hinnant        priority_queue(priority_queue&& q, const Alloc& a);
1433e519524SHoward Hinnant
1443e519524SHoward Hinnant    bool            empty() const;
1453e519524SHoward Hinnant    size_type       size() const;
1463e519524SHoward Hinnant    const_reference top() const;
1473e519524SHoward Hinnant
1483e519524SHoward Hinnant    void push(const value_type& v);
1493e519524SHoward Hinnant    void push(value_type&& v);
1503e519524SHoward Hinnant    template <class... Args> void emplace(Args&&... args);
1513e519524SHoward Hinnant    void pop();
1523e519524SHoward Hinnant
1536971d826SHoward Hinnant    void swap(priority_queue& q)
154f07dd8d0SEric Fiselier        noexcept(is_nothrow_swappable_v<Container> &&
155f07dd8d0SEric Fiselier                 is_nothrow_swappable_v<Comp>)
1563e519524SHoward Hinnant};
1573e519524SHoward Hinnant
1585b8b8b5dSMarshall Clowtemplate <class Compare, class Container>
1595b8b8b5dSMarshall Clowpriority_queue(Compare, Container)
1605b8b8b5dSMarshall Clow    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1615b8b8b5dSMarshall Clow
1625b8b8b5dSMarshall Clowtemplate<class InputIterator,
1635b8b8b5dSMarshall Clow         class Compare = less<typename iterator_traits<InputIterator>::value_type>,
1645b8b8b5dSMarshall Clow         class Container = vector<typename iterator_traits<InputIterator>::value_type>>
1655b8b8b5dSMarshall Clowpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
1665b8b8b5dSMarshall Clow    -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
1675b8b8b5dSMarshall Clow
1685b8b8b5dSMarshall Clowtemplate<class Compare, class Container, class Allocator>
1695b8b8b5dSMarshall Clowpriority_queue(Compare, Container, Allocator)
1705b8b8b5dSMarshall Clow    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1715b8b8b5dSMarshall Clow
1723e519524SHoward Hinnanttemplate <class T, class Container, class Compare>
1733e519524SHoward Hinnant  void swap(priority_queue<T, Container, Compare>& x,
1746971d826SHoward Hinnant            priority_queue<T, Container, Compare>& y)
1756971d826SHoward Hinnant            noexcept(noexcept(x.swap(y)));
1763e519524SHoward Hinnant
1773e519524SHoward Hinnant}  // std
1783e519524SHoward Hinnant
1793e519524SHoward Hinnant*/
1803e519524SHoward Hinnant
1813e519524SHoward Hinnant#include <__config>
1823e519524SHoward Hinnant#include <deque>
1833e519524SHoward Hinnant#include <vector>
1843e519524SHoward Hinnant#include <functional>
1853e519524SHoward Hinnant#include <algorithm>
1863e519524SHoward Hinnant
187073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1883e519524SHoward Hinnant#pragma GCC system_header
189073458b1SHoward Hinnant#endif
1903e519524SHoward Hinnant
1913e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD
1923e519524SHoward Hinnant
193e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
1943e519524SHoward Hinnant
1953e519524SHoward Hinnanttemplate <class _Tp, class _Container>
196aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
1973e519524SHoward Hinnantbool
1983e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
1993e519524SHoward Hinnant
2003e519524SHoward Hinnanttemplate <class _Tp, class _Container>
201aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY
2023e519524SHoward Hinnantbool
2033e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2043e519524SHoward Hinnant
2053afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/>
206e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue
2073e519524SHoward Hinnant{
2083e519524SHoward Hinnantpublic:
2093e519524SHoward Hinnant    typedef _Container                               container_type;
2103e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
2113e519524SHoward Hinnant    typedef typename container_type::reference       reference;
2123e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
2133e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
214c1fe2c43SMarshall Clow    static_assert((is_same<_Tp, value_type>::value), "" );
2153e519524SHoward Hinnant
2163e519524SHoward Hinnantprotected:
2173e519524SHoward Hinnant    container_type c;
2183e519524SHoward Hinnant
2193e519524SHoward Hinnantpublic:
220392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2216971d826SHoward Hinnant    queue()
2226971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2236971d826SHoward Hinnant        : c() {}
2246971d826SHoward Hinnant
2256971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2266971d826SHoward Hinnant    queue(const queue& __q) : c(__q.c) {}
2276971d826SHoward Hinnant
228f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
229f5427b26SEric Fiselier    queue& operator=(const queue& __q) {c = __q.c; return *this;}
230f5427b26SEric Fiselier
231f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
2326971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2336971d826SHoward Hinnant    queue(queue&& __q)
2346971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
235ce48a113SHoward Hinnant        : c(_VSTD::move(__q.c)) {}
2366971d826SHoward Hinnant
2376971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2386971d826SHoward Hinnant    queue& operator=(queue&& __q)
2396971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
240ce48a113SHoward Hinnant        {c = _VSTD::move(__q.c); return *this;}
241f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
2426971d826SHoward Hinnant
243392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2443e519524SHoward Hinnant    explicit queue(const container_type& __c)  : c(__c) {}
245f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
246392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
247ce48a113SHoward Hinnant    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
248f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
2493e519524SHoward Hinnant    template <class _Alloc>
250392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2513e519524SHoward Hinnant        explicit queue(const _Alloc& __a,
2523e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
2533e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0)
2543e519524SHoward Hinnant            : c(__a) {}
2553e519524SHoward Hinnant    template <class _Alloc>
256392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2573e519524SHoward Hinnant        queue(const queue& __q, const _Alloc& __a,
2583e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
2593e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0)
2603e519524SHoward Hinnant            : c(__q.c, __a) {}
2613e519524SHoward Hinnant    template <class _Alloc>
262392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2633e519524SHoward Hinnant        queue(const container_type& __c, const _Alloc& __a,
2643e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
2653e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0)
2663e519524SHoward Hinnant            : c(__c, __a) {}
267f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
2683e519524SHoward Hinnant    template <class _Alloc>
269392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2703e519524SHoward Hinnant        queue(container_type&& __c, const _Alloc& __a,
2713e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
2723e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0)
273ce48a113SHoward Hinnant            : c(_VSTD::move(__c), __a) {}
2743e519524SHoward Hinnant    template <class _Alloc>
275392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
2763e519524SHoward Hinnant        queue(queue&& __q, const _Alloc& __a,
2773e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
2783e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0)
279ce48a113SHoward Hinnant            : c(_VSTD::move(__q.c), __a) {}
2803e519524SHoward Hinnant
281f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
2823e519524SHoward Hinnant
28372c8fad4SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
2843e519524SHoward Hinnant    bool      empty() const {return c.empty();}
285392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2863e519524SHoward Hinnant    size_type size() const  {return c.size();}
2873e519524SHoward Hinnant
288392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2893e519524SHoward Hinnant    reference       front()       {return c.front();}
290392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2913e519524SHoward Hinnant    const_reference front() const {return c.front();}
292392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2933e519524SHoward Hinnant    reference       back()        {return c.back();}
294392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2953e519524SHoward Hinnant    const_reference back() const  {return c.back();}
2963e519524SHoward Hinnant
297392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
2983e519524SHoward Hinnant    void push(const value_type& __v) {c.push_back(__v);}
299f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
300392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
301ce48a113SHoward Hinnant    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3023e519524SHoward Hinnant    template <class... _Args>
303392183f9SHoward Hinnant        _LIBCPP_INLINE_VISIBILITY
30463b560beSMarshall Clow#if _LIBCPP_STD_VER > 14
305e34f5ffeSMarshall Clow        decltype(auto) emplace(_Args&&... __args)
3060e411641SEric Fiselier            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
30763b560beSMarshall Clow#else
30863b560beSMarshall Clow        void     emplace(_Args&&... __args)
30963b560beSMarshall Clow            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
31063b560beSMarshall Clow#endif
311f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
312392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3133e519524SHoward Hinnant    void pop() {c.pop_front();}
3143e519524SHoward Hinnant
315392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3163e519524SHoward Hinnant    void swap(queue& __q)
3176971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3183e519524SHoward Hinnant    {
319ce48a113SHoward Hinnant        using _VSTD::swap;
3203e519524SHoward Hinnant        swap(c, __q.c);
3213e519524SHoward Hinnant    }
3223e519524SHoward Hinnant
3233e519524SHoward Hinnant    template <class _T1, class _C1>
3243e519524SHoward Hinnant    friend
325392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3263e519524SHoward Hinnant    bool
3273e519524SHoward Hinnant    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3283e519524SHoward Hinnant
3293e519524SHoward Hinnant    template <class _T1, class _C1>
3303e519524SHoward Hinnant    friend
331392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
3323e519524SHoward Hinnant    bool
3333e519524SHoward Hinnant    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3343e519524SHoward Hinnant};
3353e519524SHoward Hinnant
3365b8b8b5dSMarshall Clow#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
3375b8b8b5dSMarshall Clowtemplate<class _Container,
3385b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
3395b8b8b5dSMarshall Clow>
3405b8b8b5dSMarshall Clowqueue(_Container)
3415b8b8b5dSMarshall Clow    -> queue<typename _Container::value_type, _Container>;
3425b8b8b5dSMarshall Clow
3435b8b8b5dSMarshall Clowtemplate<class _Container,
3445b8b8b5dSMarshall Clow         class _Alloc,
3455b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
3465b8b8b5dSMarshall Clow         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
3475b8b8b5dSMarshall Clow>
3485b8b8b5dSMarshall Clowqueue(_Container, _Alloc)
3495b8b8b5dSMarshall Clow    -> queue<typename _Container::value_type, _Container>;
3505b8b8b5dSMarshall Clow#endif
3515b8b8b5dSMarshall Clow
3523e519524SHoward Hinnanttemplate <class _Tp, class _Container>
353392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3543e519524SHoward Hinnantbool
3553e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3563e519524SHoward Hinnant{
3573e519524SHoward Hinnant    return __x.c == __y.c;
3583e519524SHoward Hinnant}
3593e519524SHoward Hinnant
3603e519524SHoward Hinnanttemplate <class _Tp, class _Container>
361392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3623e519524SHoward Hinnantbool
3633e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3643e519524SHoward Hinnant{
3653e519524SHoward Hinnant    return __x.c < __y.c;
3663e519524SHoward Hinnant}
3673e519524SHoward Hinnant
3683e519524SHoward Hinnanttemplate <class _Tp, class _Container>
369392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3703e519524SHoward Hinnantbool
3713e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3723e519524SHoward Hinnant{
3733e519524SHoward Hinnant    return !(__x == __y);
3743e519524SHoward Hinnant}
3753e519524SHoward Hinnant
3763e519524SHoward Hinnanttemplate <class _Tp, class _Container>
377392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3783e519524SHoward Hinnantbool
3793e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3803e519524SHoward Hinnant{
3813e519524SHoward Hinnant    return __y < __x;
3823e519524SHoward Hinnant}
3833e519524SHoward Hinnant
3843e519524SHoward Hinnanttemplate <class _Tp, class _Container>
385392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3863e519524SHoward Hinnantbool
3873e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3883e519524SHoward Hinnant{
3893e519524SHoward Hinnant    return !(__x < __y);
3903e519524SHoward Hinnant}
3913e519524SHoward Hinnant
3923e519524SHoward Hinnanttemplate <class _Tp, class _Container>
393392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
3943e519524SHoward Hinnantbool
3953e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3963e519524SHoward Hinnant{
3973e519524SHoward Hinnant    return !(__y < __x);
3983e519524SHoward Hinnant}
3993e519524SHoward Hinnant
4003e519524SHoward Hinnanttemplate <class _Tp, class _Container>
401392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
402f07dd8d0SEric Fiseliertypename enable_if<
403f07dd8d0SEric Fiselier    __is_swappable<_Container>::value,
4043e519524SHoward Hinnant    void
405f07dd8d0SEric Fiselier>::type
4063e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4076971d826SHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4083e519524SHoward Hinnant{
4093e519524SHoward Hinnant    __x.swap(__y);
4103e519524SHoward Hinnant}
4113e519524SHoward Hinnant
4123e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc>
413e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4143e519524SHoward Hinnant    : public uses_allocator<_Container, _Alloc>
4153e519524SHoward Hinnant{
4163e519524SHoward Hinnant};
4173e519524SHoward Hinnant
4183e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>,
4193e519524SHoward Hinnant          class _Compare = less<typename _Container::value_type> >
420e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue
4213e519524SHoward Hinnant{
4223e519524SHoward Hinnantpublic:
4233e519524SHoward Hinnant    typedef _Container                               container_type;
4243e519524SHoward Hinnant    typedef _Compare                                 value_compare;
4253e519524SHoward Hinnant    typedef typename container_type::value_type      value_type;
4263e519524SHoward Hinnant    typedef typename container_type::reference       reference;
4273e519524SHoward Hinnant    typedef typename container_type::const_reference const_reference;
4283e519524SHoward Hinnant    typedef typename container_type::size_type       size_type;
429c1fe2c43SMarshall Clow    static_assert((is_same<_Tp, value_type>::value), "" );
4303e519524SHoward Hinnant
4313e519524SHoward Hinnantprotected:
4323e519524SHoward Hinnant    container_type c;
4333e519524SHoward Hinnant    value_compare comp;
4343e519524SHoward Hinnant
4353e519524SHoward Hinnantpublic:
436392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4376971d826SHoward Hinnant    priority_queue()
4386971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
4396971d826SHoward Hinnant                   is_nothrow_default_constructible<value_compare>::value)
4406971d826SHoward Hinnant        : c(), comp() {}
4416971d826SHoward Hinnant
4426971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4436971d826SHoward Hinnant    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
4446971d826SHoward Hinnant
445f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
446f5427b26SEric Fiselier    priority_queue& operator=(const priority_queue& __q)
447f5427b26SEric Fiselier        {c = __q.c; comp = __q.comp; return *this;}
448f5427b26SEric Fiselier
449f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
4506971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4516971d826SHoward Hinnant    priority_queue(priority_queue&& __q)
4526971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
4536971d826SHoward Hinnant                   is_nothrow_move_constructible<value_compare>::value)
454ce48a113SHoward Hinnant        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
4556971d826SHoward Hinnant
4566971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4576971d826SHoward Hinnant    priority_queue& operator=(priority_queue&& __q)
4586971d826SHoward Hinnant        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
4596971d826SHoward Hinnant                   is_nothrow_move_assignable<value_compare>::value)
460ce48a113SHoward Hinnant        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
461f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
4626971d826SHoward Hinnant
4636971d826SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
4646971d826SHoward Hinnant    explicit priority_queue(const value_compare& __comp)
4653e519524SHoward Hinnant        : c(), comp(__comp) {}
466cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
4673e519524SHoward Hinnant    priority_queue(const value_compare& __comp, const container_type& __c);
468f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
469cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
470*a11f8b1aSMarek Kurdej    priority_queue(const value_compare& __comp, container_type&& __c);
4713e519524SHoward Hinnant#endif
4723e519524SHoward Hinnant    template <class _InputIter>
473cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4743e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
4753e519524SHoward Hinnant                       const value_compare& __comp = value_compare());
4763e519524SHoward Hinnant    template <class _InputIter>
477cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4783e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
4793e519524SHoward Hinnant                       const value_compare& __comp, const container_type& __c);
480f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
4813e519524SHoward Hinnant    template <class _InputIter>
482cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4833e519524SHoward Hinnant        priority_queue(_InputIter __f, _InputIter __l,
4843e519524SHoward Hinnant                       const value_compare& __comp, container_type&& __c);
485f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
4863e519524SHoward Hinnant    template <class _Alloc>
487cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4883e519524SHoward Hinnant        explicit priority_queue(const _Alloc& __a,
4893e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
4903e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
4913e519524SHoward Hinnant    template <class _Alloc>
492cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4933e519524SHoward Hinnant        priority_queue(const value_compare& __comp, const _Alloc& __a,
4943e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
4953e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
4963e519524SHoward Hinnant    template <class _Alloc>
497cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
4983e519524SHoward Hinnant        priority_queue(const value_compare& __comp, const container_type& __c,
4993e519524SHoward Hinnant                       const _Alloc& __a,
5003e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
5013e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
5023e519524SHoward Hinnant    template <class _Alloc>
503cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5043e519524SHoward Hinnant        priority_queue(const priority_queue& __q, const _Alloc& __a,
5053e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
5063e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
507f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
5083e519524SHoward Hinnant    template <class _Alloc>
509cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5103e519524SHoward Hinnant        priority_queue(const value_compare& __comp, container_type&& __c,
5113e519524SHoward Hinnant                       const _Alloc& __a,
5123e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
5133e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
5143e519524SHoward Hinnant    template <class _Alloc>
515cd31b434SEvgeniy Stepanov        _LIBCPP_INLINE_VISIBILITY
5163e519524SHoward Hinnant        priority_queue(priority_queue&& __q, const _Alloc& __a,
5173e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
5183e519524SHoward Hinnant                                                         _Alloc>::value>::type* = 0);
519f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
5203e519524SHoward Hinnant
52172c8fad4SMarshall Clow    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5223e519524SHoward Hinnant    bool            empty() const {return c.empty();}
523392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5243e519524SHoward Hinnant    size_type       size() const  {return c.size();}
525392183f9SHoward Hinnant    _LIBCPP_INLINE_VISIBILITY
5263e519524SHoward Hinnant    const_reference top() const   {return c.front();}
5273e519524SHoward Hinnant
528cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
5293e519524SHoward Hinnant    void push(const value_type& __v);
530f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
531cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
5323e519524SHoward Hinnant    void push(value_type&& __v);
533f5427b26SEric Fiselier    template <class... _Args>
534f5427b26SEric Fiselier    _LIBCPP_INLINE_VISIBILITY
535f5427b26SEric Fiselier    void emplace(_Args&&... __args);
536f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
537cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
5383e519524SHoward Hinnant    void pop();
5393e519524SHoward Hinnant
540cd31b434SEvgeniy Stepanov    _LIBCPP_INLINE_VISIBILITY
5416971d826SHoward Hinnant    void swap(priority_queue& __q)
5426971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
5436971d826SHoward Hinnant                   __is_nothrow_swappable<value_compare>::value);
5443e519524SHoward Hinnant};
5453e519524SHoward Hinnant
5465b8b8b5dSMarshall Clow#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
5475b8b8b5dSMarshall Clowtemplate <class _Compare,
5485b8b8b5dSMarshall Clow          class _Container,
5495b8b8b5dSMarshall Clow          class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5505b8b8b5dSMarshall Clow          class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
5515b8b8b5dSMarshall Clow>
5525b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container)
5535b8b8b5dSMarshall Clow    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5545b8b8b5dSMarshall Clow
5555b8b8b5dSMarshall Clowtemplate<class _InputIterator,
5565b8b8b5dSMarshall Clow         class _Compare   = less<typename iterator_traits<_InputIterator>::value_type>,
5575b8b8b5dSMarshall Clow         class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
558f82dba01SEric Fiselier         class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,
5595b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5605b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
5615b8b8b5dSMarshall Clow>
5625b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
5635b8b8b5dSMarshall Clow    -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
5645b8b8b5dSMarshall Clow
5655b8b8b5dSMarshall Clowtemplate<class _Compare,
5665b8b8b5dSMarshall Clow         class _Container,
5675b8b8b5dSMarshall Clow         class _Alloc,
5685b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5695b8b8b5dSMarshall Clow         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
5705b8b8b5dSMarshall Clow         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
5715b8b8b5dSMarshall Clow>
5725b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc)
5735b8b8b5dSMarshall Clow    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5745b8b8b5dSMarshall Clow#endif
5755b8b8b5dSMarshall Clow
5763e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
577cd31b434SEvgeniy Stepanovinline
5783e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
5793e519524SHoward Hinnant                                                          const container_type& __c)
5803e519524SHoward Hinnant    : c(__c),
5813e519524SHoward Hinnant      comp(__comp)
5823e519524SHoward Hinnant{
583ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
5843e519524SHoward Hinnant}
5853e519524SHoward Hinnant
586f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
5873e519524SHoward Hinnant
5883e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
589cd31b434SEvgeniy Stepanovinline
5903e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
5913e519524SHoward Hinnant                                                          container_type&& __c)
592ce48a113SHoward Hinnant    : c(_VSTD::move(__c)),
5933e519524SHoward Hinnant      comp(__comp)
5943e519524SHoward Hinnant{
595ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
5963e519524SHoward Hinnant}
5973e519524SHoward Hinnant
598f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
5993e519524SHoward Hinnant
6003e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6013e519524SHoward Hinnanttemplate <class _InputIter>
602cd31b434SEvgeniy Stepanovinline
6033e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6043e519524SHoward Hinnant                                                          const value_compare& __comp)
6053e519524SHoward Hinnant    : c(__f, __l),
6063e519524SHoward Hinnant      comp(__comp)
6073e519524SHoward Hinnant{
608ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6093e519524SHoward Hinnant}
6103e519524SHoward Hinnant
6113e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6123e519524SHoward Hinnanttemplate <class _InputIter>
613cd31b434SEvgeniy Stepanovinline
6143e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6153e519524SHoward Hinnant                                                          const value_compare& __comp,
6163e519524SHoward Hinnant                                                          const container_type& __c)
6173e519524SHoward Hinnant    : c(__c),
6183e519524SHoward Hinnant      comp(__comp)
6193e519524SHoward Hinnant{
6203e519524SHoward Hinnant    c.insert(c.end(), __f, __l);
621ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6223e519524SHoward Hinnant}
6233e519524SHoward Hinnant
624f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
6253e519524SHoward Hinnant
6263e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6273e519524SHoward Hinnanttemplate <class _InputIter>
628cd31b434SEvgeniy Stepanovinline
6293e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6303e519524SHoward Hinnant                                                          const value_compare& __comp,
6313e519524SHoward Hinnant                                                          container_type&& __c)
632ce48a113SHoward Hinnant    : c(_VSTD::move(__c)),
6333e519524SHoward Hinnant      comp(__comp)
6343e519524SHoward Hinnant{
6353e519524SHoward Hinnant    c.insert(c.end(), __f, __l);
636ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6373e519524SHoward Hinnant}
6383e519524SHoward Hinnant
639f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
6403e519524SHoward Hinnant
6413e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6423e519524SHoward Hinnanttemplate <class _Alloc>
643cd31b434SEvgeniy Stepanovinline
6443e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
6453e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
6463e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
6473e519524SHoward Hinnant    : c(__a)
6483e519524SHoward Hinnant{
6493e519524SHoward Hinnant}
6503e519524SHoward Hinnant
6513e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6523e519524SHoward Hinnanttemplate <class _Alloc>
653cd31b434SEvgeniy Stepanovinline
6543e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6553e519524SHoward Hinnant                                                          const _Alloc& __a,
6563e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
6573e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
6583e519524SHoward Hinnant    : c(__a),
6593e519524SHoward Hinnant      comp(__comp)
6603e519524SHoward Hinnant{
6613e519524SHoward Hinnant}
6623e519524SHoward Hinnant
6633e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6643e519524SHoward Hinnanttemplate <class _Alloc>
665cd31b434SEvgeniy Stepanovinline
6663e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6673e519524SHoward Hinnant                                                          const container_type& __c,
6683e519524SHoward Hinnant                                                          const _Alloc& __a,
6693e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
6703e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
6713e519524SHoward Hinnant    : c(__c, __a),
6723e519524SHoward Hinnant      comp(__comp)
6733e519524SHoward Hinnant{
674ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6753e519524SHoward Hinnant}
6763e519524SHoward Hinnant
6773e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6783e519524SHoward Hinnanttemplate <class _Alloc>
679cd31b434SEvgeniy Stepanovinline
6803e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
6813e519524SHoward Hinnant                                                          const _Alloc& __a,
6823e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
6833e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
6843e519524SHoward Hinnant    : c(__q.c, __a),
6853e519524SHoward Hinnant      comp(__q.comp)
6863e519524SHoward Hinnant{
687ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
6883e519524SHoward Hinnant}
6893e519524SHoward Hinnant
690f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
6913e519524SHoward Hinnant
6923e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
6933e519524SHoward Hinnanttemplate <class _Alloc>
694cd31b434SEvgeniy Stepanovinline
6953e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6963e519524SHoward Hinnant                                                          container_type&& __c,
6973e519524SHoward Hinnant                                                          const _Alloc& __a,
6983e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
6993e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
700ce48a113SHoward Hinnant    : c(_VSTD::move(__c), __a),
7013e519524SHoward Hinnant      comp(__comp)
7023e519524SHoward Hinnant{
703ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7043e519524SHoward Hinnant}
7053e519524SHoward Hinnant
7063e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7073e519524SHoward Hinnanttemplate <class _Alloc>
708cd31b434SEvgeniy Stepanovinline
7093e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
7103e519524SHoward Hinnant                                                          const _Alloc& __a,
7113e519524SHoward Hinnant                       typename enable_if<uses_allocator<container_type,
7123e519524SHoward Hinnant                                                         _Alloc>::value>::type*)
713ce48a113SHoward Hinnant    : c(_VSTD::move(__q.c), __a),
714ce48a113SHoward Hinnant      comp(_VSTD::move(__q.comp))
7153e519524SHoward Hinnant{
716ce48a113SHoward Hinnant    _VSTD::make_heap(c.begin(), c.end(), comp);
7173e519524SHoward Hinnant}
7183e519524SHoward Hinnant
719f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
7203e519524SHoward Hinnant
7213e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
722cd31b434SEvgeniy Stepanovinline
7233e519524SHoward Hinnantvoid
7243e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
7253e519524SHoward Hinnant{
7263e519524SHoward Hinnant    c.push_back(__v);
727ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
7283e519524SHoward Hinnant}
7293e519524SHoward Hinnant
730f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG
7313e519524SHoward Hinnant
7323e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
733cd31b434SEvgeniy Stepanovinline
7343e519524SHoward Hinnantvoid
7353e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
7363e519524SHoward Hinnant{
737ce48a113SHoward Hinnant    c.push_back(_VSTD::move(__v));
738ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
7393e519524SHoward Hinnant}
7403e519524SHoward Hinnant
7413e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
7423e519524SHoward Hinnanttemplate <class... _Args>
743cd31b434SEvgeniy Stepanovinline
7443e519524SHoward Hinnantvoid
7453e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
7463e519524SHoward Hinnant{
747ce48a113SHoward Hinnant    c.emplace_back(_VSTD::forward<_Args>(__args)...);
748ce48a113SHoward Hinnant    _VSTD::push_heap(c.begin(), c.end(), comp);
7493e519524SHoward Hinnant}
7503e519524SHoward Hinnant
751f5427b26SEric Fiselier#endif  // _LIBCPP_CXX03_LANG
7523e519524SHoward Hinnant
7533e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
754cd31b434SEvgeniy Stepanovinline
7553e519524SHoward Hinnantvoid
7563e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop()
7573e519524SHoward Hinnant{
758ce48a113SHoward Hinnant    _VSTD::pop_heap(c.begin(), c.end(), comp);
7593e519524SHoward Hinnant    c.pop_back();
7603e519524SHoward Hinnant}
7613e519524SHoward Hinnant
7623e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
763cd31b434SEvgeniy Stepanovinline
7643e519524SHoward Hinnantvoid
7653e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
7666971d826SHoward Hinnant        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
7676971d826SHoward Hinnant                   __is_nothrow_swappable<value_compare>::value)
7683e519524SHoward Hinnant{
769ce48a113SHoward Hinnant    using _VSTD::swap;
7703e519524SHoward Hinnant    swap(c, __q.c);
7713e519524SHoward Hinnant    swap(comp, __q.comp);
7723e519524SHoward Hinnant}
7733e519524SHoward Hinnant
7743e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare>
775392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY
776f07dd8d0SEric Fiseliertypename enable_if<
777f07dd8d0SEric Fiselier    __is_swappable<_Container>::value
778f07dd8d0SEric Fiselier    && __is_swappable<_Compare>::value,
7793e519524SHoward Hinnant    void
780f07dd8d0SEric Fiselier>::type
7813e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x,
7823e519524SHoward Hinnant     priority_queue<_Tp, _Container, _Compare>& __y)
7836971d826SHoward Hinnant    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7843e519524SHoward Hinnant{
7853e519524SHoward Hinnant    __x.swap(__y);
7863e519524SHoward Hinnant}
7873e519524SHoward Hinnant
7883e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc>
789e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
7903e519524SHoward Hinnant    : public uses_allocator<_Container, _Alloc>
7913e519524SHoward Hinnant{
7923e519524SHoward Hinnant};
7933e519524SHoward Hinnant
7943e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD
7953e519524SHoward Hinnant
7963e519524SHoward Hinnant#endif  // _LIBCPP_QUEUE
797