xref: /freebsd/contrib/llvm-project/libcxx/include/queue (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
10b57cec5SDimitry Andric// -*- C++ -*-
20b57cec5SDimitry Andric//===--------------------------- queue ------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_QUEUE
110b57cec5SDimitry Andric#define _LIBCPP_QUEUE
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    queue synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry Andricnamespace std
170b57cec5SDimitry Andric{
180b57cec5SDimitry Andric
190b57cec5SDimitry Andrictemplate <class T, class Container = deque<T>>
200b57cec5SDimitry Andricclass queue
210b57cec5SDimitry Andric{
220b57cec5SDimitry Andricpublic:
230b57cec5SDimitry Andric    typedef Container                                container_type;
240b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
250b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
260b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
270b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
280b57cec5SDimitry Andric
290b57cec5SDimitry Andricprotected:
300b57cec5SDimitry Andric    container_type c;
310b57cec5SDimitry Andric
320b57cec5SDimitry Andricpublic:
330b57cec5SDimitry Andric    queue() = default;
340b57cec5SDimitry Andric    ~queue() = default;
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric    queue(const queue& q) = default;
370b57cec5SDimitry Andric    queue(queue&& q) = default;
380b57cec5SDimitry Andric
390b57cec5SDimitry Andric    queue& operator=(const queue& q) = default;
400b57cec5SDimitry Andric    queue& operator=(queue&& q) = default;
410b57cec5SDimitry Andric
420b57cec5SDimitry Andric    explicit queue(const container_type& c);
430b57cec5SDimitry Andric    explicit queue(container_type&& c)
440b57cec5SDimitry Andric    template <class Alloc>
450b57cec5SDimitry Andric        explicit queue(const Alloc& a);
460b57cec5SDimitry Andric    template <class Alloc>
470b57cec5SDimitry Andric        queue(const container_type& c, const Alloc& a);
480b57cec5SDimitry Andric    template <class Alloc>
490b57cec5SDimitry Andric        queue(container_type&& c, const Alloc& a);
500b57cec5SDimitry Andric    template <class Alloc>
510b57cec5SDimitry Andric        queue(const queue& q, const Alloc& a);
520b57cec5SDimitry Andric    template <class Alloc>
530b57cec5SDimitry Andric        queue(queue&& q, const Alloc& a);
540b57cec5SDimitry Andric
550b57cec5SDimitry Andric    bool      empty() const;
560b57cec5SDimitry Andric    size_type size() const;
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric    reference       front();
590b57cec5SDimitry Andric    const_reference front() const;
600b57cec5SDimitry Andric    reference       back();
610b57cec5SDimitry Andric    const_reference back() const;
620b57cec5SDimitry Andric
630b57cec5SDimitry Andric    void push(const value_type& v);
640b57cec5SDimitry Andric    void push(value_type&& v);
650b57cec5SDimitry Andric    template <class... Args> reference emplace(Args&&... args); // reference in C++17
660b57cec5SDimitry Andric    void pop();
670b57cec5SDimitry Andric
680b57cec5SDimitry Andric    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
690b57cec5SDimitry Andric};
700b57cec5SDimitry Andric
710b57cec5SDimitry Andrictemplate<class Container>
720b57cec5SDimitry Andric  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
730b57cec5SDimitry Andric
740b57cec5SDimitry Andrictemplate<class Container, class Allocator>
750b57cec5SDimitry Andric  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
760b57cec5SDimitry Andric
770b57cec5SDimitry Andrictemplate <class T, class Container>
780b57cec5SDimitry Andric  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
790b57cec5SDimitry Andric
800b57cec5SDimitry Andrictemplate <class T, class Container>
810b57cec5SDimitry Andric  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
820b57cec5SDimitry Andric
830b57cec5SDimitry Andrictemplate <class T, class Container>
840b57cec5SDimitry Andric  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
850b57cec5SDimitry Andric
860b57cec5SDimitry Andrictemplate <class T, class Container>
870b57cec5SDimitry Andric  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
880b57cec5SDimitry Andric
890b57cec5SDimitry Andrictemplate <class T, class Container>
900b57cec5SDimitry Andric  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
910b57cec5SDimitry Andric
920b57cec5SDimitry Andrictemplate <class T, class Container>
930b57cec5SDimitry Andric  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
940b57cec5SDimitry Andric
950b57cec5SDimitry Andrictemplate <class T, class Container>
960b57cec5SDimitry Andric  void swap(queue<T, Container>& x, queue<T, Container>& y)
970b57cec5SDimitry Andric  noexcept(noexcept(x.swap(y)));
980b57cec5SDimitry Andric
990b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>,
1000b57cec5SDimitry Andric          class Compare = less<typename Container::value_type>>
1010b57cec5SDimitry Andricclass priority_queue
1020b57cec5SDimitry Andric{
1030b57cec5SDimitry Andricpublic:
1040b57cec5SDimitry Andric    typedef Container                                container_type;
1050b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
1060b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
1070b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
1080b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
1090b57cec5SDimitry Andric
1100b57cec5SDimitry Andricprotected:
1110b57cec5SDimitry Andric    container_type c;
1120b57cec5SDimitry Andric    Compare comp;
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andricpublic:
115*e8d8bef9SDimitry Andric    priority_queue() : priority_queue(Compare()) {} // C++20
116*e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
117*e8d8bef9SDimitry Andric    priority_queue(const Compare& x, const Container&);
118*e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20
119*e8d8bef9SDimitry Andric    priority_queue(const Compare& x, Container&&); // C++20
1200b57cec5SDimitry Andric    template <class InputIterator>
1210b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
1220b57cec5SDimitry Andric                       const Compare& comp = Compare());
1230b57cec5SDimitry Andric    template <class InputIterator>
1240b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
1250b57cec5SDimitry Andric                       const Compare& comp, const container_type& c);
1260b57cec5SDimitry Andric    template <class InputIterator>
1270b57cec5SDimitry Andric        priority_queue(InputIterator first, InputIterator last,
1280b57cec5SDimitry Andric                       const Compare& comp, container_type&& c);
1290b57cec5SDimitry Andric    template <class Alloc>
1300b57cec5SDimitry Andric        explicit priority_queue(const Alloc& a);
1310b57cec5SDimitry Andric    template <class Alloc>
1320b57cec5SDimitry Andric        priority_queue(const Compare& comp, const Alloc& a);
1330b57cec5SDimitry Andric    template <class Alloc>
1340b57cec5SDimitry Andric        priority_queue(const Compare& comp, const container_type& c,
1350b57cec5SDimitry Andric                       const Alloc& a);
1360b57cec5SDimitry Andric    template <class Alloc>
1370b57cec5SDimitry Andric        priority_queue(const Compare& comp, container_type&& c,
1380b57cec5SDimitry Andric                       const Alloc& a);
1390b57cec5SDimitry Andric    template <class Alloc>
1400b57cec5SDimitry Andric        priority_queue(const priority_queue& q, const Alloc& a);
1410b57cec5SDimitry Andric    template <class Alloc>
1420b57cec5SDimitry Andric        priority_queue(priority_queue&& q, const Alloc& a);
1430b57cec5SDimitry Andric
1440b57cec5SDimitry Andric    bool            empty() const;
1450b57cec5SDimitry Andric    size_type       size() const;
1460b57cec5SDimitry Andric    const_reference top() const;
1470b57cec5SDimitry Andric
1480b57cec5SDimitry Andric    void push(const value_type& v);
1490b57cec5SDimitry Andric    void push(value_type&& v);
1500b57cec5SDimitry Andric    template <class... Args> void emplace(Args&&... args);
1510b57cec5SDimitry Andric    void pop();
1520b57cec5SDimitry Andric
1530b57cec5SDimitry Andric    void swap(priority_queue& q)
1540b57cec5SDimitry Andric        noexcept(is_nothrow_swappable_v<Container> &&
1550b57cec5SDimitry Andric                 is_nothrow_swappable_v<Comp>)
1560b57cec5SDimitry Andric};
1570b57cec5SDimitry Andric
1580b57cec5SDimitry Andrictemplate <class Compare, class Container>
1590b57cec5SDimitry Andricpriority_queue(Compare, Container)
1600b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1610b57cec5SDimitry Andric
1620b57cec5SDimitry Andrictemplate<class InputIterator,
1630b57cec5SDimitry Andric         class Compare = less<typename iterator_traits<InputIterator>::value_type>,
1640b57cec5SDimitry Andric         class Container = vector<typename iterator_traits<InputIterator>::value_type>>
1650b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
1660b57cec5SDimitry Andric    -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator>
1690b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator)
1700b57cec5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
1710b57cec5SDimitry Andric
1720b57cec5SDimitry Andrictemplate <class T, class Container, class Compare>
1730b57cec5SDimitry Andric  void swap(priority_queue<T, Container, Compare>& x,
1740b57cec5SDimitry Andric            priority_queue<T, Container, Compare>& y)
1750b57cec5SDimitry Andric            noexcept(noexcept(x.swap(y)));
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric}  // std
1780b57cec5SDimitry Andric
1790b57cec5SDimitry Andric*/
1800b57cec5SDimitry Andric
1810b57cec5SDimitry Andric#include <__config>
1820b57cec5SDimitry Andric#include <deque>
1830b57cec5SDimitry Andric#include <vector>
1840b57cec5SDimitry Andric#include <functional>
1850b57cec5SDimitry Andric#include <algorithm>
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1880b57cec5SDimitry Andric#pragma GCC system_header
1890b57cec5SDimitry Andric#endif
1900b57cec5SDimitry Andric
1910b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
1920b57cec5SDimitry Andric
1930b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
1960b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
1970b57cec5SDimitry Andricbool
1980b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2010b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2020b57cec5SDimitry Andricbool
2030b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2040b57cec5SDimitry Andric
2050b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
2060b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue
2070b57cec5SDimitry Andric{
2080b57cec5SDimitry Andricpublic:
2090b57cec5SDimitry Andric    typedef _Container                               container_type;
2100b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
2110b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
2120b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
2130b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
2140b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
2150b57cec5SDimitry Andric
2160b57cec5SDimitry Andricprotected:
2170b57cec5SDimitry Andric    container_type c;
2180b57cec5SDimitry Andric
2190b57cec5SDimitry Andricpublic:
2200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2210b57cec5SDimitry Andric    queue()
2220b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2230b57cec5SDimitry Andric        : c() {}
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2260b57cec5SDimitry Andric    queue(const queue& __q) : c(__q.c) {}
2270b57cec5SDimitry Andric
2280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2290b57cec5SDimitry Andric    queue& operator=(const queue& __q) {c = __q.c; return *this;}
2300b57cec5SDimitry Andric
2310b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2320b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2330b57cec5SDimitry Andric    queue(queue&& __q)
2340b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
2350b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)) {}
2360b57cec5SDimitry Andric
2370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2380b57cec5SDimitry Andric    queue& operator=(queue&& __q)
2390b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
2400b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); return *this;}
2410b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2420b57cec5SDimitry Andric
2430b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2440b57cec5SDimitry Andric    explicit queue(const container_type& __c)  : c(__c) {}
2450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2470b57cec5SDimitry Andric    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
2480b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2490b57cec5SDimitry Andric    template <class _Alloc>
2500b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2510b57cec5SDimitry Andric        explicit queue(const _Alloc& __a,
2520b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
2530b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0)
2540b57cec5SDimitry Andric            : c(__a) {}
2550b57cec5SDimitry Andric    template <class _Alloc>
2560b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2570b57cec5SDimitry Andric        queue(const queue& __q, const _Alloc& __a,
2580b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
2590b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0)
2600b57cec5SDimitry Andric            : c(__q.c, __a) {}
2610b57cec5SDimitry Andric    template <class _Alloc>
2620b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2630b57cec5SDimitry Andric        queue(const container_type& __c, const _Alloc& __a,
2640b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
2650b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0)
2660b57cec5SDimitry Andric            : c(__c, __a) {}
2670b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2680b57cec5SDimitry Andric    template <class _Alloc>
2690b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2700b57cec5SDimitry Andric        queue(container_type&& __c, const _Alloc& __a,
2710b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
2720b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0)
2730b57cec5SDimitry Andric            : c(_VSTD::move(__c), __a) {}
2740b57cec5SDimitry Andric    template <class _Alloc>
2750b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2760b57cec5SDimitry Andric        queue(queue&& __q, const _Alloc& __a,
2770b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
2780b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0)
2790b57cec5SDimitry Andric            : c(_VSTD::move(__q.c), __a) {}
2800b57cec5SDimitry Andric
2810b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2820b57cec5SDimitry Andric
2830b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
2840b57cec5SDimitry Andric    bool      empty() const {return c.empty();}
2850b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2860b57cec5SDimitry Andric    size_type size() const  {return c.size();}
2870b57cec5SDimitry Andric
2880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2890b57cec5SDimitry Andric    reference       front()       {return c.front();}
2900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2910b57cec5SDimitry Andric    const_reference front() const {return c.front();}
2920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2930b57cec5SDimitry Andric    reference       back()        {return c.back();}
2940b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2950b57cec5SDimitry Andric    const_reference back() const  {return c.back();}
2960b57cec5SDimitry Andric
2970b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2980b57cec5SDimitry Andric    void push(const value_type& __v) {c.push_back(__v);}
2990b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3000b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3010b57cec5SDimitry Andric    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3020b57cec5SDimitry Andric    template <class... _Args>
3030b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3040b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
3050b57cec5SDimitry Andric        decltype(auto) emplace(_Args&&... __args)
3060b57cec5SDimitry Andric            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3070b57cec5SDimitry Andric#else
3080b57cec5SDimitry Andric        void     emplace(_Args&&... __args)
3090b57cec5SDimitry Andric            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3100b57cec5SDimitry Andric#endif
3110b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
3120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3130b57cec5SDimitry Andric    void pop() {c.pop_front();}
3140b57cec5SDimitry Andric
3150b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3160b57cec5SDimitry Andric    void swap(queue& __q)
3170b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3180b57cec5SDimitry Andric    {
3190b57cec5SDimitry Andric        using _VSTD::swap;
3200b57cec5SDimitry Andric        swap(c, __q.c);
3210b57cec5SDimitry Andric    }
3220b57cec5SDimitry Andric
3230b57cec5SDimitry Andric    template <class _T1, class _C1>
3240b57cec5SDimitry Andric    friend
3250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3260b57cec5SDimitry Andric    bool
3270b57cec5SDimitry Andric    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3280b57cec5SDimitry Andric
3290b57cec5SDimitry Andric    template <class _T1, class _C1>
3300b57cec5SDimitry Andric    friend
3310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3320b57cec5SDimitry Andric    bool
3330b57cec5SDimitry Andric    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3340b57cec5SDimitry Andric};
3350b57cec5SDimitry Andric
3360b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
3370b57cec5SDimitry Andrictemplate<class _Container,
3380b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
3390b57cec5SDimitry Andric>
3400b57cec5SDimitry Andricqueue(_Container)
3410b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andrictemplate<class _Container,
3440b57cec5SDimitry Andric         class _Alloc,
3450b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
3460b57cec5SDimitry Andric         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
3470b57cec5SDimitry Andric>
3480b57cec5SDimitry Andricqueue(_Container, _Alloc)
3490b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
3500b57cec5SDimitry Andric#endif
3510b57cec5SDimitry Andric
3520b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3530b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3540b57cec5SDimitry Andricbool
3550b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3560b57cec5SDimitry Andric{
3570b57cec5SDimitry Andric    return __x.c == __y.c;
3580b57cec5SDimitry Andric}
3590b57cec5SDimitry Andric
3600b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3610b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3620b57cec5SDimitry Andricbool
3630b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3640b57cec5SDimitry Andric{
3650b57cec5SDimitry Andric    return __x.c < __y.c;
3660b57cec5SDimitry Andric}
3670b57cec5SDimitry Andric
3680b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3690b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3700b57cec5SDimitry Andricbool
3710b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3720b57cec5SDimitry Andric{
3730b57cec5SDimitry Andric    return !(__x == __y);
3740b57cec5SDimitry Andric}
3750b57cec5SDimitry Andric
3760b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3770b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3780b57cec5SDimitry Andricbool
3790b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3800b57cec5SDimitry Andric{
3810b57cec5SDimitry Andric    return __y < __x;
3820b57cec5SDimitry Andric}
3830b57cec5SDimitry Andric
3840b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3850b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3860b57cec5SDimitry Andricbool
3870b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3880b57cec5SDimitry Andric{
3890b57cec5SDimitry Andric    return !(__x < __y);
3900b57cec5SDimitry Andric}
3910b57cec5SDimitry Andric
3920b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3930b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3940b57cec5SDimitry Andricbool
3950b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3960b57cec5SDimitry Andric{
3970b57cec5SDimitry Andric    return !(__y < __x);
3980b57cec5SDimitry Andric}
3990b57cec5SDimitry Andric
4000b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
4010b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
4020b57cec5SDimitry Andrictypename enable_if<
4030b57cec5SDimitry Andric    __is_swappable<_Container>::value,
4040b57cec5SDimitry Andric    void
4050b57cec5SDimitry Andric>::type
4060b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4070b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4080b57cec5SDimitry Andric{
4090b57cec5SDimitry Andric    __x.swap(__y);
4100b57cec5SDimitry Andric}
4110b57cec5SDimitry Andric
4120b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
4130b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4140b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
4150b57cec5SDimitry Andric{
4160b57cec5SDimitry Andric};
4170b57cec5SDimitry Andric
4180b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>,
4190b57cec5SDimitry Andric          class _Compare = less<typename _Container::value_type> >
4200b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue
4210b57cec5SDimitry Andric{
4220b57cec5SDimitry Andricpublic:
4230b57cec5SDimitry Andric    typedef _Container                               container_type;
4240b57cec5SDimitry Andric    typedef _Compare                                 value_compare;
4250b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
4260b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
4270b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
4280b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
4290b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
4300b57cec5SDimitry Andric
4310b57cec5SDimitry Andricprotected:
4320b57cec5SDimitry Andric    container_type c;
4330b57cec5SDimitry Andric    value_compare comp;
4340b57cec5SDimitry Andric
4350b57cec5SDimitry Andricpublic:
4360b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4370b57cec5SDimitry Andric    priority_queue()
4380b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
4390b57cec5SDimitry Andric                   is_nothrow_default_constructible<value_compare>::value)
4400b57cec5SDimitry Andric        : c(), comp() {}
4410b57cec5SDimitry Andric
4420b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4430b57cec5SDimitry Andric    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
4440b57cec5SDimitry Andric
4450b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4460b57cec5SDimitry Andric    priority_queue& operator=(const priority_queue& __q)
4470b57cec5SDimitry Andric        {c = __q.c; comp = __q.comp; return *this;}
4480b57cec5SDimitry Andric
4490b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4500b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4510b57cec5SDimitry Andric    priority_queue(priority_queue&& __q)
4520b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
4530b57cec5SDimitry Andric                   is_nothrow_move_constructible<value_compare>::value)
4540b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
4550b57cec5SDimitry Andric
4560b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4570b57cec5SDimitry Andric    priority_queue& operator=(priority_queue&& __q)
4580b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
4590b57cec5SDimitry Andric                   is_nothrow_move_assignable<value_compare>::value)
4600b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
4610b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4620b57cec5SDimitry Andric
4630b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4640b57cec5SDimitry Andric    explicit priority_queue(const value_compare& __comp)
4650b57cec5SDimitry Andric        : c(), comp(__comp) {}
4660b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4670b57cec5SDimitry Andric    priority_queue(const value_compare& __comp, const container_type& __c);
4680b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4690b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
470*e8d8bef9SDimitry Andric    priority_queue(const value_compare& __comp, container_type&& __c);
4710b57cec5SDimitry Andric#endif
4720b57cec5SDimitry Andric    template <class _InputIter>
4730b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4740b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4750b57cec5SDimitry Andric                       const value_compare& __comp = value_compare());
4760b57cec5SDimitry Andric    template <class _InputIter>
4770b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4780b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4790b57cec5SDimitry Andric                       const value_compare& __comp, const container_type& __c);
4800b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4810b57cec5SDimitry Andric    template <class _InputIter>
4820b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4830b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4840b57cec5SDimitry Andric                       const value_compare& __comp, container_type&& __c);
4850b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4860b57cec5SDimitry Andric    template <class _Alloc>
4870b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4880b57cec5SDimitry Andric        explicit priority_queue(const _Alloc& __a,
4890b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
4900b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
4910b57cec5SDimitry Andric    template <class _Alloc>
4920b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4930b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const _Alloc& __a,
4940b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
4950b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
4960b57cec5SDimitry Andric    template <class _Alloc>
4970b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4980b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const container_type& __c,
4990b57cec5SDimitry Andric                       const _Alloc& __a,
5000b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
5010b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
5020b57cec5SDimitry Andric    template <class _Alloc>
5030b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5040b57cec5SDimitry Andric        priority_queue(const priority_queue& __q, const _Alloc& __a,
5050b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
5060b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
5070b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5080b57cec5SDimitry Andric    template <class _Alloc>
5090b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5100b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, container_type&& __c,
5110b57cec5SDimitry Andric                       const _Alloc& __a,
5120b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
5130b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
5140b57cec5SDimitry Andric    template <class _Alloc>
5150b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5160b57cec5SDimitry Andric        priority_queue(priority_queue&& __q, const _Alloc& __a,
5170b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
5180b57cec5SDimitry Andric                                                         _Alloc>::value>::type* = 0);
5190b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5200b57cec5SDimitry Andric
5210b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5220b57cec5SDimitry Andric    bool            empty() const {return c.empty();}
5230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5240b57cec5SDimitry Andric    size_type       size() const  {return c.size();}
5250b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5260b57cec5SDimitry Andric    const_reference top() const   {return c.front();}
5270b57cec5SDimitry Andric
5280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5290b57cec5SDimitry Andric    void push(const value_type& __v);
5300b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5320b57cec5SDimitry Andric    void push(value_type&& __v);
5330b57cec5SDimitry Andric    template <class... _Args>
5340b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5350b57cec5SDimitry Andric    void emplace(_Args&&... __args);
5360b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5380b57cec5SDimitry Andric    void pop();
5390b57cec5SDimitry Andric
5400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5410b57cec5SDimitry Andric    void swap(priority_queue& __q)
5420b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
5430b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value);
5440b57cec5SDimitry Andric};
5450b57cec5SDimitry Andric
5460b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
5470b57cec5SDimitry Andrictemplate <class _Compare,
5480b57cec5SDimitry Andric          class _Container,
5490b57cec5SDimitry Andric          class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5500b57cec5SDimitry Andric          class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
5510b57cec5SDimitry Andric>
5520b57cec5SDimitry Andricpriority_queue(_Compare, _Container)
5530b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5540b57cec5SDimitry Andric
5550b57cec5SDimitry Andrictemplate<class _InputIterator,
5560b57cec5SDimitry Andric         class _Compare   = less<typename iterator_traits<_InputIterator>::value_type>,
5570b57cec5SDimitry Andric         class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
558480093f4SDimitry Andric         class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,
5590b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5600b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
5610b57cec5SDimitry Andric>
5620b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
5630b57cec5SDimitry Andric    -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andrictemplate<class _Compare,
5660b57cec5SDimitry Andric         class _Container,
5670b57cec5SDimitry Andric         class _Alloc,
5680b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
5690b57cec5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
5700b57cec5SDimitry Andric         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
5710b57cec5SDimitry Andric>
5720b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc)
5730b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5740b57cec5SDimitry Andric#endif
5750b57cec5SDimitry Andric
5760b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
5770b57cec5SDimitry Andricinline
5780b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
5790b57cec5SDimitry Andric                                                          const container_type& __c)
5800b57cec5SDimitry Andric    : c(__c),
5810b57cec5SDimitry Andric      comp(__comp)
5820b57cec5SDimitry Andric{
5830b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
5840b57cec5SDimitry Andric}
5850b57cec5SDimitry Andric
5860b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5870b57cec5SDimitry Andric
5880b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
5890b57cec5SDimitry Andricinline
5900b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
5910b57cec5SDimitry Andric                                                          container_type&& __c)
5920b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
5930b57cec5SDimitry Andric      comp(__comp)
5940b57cec5SDimitry Andric{
5950b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
5960b57cec5SDimitry Andric}
5970b57cec5SDimitry Andric
5980b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5990b57cec5SDimitry Andric
6000b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6010b57cec5SDimitry Andrictemplate <class _InputIter>
6020b57cec5SDimitry Andricinline
6030b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6040b57cec5SDimitry Andric                                                          const value_compare& __comp)
6050b57cec5SDimitry Andric    : c(__f, __l),
6060b57cec5SDimitry Andric      comp(__comp)
6070b57cec5SDimitry Andric{
6080b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6090b57cec5SDimitry Andric}
6100b57cec5SDimitry Andric
6110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6120b57cec5SDimitry Andrictemplate <class _InputIter>
6130b57cec5SDimitry Andricinline
6140b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6150b57cec5SDimitry Andric                                                          const value_compare& __comp,
6160b57cec5SDimitry Andric                                                          const container_type& __c)
6170b57cec5SDimitry Andric    : c(__c),
6180b57cec5SDimitry Andric      comp(__comp)
6190b57cec5SDimitry Andric{
6200b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
6210b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6220b57cec5SDimitry Andric}
6230b57cec5SDimitry Andric
6240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6250b57cec5SDimitry Andric
6260b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6270b57cec5SDimitry Andrictemplate <class _InputIter>
6280b57cec5SDimitry Andricinline
6290b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6300b57cec5SDimitry Andric                                                          const value_compare& __comp,
6310b57cec5SDimitry Andric                                                          container_type&& __c)
6320b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
6330b57cec5SDimitry Andric      comp(__comp)
6340b57cec5SDimitry Andric{
6350b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
6360b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6370b57cec5SDimitry Andric}
6380b57cec5SDimitry Andric
6390b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
6400b57cec5SDimitry Andric
6410b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6420b57cec5SDimitry Andrictemplate <class _Alloc>
6430b57cec5SDimitry Andricinline
6440b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
6450b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
6460b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
6470b57cec5SDimitry Andric    : c(__a)
6480b57cec5SDimitry Andric{
6490b57cec5SDimitry Andric}
6500b57cec5SDimitry Andric
6510b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6520b57cec5SDimitry Andrictemplate <class _Alloc>
6530b57cec5SDimitry Andricinline
6540b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6550b57cec5SDimitry Andric                                                          const _Alloc& __a,
6560b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
6570b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
6580b57cec5SDimitry Andric    : c(__a),
6590b57cec5SDimitry Andric      comp(__comp)
6600b57cec5SDimitry Andric{
6610b57cec5SDimitry Andric}
6620b57cec5SDimitry Andric
6630b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6640b57cec5SDimitry Andrictemplate <class _Alloc>
6650b57cec5SDimitry Andricinline
6660b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6670b57cec5SDimitry Andric                                                          const container_type& __c,
6680b57cec5SDimitry Andric                                                          const _Alloc& __a,
6690b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
6700b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
6710b57cec5SDimitry Andric    : c(__c, __a),
6720b57cec5SDimitry Andric      comp(__comp)
6730b57cec5SDimitry Andric{
6740b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6750b57cec5SDimitry Andric}
6760b57cec5SDimitry Andric
6770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6780b57cec5SDimitry Andrictemplate <class _Alloc>
6790b57cec5SDimitry Andricinline
6800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
6810b57cec5SDimitry Andric                                                          const _Alloc& __a,
6820b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
6830b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
6840b57cec5SDimitry Andric    : c(__q.c, __a),
6850b57cec5SDimitry Andric      comp(__q.comp)
6860b57cec5SDimitry Andric{
6870b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6880b57cec5SDimitry Andric}
6890b57cec5SDimitry Andric
6900b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6910b57cec5SDimitry Andric
6920b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6930b57cec5SDimitry Andrictemplate <class _Alloc>
6940b57cec5SDimitry Andricinline
6950b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6960b57cec5SDimitry Andric                                                          container_type&& __c,
6970b57cec5SDimitry Andric                                                          const _Alloc& __a,
6980b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
6990b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
7000b57cec5SDimitry Andric    : c(_VSTD::move(__c), __a),
7010b57cec5SDimitry Andric      comp(__comp)
7020b57cec5SDimitry Andric{
7030b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7040b57cec5SDimitry Andric}
7050b57cec5SDimitry Andric
7060b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7070b57cec5SDimitry Andrictemplate <class _Alloc>
7080b57cec5SDimitry Andricinline
7090b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
7100b57cec5SDimitry Andric                                                          const _Alloc& __a,
7110b57cec5SDimitry Andric                       typename enable_if<uses_allocator<container_type,
7120b57cec5SDimitry Andric                                                         _Alloc>::value>::type*)
7130b57cec5SDimitry Andric    : c(_VSTD::move(__q.c), __a),
7140b57cec5SDimitry Andric      comp(_VSTD::move(__q.comp))
7150b57cec5SDimitry Andric{
7160b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7170b57cec5SDimitry Andric}
7180b57cec5SDimitry Andric
7190b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
7200b57cec5SDimitry Andric
7210b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7220b57cec5SDimitry Andricinline
7230b57cec5SDimitry Andricvoid
7240b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
7250b57cec5SDimitry Andric{
7260b57cec5SDimitry Andric    c.push_back(__v);
7270b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7280b57cec5SDimitry Andric}
7290b57cec5SDimitry Andric
7300b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7310b57cec5SDimitry Andric
7320b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7330b57cec5SDimitry Andricinline
7340b57cec5SDimitry Andricvoid
7350b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
7360b57cec5SDimitry Andric{
7370b57cec5SDimitry Andric    c.push_back(_VSTD::move(__v));
7380b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7390b57cec5SDimitry Andric}
7400b57cec5SDimitry Andric
7410b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7420b57cec5SDimitry Andrictemplate <class... _Args>
7430b57cec5SDimitry Andricinline
7440b57cec5SDimitry Andricvoid
7450b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
7460b57cec5SDimitry Andric{
7470b57cec5SDimitry Andric    c.emplace_back(_VSTD::forward<_Args>(__args)...);
7480b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7490b57cec5SDimitry Andric}
7500b57cec5SDimitry Andric
7510b57cec5SDimitry Andric#endif  // _LIBCPP_CXX03_LANG
7520b57cec5SDimitry Andric
7530b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7540b57cec5SDimitry Andricinline
7550b57cec5SDimitry Andricvoid
7560b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop()
7570b57cec5SDimitry Andric{
7580b57cec5SDimitry Andric    _VSTD::pop_heap(c.begin(), c.end(), comp);
7590b57cec5SDimitry Andric    c.pop_back();
7600b57cec5SDimitry Andric}
7610b57cec5SDimitry Andric
7620b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7630b57cec5SDimitry Andricinline
7640b57cec5SDimitry Andricvoid
7650b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
7660b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
7670b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value)
7680b57cec5SDimitry Andric{
7690b57cec5SDimitry Andric    using _VSTD::swap;
7700b57cec5SDimitry Andric    swap(c, __q.c);
7710b57cec5SDimitry Andric    swap(comp, __q.comp);
7720b57cec5SDimitry Andric}
7730b57cec5SDimitry Andric
7740b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7750b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
7760b57cec5SDimitry Andrictypename enable_if<
7770b57cec5SDimitry Andric    __is_swappable<_Container>::value
7780b57cec5SDimitry Andric    && __is_swappable<_Compare>::value,
7790b57cec5SDimitry Andric    void
7800b57cec5SDimitry Andric>::type
7810b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x,
7820b57cec5SDimitry Andric     priority_queue<_Tp, _Container, _Compare>& __y)
7830b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7840b57cec5SDimitry Andric{
7850b57cec5SDimitry Andric    __x.swap(__y);
7860b57cec5SDimitry Andric}
7870b57cec5SDimitry Andric
7880b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
7890b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
7900b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
7910b57cec5SDimitry Andric{
7920b57cec5SDimitry Andric};
7930b57cec5SDimitry Andric
7940b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
7950b57cec5SDimitry Andric
7960b57cec5SDimitry Andric#endif  // _LIBCPP_QUEUE
797