xref: /freebsd/contrib/llvm-project/libcxx/include/queue (revision fe6060f10f634930ff71b7c50291ddc610da2475)
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:
115e8d8bef9SDimitry Andric    priority_queue() : priority_queue(Compare()) {} // C++20
116e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
117e8d8bef9SDimitry Andric    priority_queue(const Compare& x, const Container&);
118e8d8bef9SDimitry Andric    explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20
119e8d8bef9SDimitry 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>
182*fe6060f1SDimitry Andric#include <__memory/uses_allocator.h>
183*fe6060f1SDimitry Andric#include <__utility/forward.h>
1840b57cec5SDimitry Andric#include <algorithm>
185*fe6060f1SDimitry Andric#include <compare>
186*fe6060f1SDimitry Andric#include <deque>
187*fe6060f1SDimitry Andric#include <functional>
188*fe6060f1SDimitry Andric#include <vector>
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1910b57cec5SDimitry Andric#pragma GCC system_header
1920b57cec5SDimitry Andric#endif
1930b57cec5SDimitry Andric
1940b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
1950b57cec5SDimitry Andric
1960b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
1970b57cec5SDimitry Andric
1980b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
1990b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2000b57cec5SDimitry Andricbool
2010b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2020b57cec5SDimitry Andric
2030b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
2040b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2050b57cec5SDimitry Andricbool
2060b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2070b57cec5SDimitry Andric
2080b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
2090b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue
2100b57cec5SDimitry Andric{
2110b57cec5SDimitry Andricpublic:
2120b57cec5SDimitry Andric    typedef _Container                               container_type;
2130b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
2140b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
2150b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
2160b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
2170b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
2180b57cec5SDimitry Andric
2190b57cec5SDimitry Andricprotected:
2200b57cec5SDimitry Andric    container_type c;
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andricpublic:
2230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2240b57cec5SDimitry Andric    queue()
2250b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2260b57cec5SDimitry Andric        : c() {}
2270b57cec5SDimitry Andric
2280b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2290b57cec5SDimitry Andric    queue(const queue& __q) : c(__q.c) {}
2300b57cec5SDimitry Andric
2310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2320b57cec5SDimitry Andric    queue& operator=(const queue& __q) {c = __q.c; return *this;}
2330b57cec5SDimitry Andric
2340b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2350b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2360b57cec5SDimitry Andric    queue(queue&& __q)
2370b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
2380b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)) {}
2390b57cec5SDimitry Andric
2400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2410b57cec5SDimitry Andric    queue& operator=(queue&& __q)
2420b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
2430b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); return *this;}
2440b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2450b57cec5SDimitry Andric
2460b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2470b57cec5SDimitry Andric    explicit queue(const container_type& __c)  : c(__c) {}
2480b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2490b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2500b57cec5SDimitry Andric    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
2510b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2520b57cec5SDimitry Andric    template <class _Alloc>
2530b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2540b57cec5SDimitry Andric        explicit queue(const _Alloc& __a,
255*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
2560b57cec5SDimitry Andric            : c(__a) {}
2570b57cec5SDimitry Andric    template <class _Alloc>
2580b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2590b57cec5SDimitry Andric        queue(const queue& __q, const _Alloc& __a,
260*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
2610b57cec5SDimitry Andric            : c(__q.c, __a) {}
2620b57cec5SDimitry Andric    template <class _Alloc>
2630b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2640b57cec5SDimitry Andric        queue(const container_type& __c, const _Alloc& __a,
265*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 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,
271*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
2720b57cec5SDimitry Andric            : c(_VSTD::move(__c), __a) {}
2730b57cec5SDimitry Andric    template <class _Alloc>
2740b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
2750b57cec5SDimitry Andric        queue(queue&& __q, const _Alloc& __a,
276*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0)
2770b57cec5SDimitry Andric            : c(_VSTD::move(__q.c), __a) {}
2780b57cec5SDimitry Andric
2790b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2800b57cec5SDimitry Andric
2810b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
2820b57cec5SDimitry Andric    bool      empty() const {return c.empty();}
2830b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2840b57cec5SDimitry Andric    size_type size() const  {return c.size();}
2850b57cec5SDimitry Andric
2860b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2870b57cec5SDimitry Andric    reference       front()       {return c.front();}
2880b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2890b57cec5SDimitry Andric    const_reference front() const {return c.front();}
2900b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2910b57cec5SDimitry Andric    reference       back()        {return c.back();}
2920b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2930b57cec5SDimitry Andric    const_reference back() const  {return c.back();}
2940b57cec5SDimitry Andric
2950b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2960b57cec5SDimitry Andric    void push(const value_type& __v) {c.push_back(__v);}
2970b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2980b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
2990b57cec5SDimitry Andric    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3000b57cec5SDimitry Andric    template <class... _Args>
3010b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
3020b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14
3030b57cec5SDimitry Andric        decltype(auto) emplace(_Args&&... __args)
3040b57cec5SDimitry Andric            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3050b57cec5SDimitry Andric#else
3060b57cec5SDimitry Andric        void     emplace(_Args&&... __args)
3070b57cec5SDimitry Andric            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
3080b57cec5SDimitry Andric#endif
3090b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3100b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3110b57cec5SDimitry Andric    void pop() {c.pop_front();}
3120b57cec5SDimitry Andric
3130b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3140b57cec5SDimitry Andric    void swap(queue& __q)
3150b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3160b57cec5SDimitry Andric    {
3170b57cec5SDimitry Andric        using _VSTD::swap;
3180b57cec5SDimitry Andric        swap(c, __q.c);
3190b57cec5SDimitry Andric    }
3200b57cec5SDimitry Andric
3210b57cec5SDimitry Andric    template <class _T1, class _C1>
3220b57cec5SDimitry Andric    friend
3230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3240b57cec5SDimitry Andric    bool
3250b57cec5SDimitry Andric    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3260b57cec5SDimitry Andric
3270b57cec5SDimitry Andric    template <class _T1, class _C1>
3280b57cec5SDimitry Andric    friend
3290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
3300b57cec5SDimitry Andric    bool
3310b57cec5SDimitry Andric    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3320b57cec5SDimitry Andric};
3330b57cec5SDimitry Andric
3340b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
3350b57cec5SDimitry Andrictemplate<class _Container,
336*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Container>::value>
3370b57cec5SDimitry Andric>
3380b57cec5SDimitry Andricqueue(_Container)
3390b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
3400b57cec5SDimitry Andric
3410b57cec5SDimitry Andrictemplate<class _Container,
3420b57cec5SDimitry Andric         class _Alloc,
343*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Container>::value>,
344*fe6060f1SDimitry Andric         class = _EnableIf<uses_allocator<_Container, _Alloc>::value>
3450b57cec5SDimitry Andric>
3460b57cec5SDimitry Andricqueue(_Container, _Alloc)
3470b57cec5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
3480b57cec5SDimitry Andric#endif
3490b57cec5SDimitry Andric
3500b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3510b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3520b57cec5SDimitry Andricbool
3530b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3540b57cec5SDimitry Andric{
3550b57cec5SDimitry Andric    return __x.c == __y.c;
3560b57cec5SDimitry Andric}
3570b57cec5SDimitry Andric
3580b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3590b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3600b57cec5SDimitry Andricbool
3610b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3620b57cec5SDimitry Andric{
3630b57cec5SDimitry Andric    return __x.c < __y.c;
3640b57cec5SDimitry Andric}
3650b57cec5SDimitry Andric
3660b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3670b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3680b57cec5SDimitry Andricbool
3690b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3700b57cec5SDimitry Andric{
3710b57cec5SDimitry Andric    return !(__x == __y);
3720b57cec5SDimitry Andric}
3730b57cec5SDimitry Andric
3740b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3750b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3760b57cec5SDimitry Andricbool
3770b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3780b57cec5SDimitry Andric{
3790b57cec5SDimitry Andric    return __y < __x;
3800b57cec5SDimitry Andric}
3810b57cec5SDimitry Andric
3820b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3830b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3840b57cec5SDimitry Andricbool
3850b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3860b57cec5SDimitry Andric{
3870b57cec5SDimitry Andric    return !(__x < __y);
3880b57cec5SDimitry Andric}
3890b57cec5SDimitry Andric
3900b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3910b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
3920b57cec5SDimitry Andricbool
3930b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3940b57cec5SDimitry Andric{
3950b57cec5SDimitry Andric    return !(__y < __x);
3960b57cec5SDimitry Andric}
3970b57cec5SDimitry Andric
3980b57cec5SDimitry Andrictemplate <class _Tp, class _Container>
3990b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
400*fe6060f1SDimitry Andric_EnableIf<__is_swappable<_Container>::value, void>
4010b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4020b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4030b57cec5SDimitry Andric{
4040b57cec5SDimitry Andric    __x.swap(__y);
4050b57cec5SDimitry Andric}
4060b57cec5SDimitry Andric
4070b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc>
4080b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4090b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
4100b57cec5SDimitry Andric{
4110b57cec5SDimitry Andric};
4120b57cec5SDimitry Andric
4130b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>,
4140b57cec5SDimitry Andric          class _Compare = less<typename _Container::value_type> >
4150b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue
4160b57cec5SDimitry Andric{
4170b57cec5SDimitry Andricpublic:
4180b57cec5SDimitry Andric    typedef _Container                               container_type;
4190b57cec5SDimitry Andric    typedef _Compare                                 value_compare;
4200b57cec5SDimitry Andric    typedef typename container_type::value_type      value_type;
4210b57cec5SDimitry Andric    typedef typename container_type::reference       reference;
4220b57cec5SDimitry Andric    typedef typename container_type::const_reference const_reference;
4230b57cec5SDimitry Andric    typedef typename container_type::size_type       size_type;
4240b57cec5SDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
4250b57cec5SDimitry Andric
4260b57cec5SDimitry Andricprotected:
4270b57cec5SDimitry Andric    container_type c;
4280b57cec5SDimitry Andric    value_compare comp;
4290b57cec5SDimitry Andric
4300b57cec5SDimitry Andricpublic:
4310b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4320b57cec5SDimitry Andric    priority_queue()
4330b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
4340b57cec5SDimitry Andric                   is_nothrow_default_constructible<value_compare>::value)
4350b57cec5SDimitry Andric        : c(), comp() {}
4360b57cec5SDimitry Andric
4370b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4380b57cec5SDimitry Andric    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
4390b57cec5SDimitry Andric
4400b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4410b57cec5SDimitry Andric    priority_queue& operator=(const priority_queue& __q)
4420b57cec5SDimitry Andric        {c = __q.c; comp = __q.comp; return *this;}
4430b57cec5SDimitry Andric
4440b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4450b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4460b57cec5SDimitry Andric    priority_queue(priority_queue&& __q)
4470b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
4480b57cec5SDimitry Andric                   is_nothrow_move_constructible<value_compare>::value)
4490b57cec5SDimitry Andric        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
4500b57cec5SDimitry Andric
4510b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4520b57cec5SDimitry Andric    priority_queue& operator=(priority_queue&& __q)
4530b57cec5SDimitry Andric        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
4540b57cec5SDimitry Andric                   is_nothrow_move_assignable<value_compare>::value)
4550b57cec5SDimitry Andric        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
4560b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
4570b57cec5SDimitry Andric
4580b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4590b57cec5SDimitry Andric    explicit priority_queue(const value_compare& __comp)
4600b57cec5SDimitry Andric        : c(), comp(__comp) {}
4610b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4620b57cec5SDimitry Andric    priority_queue(const value_compare& __comp, const container_type& __c);
4630b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4640b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
465e8d8bef9SDimitry Andric    priority_queue(const value_compare& __comp, container_type&& __c);
4660b57cec5SDimitry Andric#endif
4670b57cec5SDimitry Andric    template <class _InputIter>
4680b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4690b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4700b57cec5SDimitry Andric                       const value_compare& __comp = value_compare());
4710b57cec5SDimitry Andric    template <class _InputIter>
4720b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4730b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4740b57cec5SDimitry Andric                       const value_compare& __comp, const container_type& __c);
4750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4760b57cec5SDimitry Andric    template <class _InputIter>
4770b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4780b57cec5SDimitry Andric        priority_queue(_InputIter __f, _InputIter __l,
4790b57cec5SDimitry Andric                       const value_compare& __comp, container_type&& __c);
4800b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
4810b57cec5SDimitry Andric    template <class _Alloc>
4820b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4830b57cec5SDimitry Andric        explicit priority_queue(const _Alloc& __a,
484*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
4850b57cec5SDimitry Andric    template <class _Alloc>
4860b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4870b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const _Alloc& __a,
488*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
4890b57cec5SDimitry Andric    template <class _Alloc>
4900b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4910b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, const container_type& __c,
4920b57cec5SDimitry Andric                       const _Alloc& __a,
493*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
4940b57cec5SDimitry Andric    template <class _Alloc>
4950b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4960b57cec5SDimitry Andric        priority_queue(const priority_queue& __q, const _Alloc& __a,
497*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
4980b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4990b57cec5SDimitry Andric    template <class _Alloc>
5000b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5010b57cec5SDimitry Andric        priority_queue(const value_compare& __comp, container_type&& __c,
5020b57cec5SDimitry Andric                       const _Alloc& __a,
503*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
5040b57cec5SDimitry Andric    template <class _Alloc>
5050b57cec5SDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5060b57cec5SDimitry Andric        priority_queue(priority_queue&& __q, const _Alloc& __a,
507*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0);
5080b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5090b57cec5SDimitry Andric
5100b57cec5SDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5110b57cec5SDimitry Andric    bool            empty() const {return c.empty();}
5120b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5130b57cec5SDimitry Andric    size_type       size() const  {return c.size();}
5140b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5150b57cec5SDimitry Andric    const_reference top() const   {return c.front();}
5160b57cec5SDimitry Andric
5170b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5180b57cec5SDimitry Andric    void push(const value_type& __v);
5190b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5200b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5210b57cec5SDimitry Andric    void push(value_type&& __v);
5220b57cec5SDimitry Andric    template <class... _Args>
5230b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5240b57cec5SDimitry Andric    void emplace(_Args&&... __args);
5250b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5260b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5270b57cec5SDimitry Andric    void pop();
5280b57cec5SDimitry Andric
5290b57cec5SDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5300b57cec5SDimitry Andric    void swap(priority_queue& __q)
5310b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
5320b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value);
5330b57cec5SDimitry Andric};
5340b57cec5SDimitry Andric
5350b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
5360b57cec5SDimitry Andrictemplate <class _Compare,
5370b57cec5SDimitry Andric          class _Container,
538*fe6060f1SDimitry Andric          class = _EnableIf<!__is_allocator<_Compare>::value>,
539*fe6060f1SDimitry Andric          class = _EnableIf<!__is_allocator<_Container>::value>
5400b57cec5SDimitry Andric>
5410b57cec5SDimitry Andricpriority_queue(_Compare, _Container)
5420b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5430b57cec5SDimitry Andric
5440b57cec5SDimitry Andrictemplate<class _InputIterator,
545*fe6060f1SDimitry Andric         class _Compare = less<__iter_value_type<_InputIterator>>,
546*fe6060f1SDimitry Andric         class _Container = vector<__iter_value_type<_InputIterator>>,
547*fe6060f1SDimitry Andric         class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>,
548*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value>,
549*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Container>::value>
5500b57cec5SDimitry Andric>
5510b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
552*fe6060f1SDimitry Andric    -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>;
5530b57cec5SDimitry Andric
5540b57cec5SDimitry Andrictemplate<class _Compare,
5550b57cec5SDimitry Andric         class _Container,
5560b57cec5SDimitry Andric         class _Alloc,
557*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Compare>::value>,
558*fe6060f1SDimitry Andric         class = _EnableIf<!__is_allocator<_Container>::value>,
559*fe6060f1SDimitry Andric         class = _EnableIf<uses_allocator<_Container, _Alloc>::value>
5600b57cec5SDimitry Andric>
5610b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc)
5620b57cec5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
5630b57cec5SDimitry Andric#endif
5640b57cec5SDimitry Andric
5650b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
5660b57cec5SDimitry Andricinline
5670b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
5680b57cec5SDimitry Andric                                                          const container_type& __c)
5690b57cec5SDimitry Andric    : c(__c),
5700b57cec5SDimitry Andric      comp(__comp)
5710b57cec5SDimitry Andric{
5720b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
5730b57cec5SDimitry Andric}
5740b57cec5SDimitry Andric
5750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5760b57cec5SDimitry Andric
5770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
5780b57cec5SDimitry Andricinline
5790b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
5800b57cec5SDimitry Andric                                                          container_type&& __c)
5810b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
5820b57cec5SDimitry Andric      comp(__comp)
5830b57cec5SDimitry Andric{
5840b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
5850b57cec5SDimitry Andric}
5860b57cec5SDimitry Andric
5870b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
5880b57cec5SDimitry Andric
5890b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
5900b57cec5SDimitry Andrictemplate <class _InputIter>
5910b57cec5SDimitry Andricinline
5920b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
5930b57cec5SDimitry Andric                                                          const value_compare& __comp)
5940b57cec5SDimitry Andric    : c(__f, __l),
5950b57cec5SDimitry Andric      comp(__comp)
5960b57cec5SDimitry Andric{
5970b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
5980b57cec5SDimitry Andric}
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                                                          const container_type& __c)
6060b57cec5SDimitry Andric    : c(__c),
6070b57cec5SDimitry Andric      comp(__comp)
6080b57cec5SDimitry Andric{
6090b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
6100b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6110b57cec5SDimitry Andric}
6120b57cec5SDimitry Andric
6130b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6140b57cec5SDimitry Andric
6150b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6160b57cec5SDimitry Andrictemplate <class _InputIter>
6170b57cec5SDimitry Andricinline
6180b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6190b57cec5SDimitry Andric                                                          const value_compare& __comp,
6200b57cec5SDimitry Andric                                                          container_type&& __c)
6210b57cec5SDimitry Andric    : c(_VSTD::move(__c)),
6220b57cec5SDimitry Andric      comp(__comp)
6230b57cec5SDimitry Andric{
6240b57cec5SDimitry Andric    c.insert(c.end(), __f, __l);
6250b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6260b57cec5SDimitry Andric}
6270b57cec5SDimitry Andric
6280b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
6290b57cec5SDimitry Andric
6300b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6310b57cec5SDimitry Andrictemplate <class _Alloc>
6320b57cec5SDimitry Andricinline
6330b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
634*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6350b57cec5SDimitry Andric    : c(__a)
6360b57cec5SDimitry Andric{
6370b57cec5SDimitry Andric}
6380b57cec5SDimitry Andric
6390b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6400b57cec5SDimitry Andrictemplate <class _Alloc>
6410b57cec5SDimitry Andricinline
6420b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6430b57cec5SDimitry Andric                                                          const _Alloc& __a,
644*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6450b57cec5SDimitry Andric    : c(__a),
6460b57cec5SDimitry Andric      comp(__comp)
6470b57cec5SDimitry Andric{
6480b57cec5SDimitry Andric}
6490b57cec5SDimitry Andric
6500b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6510b57cec5SDimitry Andrictemplate <class _Alloc>
6520b57cec5SDimitry Andricinline
6530b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6540b57cec5SDimitry Andric                                                          const container_type& __c,
6550b57cec5SDimitry Andric                                                          const _Alloc& __a,
656*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6570b57cec5SDimitry Andric    : c(__c, __a),
6580b57cec5SDimitry Andric      comp(__comp)
6590b57cec5SDimitry Andric{
6600b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
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 priority_queue& __q,
6670b57cec5SDimitry Andric                                                          const _Alloc& __a,
668*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6690b57cec5SDimitry Andric    : c(__q.c, __a),
6700b57cec5SDimitry Andric      comp(__q.comp)
6710b57cec5SDimitry Andric{
6720b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6730b57cec5SDimitry Andric}
6740b57cec5SDimitry Andric
6750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
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 value_compare& __comp,
6810b57cec5SDimitry Andric                                                          container_type&& __c,
6820b57cec5SDimitry Andric                                                          const _Alloc& __a,
683*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6840b57cec5SDimitry Andric    : c(_VSTD::move(__c), __a),
6850b57cec5SDimitry Andric      comp(__comp)
6860b57cec5SDimitry Andric{
6870b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
6880b57cec5SDimitry Andric}
6890b57cec5SDimitry Andric
6900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
6910b57cec5SDimitry Andrictemplate <class _Alloc>
6920b57cec5SDimitry Andricinline
6930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
6940b57cec5SDimitry Andric                                                          const _Alloc& __a,
695*fe6060f1SDimitry Andric                       _EnableIf<uses_allocator<container_type, _Alloc>::value>*)
6960b57cec5SDimitry Andric    : c(_VSTD::move(__q.c), __a),
6970b57cec5SDimitry Andric      comp(_VSTD::move(__q.comp))
6980b57cec5SDimitry Andric{
6990b57cec5SDimitry Andric    _VSTD::make_heap(c.begin(), c.end(), comp);
7000b57cec5SDimitry Andric}
7010b57cec5SDimitry Andric
7020b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7030b57cec5SDimitry Andric
7040b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7050b57cec5SDimitry Andricinline
7060b57cec5SDimitry Andricvoid
7070b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
7080b57cec5SDimitry Andric{
7090b57cec5SDimitry Andric    c.push_back(__v);
7100b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7110b57cec5SDimitry Andric}
7120b57cec5SDimitry Andric
7130b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7140b57cec5SDimitry Andric
7150b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7160b57cec5SDimitry Andricinline
7170b57cec5SDimitry Andricvoid
7180b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
7190b57cec5SDimitry Andric{
7200b57cec5SDimitry Andric    c.push_back(_VSTD::move(__v));
7210b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7220b57cec5SDimitry Andric}
7230b57cec5SDimitry Andric
7240b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7250b57cec5SDimitry Andrictemplate <class... _Args>
7260b57cec5SDimitry Andricinline
7270b57cec5SDimitry Andricvoid
7280b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
7290b57cec5SDimitry Andric{
7300b57cec5SDimitry Andric    c.emplace_back(_VSTD::forward<_Args>(__args)...);
7310b57cec5SDimitry Andric    _VSTD::push_heap(c.begin(), c.end(), comp);
7320b57cec5SDimitry Andric}
7330b57cec5SDimitry Andric
7340b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
7350b57cec5SDimitry Andric
7360b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7370b57cec5SDimitry Andricinline
7380b57cec5SDimitry Andricvoid
7390b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop()
7400b57cec5SDimitry Andric{
7410b57cec5SDimitry Andric    _VSTD::pop_heap(c.begin(), c.end(), comp);
7420b57cec5SDimitry Andric    c.pop_back();
7430b57cec5SDimitry Andric}
7440b57cec5SDimitry Andric
7450b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7460b57cec5SDimitry Andricinline
7470b57cec5SDimitry Andricvoid
7480b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
7490b57cec5SDimitry Andric        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
7500b57cec5SDimitry Andric                   __is_nothrow_swappable<value_compare>::value)
7510b57cec5SDimitry Andric{
7520b57cec5SDimitry Andric    using _VSTD::swap;
7530b57cec5SDimitry Andric    swap(c, __q.c);
7540b57cec5SDimitry Andric    swap(comp, __q.comp);
7550b57cec5SDimitry Andric}
7560b57cec5SDimitry Andric
7570b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare>
7580b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY
759*fe6060f1SDimitry Andric_EnableIf<
760*fe6060f1SDimitry Andric    __is_swappable<_Container>::value && __is_swappable<_Compare>::value,
7610b57cec5SDimitry Andric    void
762*fe6060f1SDimitry Andric>
7630b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x,
7640b57cec5SDimitry Andric     priority_queue<_Tp, _Container, _Compare>& __y)
7650b57cec5SDimitry Andric    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7660b57cec5SDimitry Andric{
7670b57cec5SDimitry Andric    __x.swap(__y);
7680b57cec5SDimitry Andric}
7690b57cec5SDimitry Andric
7700b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc>
7710b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
7720b57cec5SDimitry Andric    : public uses_allocator<_Container, _Alloc>
7730b57cec5SDimitry Andric{
7740b57cec5SDimitry Andric};
7750b57cec5SDimitry Andric
7760b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
7770b57cec5SDimitry Andric
7780b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE
779