xref: /freebsd-12.1/contrib/libc++/include/queue (revision 4ba319b5)
17a984708SDavid Chisnall// -*- C++ -*-
27a984708SDavid Chisnall//===--------------------------- queue ------------------------------------===//
37a984708SDavid Chisnall//
47a984708SDavid Chisnall//                     The LLVM Compiler Infrastructure
57a984708SDavid Chisnall//
67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open
77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details.
87a984708SDavid Chisnall//
97a984708SDavid Chisnall//===----------------------------------------------------------------------===//
107a984708SDavid Chisnall
117a984708SDavid Chisnall#ifndef _LIBCPP_QUEUE
127a984708SDavid Chisnall#define _LIBCPP_QUEUE
137a984708SDavid Chisnall
147a984708SDavid Chisnall/*
157a984708SDavid Chisnall    queue synopsis
167a984708SDavid Chisnall
177a984708SDavid Chisnallnamespace std
187a984708SDavid Chisnall{
197a984708SDavid Chisnall
207a984708SDavid Chisnalltemplate <class T, class Container = deque<T>>
217a984708SDavid Chisnallclass queue
227a984708SDavid Chisnall{
237a984708SDavid Chisnallpublic:
247a984708SDavid Chisnall    typedef Container                                container_type;
257a984708SDavid Chisnall    typedef typename container_type::value_type      value_type;
267a984708SDavid Chisnall    typedef typename container_type::reference       reference;
277a984708SDavid Chisnall    typedef typename container_type::const_reference const_reference;
287a984708SDavid Chisnall    typedef typename container_type::size_type       size_type;
297a984708SDavid Chisnall
307a984708SDavid Chisnallprotected:
317a984708SDavid Chisnall    container_type c;
327a984708SDavid Chisnall
337a984708SDavid Chisnallpublic:
347a984708SDavid Chisnall    queue() = default;
357a984708SDavid Chisnall    ~queue() = default;
367a984708SDavid Chisnall
377a984708SDavid Chisnall    queue(const queue& q) = default;
387a984708SDavid Chisnall    queue(queue&& q) = default;
397a984708SDavid Chisnall
407a984708SDavid Chisnall    queue& operator=(const queue& q) = default;
417a984708SDavid Chisnall    queue& operator=(queue&& q) = default;
427a984708SDavid Chisnall
437a984708SDavid Chisnall    explicit queue(const container_type& c);
447a984708SDavid Chisnall    explicit queue(container_type&& c)
457a984708SDavid Chisnall    template <class Alloc>
467a984708SDavid Chisnall        explicit queue(const Alloc& a);
477a984708SDavid Chisnall    template <class Alloc>
487a984708SDavid Chisnall        queue(const container_type& c, const Alloc& a);
497a984708SDavid Chisnall    template <class Alloc>
507a984708SDavid Chisnall        queue(container_type&& c, const Alloc& a);
517a984708SDavid Chisnall    template <class Alloc>
527a984708SDavid Chisnall        queue(const queue& q, const Alloc& a);
537a984708SDavid Chisnall    template <class Alloc>
547a984708SDavid Chisnall        queue(queue&& q, const Alloc& a);
557a984708SDavid Chisnall
567a984708SDavid Chisnall    bool      empty() const;
577a984708SDavid Chisnall    size_type size() const;
587a984708SDavid Chisnall
597a984708SDavid Chisnall    reference       front();
607a984708SDavid Chisnall    const_reference front() const;
617a984708SDavid Chisnall    reference       back();
627a984708SDavid Chisnall    const_reference back() const;
637a984708SDavid Chisnall
647a984708SDavid Chisnall    void push(const value_type& v);
657a984708SDavid Chisnall    void push(value_type&& v);
6698221d2eSDimitry Andric    template <class... Args> reference emplace(Args&&... args); // reference in C++17
677a984708SDavid Chisnall    void pop();
687a984708SDavid Chisnall
697c82a1ecSDimitry Andric    void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)
707a984708SDavid Chisnall};
717a984708SDavid Chisnall
72*4ba319b5SDimitry Andrictemplate<class Container>
73*4ba319b5SDimitry Andric  queue(Container) -> queue<typename Container::value_type, Container>; // C++17
74*4ba319b5SDimitry Andric
75*4ba319b5SDimitry Andrictemplate<class Container, class Allocator>
76*4ba319b5SDimitry Andric  queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
77*4ba319b5SDimitry Andric
787a984708SDavid Chisnalltemplate <class T, class Container>
797a984708SDavid Chisnall  bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
807a984708SDavid Chisnall
817a984708SDavid Chisnalltemplate <class T, class Container>
827a984708SDavid Chisnall  bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
837a984708SDavid Chisnall
847a984708SDavid Chisnalltemplate <class T, class Container>
857a984708SDavid Chisnall  bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
867a984708SDavid Chisnall
877a984708SDavid Chisnalltemplate <class T, class Container>
887a984708SDavid Chisnall  bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
897a984708SDavid Chisnall
907a984708SDavid Chisnalltemplate <class T, class Container>
917a984708SDavid Chisnall  bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
927a984708SDavid Chisnall
937a984708SDavid Chisnalltemplate <class T, class Container>
947a984708SDavid Chisnall  bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
957a984708SDavid Chisnall
967a984708SDavid Chisnalltemplate <class T, class Container>
977a984708SDavid Chisnall  void swap(queue<T, Container>& x, queue<T, Container>& y)
987a984708SDavid Chisnall  noexcept(noexcept(x.swap(y)));
997a984708SDavid Chisnall
1007a984708SDavid Chisnalltemplate <class T, class Container = vector<T>,
1017a984708SDavid Chisnall          class Compare = less<typename Container::value_type>>
1027a984708SDavid Chisnallclass priority_queue
1037a984708SDavid Chisnall{
1047a984708SDavid Chisnallpublic:
1057a984708SDavid Chisnall    typedef Container                                container_type;
1067a984708SDavid Chisnall    typedef typename container_type::value_type      value_type;
1077a984708SDavid Chisnall    typedef typename container_type::reference       reference;
1087a984708SDavid Chisnall    typedef typename container_type::const_reference const_reference;
1097a984708SDavid Chisnall    typedef typename container_type::size_type       size_type;
1107a984708SDavid Chisnall
1117a984708SDavid Chisnallprotected:
1127a984708SDavid Chisnall    container_type c;
1137a984708SDavid Chisnall    Compare comp;
1147a984708SDavid Chisnall
1157a984708SDavid Chisnallpublic:
1167a984708SDavid Chisnall    priority_queue() = default;
1177a984708SDavid Chisnall    ~priority_queue() = default;
1187a984708SDavid Chisnall
1197a984708SDavid Chisnall    priority_queue(const priority_queue& q) = default;
1207a984708SDavid Chisnall    priority_queue(priority_queue&& q) = default;
1217a984708SDavid Chisnall
1227a984708SDavid Chisnall    priority_queue& operator=(const priority_queue& q) = default;
1237a984708SDavid Chisnall    priority_queue& operator=(priority_queue&& q) = default;
1247a984708SDavid Chisnall
1257a984708SDavid Chisnall    explicit priority_queue(const Compare& comp);
1267a984708SDavid Chisnall    priority_queue(const Compare& comp, const container_type& c);
1277a984708SDavid Chisnall    explicit priority_queue(const Compare& comp, container_type&& c);
1287a984708SDavid Chisnall    template <class InputIterator>
1297a984708SDavid Chisnall        priority_queue(InputIterator first, InputIterator last,
1307a984708SDavid Chisnall                       const Compare& comp = Compare());
1317a984708SDavid Chisnall    template <class InputIterator>
1327a984708SDavid Chisnall        priority_queue(InputIterator first, InputIterator last,
1337a984708SDavid Chisnall                       const Compare& comp, const container_type& c);
1347a984708SDavid Chisnall    template <class InputIterator>
1357a984708SDavid Chisnall        priority_queue(InputIterator first, InputIterator last,
1367a984708SDavid Chisnall                       const Compare& comp, container_type&& c);
1377a984708SDavid Chisnall    template <class Alloc>
1387a984708SDavid Chisnall        explicit priority_queue(const Alloc& a);
1397a984708SDavid Chisnall    template <class Alloc>
1407a984708SDavid Chisnall        priority_queue(const Compare& comp, const Alloc& a);
1417a984708SDavid Chisnall    template <class Alloc>
1427a984708SDavid Chisnall        priority_queue(const Compare& comp, const container_type& c,
1437a984708SDavid Chisnall                       const Alloc& a);
1447a984708SDavid Chisnall    template <class Alloc>
1457a984708SDavid Chisnall        priority_queue(const Compare& comp, container_type&& c,
1467a984708SDavid Chisnall                       const Alloc& a);
1477a984708SDavid Chisnall    template <class Alloc>
1487a984708SDavid Chisnall        priority_queue(const priority_queue& q, const Alloc& a);
1497a984708SDavid Chisnall    template <class Alloc>
1507a984708SDavid Chisnall        priority_queue(priority_queue&& q, const Alloc& a);
1517a984708SDavid Chisnall
1527a984708SDavid Chisnall    bool            empty() const;
1537a984708SDavid Chisnall    size_type       size() const;
1547a984708SDavid Chisnall    const_reference top() const;
1557a984708SDavid Chisnall
1567a984708SDavid Chisnall    void push(const value_type& v);
1577a984708SDavid Chisnall    void push(value_type&& v);
1587a984708SDavid Chisnall    template <class... Args> void emplace(Args&&... args);
1597a984708SDavid Chisnall    void pop();
1607a984708SDavid Chisnall
1617a984708SDavid Chisnall    void swap(priority_queue& q)
1627c82a1ecSDimitry Andric        noexcept(is_nothrow_swappable_v<Container> &&
1637c82a1ecSDimitry Andric                 is_nothrow_swappable_v<Comp>)
1647a984708SDavid Chisnall};
1657a984708SDavid Chisnall
166*4ba319b5SDimitry Andrictemplate <class Compare, class Container>
167*4ba319b5SDimitry Andricpriority_queue(Compare, Container)
168*4ba319b5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
169*4ba319b5SDimitry Andric
170*4ba319b5SDimitry Andrictemplate<class InputIterator,
171*4ba319b5SDimitry Andric         class Compare = less<typename iterator_traits<InputIterator>::value_type>,
172*4ba319b5SDimitry Andric         class Container = vector<typename iterator_traits<InputIterator>::value_type>>
173*4ba319b5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
174*4ba319b5SDimitry Andric    -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
175*4ba319b5SDimitry Andric
176*4ba319b5SDimitry Andrictemplate<class Compare, class Container, class Allocator>
177*4ba319b5SDimitry Andricpriority_queue(Compare, Container, Allocator)
178*4ba319b5SDimitry Andric    -> priority_queue<typename Container::value_type, Container, Compare>; // C++17
179*4ba319b5SDimitry Andric
1807a984708SDavid Chisnalltemplate <class T, class Container, class Compare>
1817a984708SDavid Chisnall  void swap(priority_queue<T, Container, Compare>& x,
1827a984708SDavid Chisnall            priority_queue<T, Container, Compare>& y)
1837a984708SDavid Chisnall            noexcept(noexcept(x.swap(y)));
1847a984708SDavid Chisnall
1857a984708SDavid Chisnall}  // std
1867a984708SDavid Chisnall
1877a984708SDavid Chisnall*/
1887a984708SDavid Chisnall
1897a984708SDavid Chisnall#include <__config>
1907a984708SDavid Chisnall#include <deque>
1917a984708SDavid Chisnall#include <vector>
1927a984708SDavid Chisnall#include <functional>
1937a984708SDavid Chisnall#include <algorithm>
1947a984708SDavid Chisnall
1957a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1967a984708SDavid Chisnall#pragma GCC system_header
1977a984708SDavid Chisnall#endif
1987a984708SDavid Chisnall
1997a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD
2007a984708SDavid Chisnall
201aed8d94eSDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue;
2027a984708SDavid Chisnall
2037a984708SDavid Chisnalltemplate <class _Tp, class _Container>
204936e9439SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2057a984708SDavid Chisnallbool
2067a984708SDavid Chisnalloperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2077a984708SDavid Chisnall
2087a984708SDavid Chisnalltemplate <class _Tp, class _Container>
209936e9439SDimitry Andric_LIBCPP_INLINE_VISIBILITY
2107a984708SDavid Chisnallbool
2117a984708SDavid Chisnalloperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
2127a984708SDavid Chisnall
213854fa44bSDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/>
214aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue
2157a984708SDavid Chisnall{
2167a984708SDavid Chisnallpublic:
2177a984708SDavid Chisnall    typedef _Container                               container_type;
2187a984708SDavid Chisnall    typedef typename container_type::value_type      value_type;
2197a984708SDavid Chisnall    typedef typename container_type::reference       reference;
2207a984708SDavid Chisnall    typedef typename container_type::const_reference const_reference;
2217a984708SDavid Chisnall    typedef typename container_type::size_type       size_type;
2227c82a1ecSDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
2237a984708SDavid Chisnall
2247a984708SDavid Chisnallprotected:
2257a984708SDavid Chisnall    container_type c;
2267a984708SDavid Chisnall
2277a984708SDavid Chisnallpublic:
2287a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2297a984708SDavid Chisnall    queue()
2307a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value)
2317a984708SDavid Chisnall        : c() {}
2327a984708SDavid Chisnall
2337a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2347a984708SDavid Chisnall    queue(const queue& __q) : c(__q.c) {}
2357a984708SDavid Chisnall
236540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
237540d2a8bSDimitry Andric    queue& operator=(const queue& __q) {c = __q.c; return *this;}
238540d2a8bSDimitry Andric
239540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2407a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2417a984708SDavid Chisnall    queue(queue&& __q)
2427a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
2437a984708SDavid Chisnall        : c(_VSTD::move(__q.c)) {}
2447a984708SDavid Chisnall
2457a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2467a984708SDavid Chisnall    queue& operator=(queue&& __q)
2477a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value)
2487a984708SDavid Chisnall        {c = _VSTD::move(__q.c); return *this;}
249540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2507a984708SDavid Chisnall
2517a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2527a984708SDavid Chisnall    explicit queue(const container_type& __c)  : c(__c) {}
253540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2547a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2557a984708SDavid Chisnall    explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {}
256540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2577a984708SDavid Chisnall    template <class _Alloc>
2587a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
2597a984708SDavid Chisnall        explicit queue(const _Alloc& __a,
2607a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
2617a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0)
2627a984708SDavid Chisnall            : c(__a) {}
2637a984708SDavid Chisnall    template <class _Alloc>
2647a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
2657a984708SDavid Chisnall        queue(const queue& __q, const _Alloc& __a,
2667a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
2677a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0)
2687a984708SDavid Chisnall            : c(__q.c, __a) {}
2697a984708SDavid Chisnall    template <class _Alloc>
2707a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
2717a984708SDavid Chisnall        queue(const container_type& __c, const _Alloc& __a,
2727a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
2737a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0)
2747a984708SDavid Chisnall            : c(__c, __a) {}
275540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
2767a984708SDavid Chisnall    template <class _Alloc>
2777a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
2787a984708SDavid Chisnall        queue(container_type&& __c, const _Alloc& __a,
2797a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
2807a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0)
2817a984708SDavid Chisnall            : c(_VSTD::move(__c), __a) {}
2827a984708SDavid Chisnall    template <class _Alloc>
2837a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
2847a984708SDavid Chisnall        queue(queue&& __q, const _Alloc& __a,
2857a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
2867a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0)
2877a984708SDavid Chisnall            : c(_VSTD::move(__q.c), __a) {}
2887a984708SDavid Chisnall
289540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
2907a984708SDavid Chisnall
291b2c7081bSDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
2927a984708SDavid Chisnall    bool      empty() const {return c.empty();}
2937a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2947a984708SDavid Chisnall    size_type size() const  {return c.size();}
2957a984708SDavid Chisnall
2967a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2977a984708SDavid Chisnall    reference       front()       {return c.front();}
2987a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
2997a984708SDavid Chisnall    const_reference front() const {return c.front();}
3007a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3017a984708SDavid Chisnall    reference       back()        {return c.back();}
3027a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3037a984708SDavid Chisnall    const_reference back() const  {return c.back();}
3047a984708SDavid Chisnall
3057a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3067a984708SDavid Chisnall    void push(const value_type& __v) {c.push_back(__v);}
307540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
3087a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3097a984708SDavid Chisnall    void push(value_type&& __v)      {c.push_back(_VSTD::move(__v));}
3107a984708SDavid Chisnall    template <class... _Args>
3117a984708SDavid Chisnall        _LIBCPP_INLINE_VISIBILITY
31298221d2eSDimitry Andric#if _LIBCPP_STD_VER > 14
313*4ba319b5SDimitry Andric        decltype(auto) emplace(_Args&&... __args)
314aed8d94eSDimitry Andric            { return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
31598221d2eSDimitry Andric#else
31698221d2eSDimitry Andric        void     emplace(_Args&&... __args)
31798221d2eSDimitry Andric            {        c.emplace_back(_VSTD::forward<_Args>(__args)...);}
31898221d2eSDimitry Andric#endif
319540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
3207a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3217a984708SDavid Chisnall    void pop() {c.pop_front();}
3227a984708SDavid Chisnall
3237a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3247a984708SDavid Chisnall    void swap(queue& __q)
3257a984708SDavid Chisnall        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value)
3267a984708SDavid Chisnall    {
3277a984708SDavid Chisnall        using _VSTD::swap;
3287a984708SDavid Chisnall        swap(c, __q.c);
3297a984708SDavid Chisnall    }
3307a984708SDavid Chisnall
3317a984708SDavid Chisnall    template <class _T1, class _C1>
3327a984708SDavid Chisnall    friend
3337a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3347a984708SDavid Chisnall    bool
3357a984708SDavid Chisnall    operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3367a984708SDavid Chisnall
3377a984708SDavid Chisnall    template <class _T1, class _C1>
3387a984708SDavid Chisnall    friend
3397a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
3407a984708SDavid Chisnall    bool
3417a984708SDavid Chisnall    operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
3427a984708SDavid Chisnall};
3437a984708SDavid Chisnall
344*4ba319b5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
345*4ba319b5SDimitry Andrictemplate<class _Container,
346*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
347*4ba319b5SDimitry Andric>
348*4ba319b5SDimitry Andricqueue(_Container)
349*4ba319b5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
350*4ba319b5SDimitry Andric
351*4ba319b5SDimitry Andrictemplate<class _Container,
352*4ba319b5SDimitry Andric         class _Alloc,
353*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
354*4ba319b5SDimitry Andric         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
355*4ba319b5SDimitry Andric>
356*4ba319b5SDimitry Andricqueue(_Container, _Alloc)
357*4ba319b5SDimitry Andric    -> queue<typename _Container::value_type, _Container>;
358*4ba319b5SDimitry Andric#endif
359*4ba319b5SDimitry Andric
3607a984708SDavid Chisnalltemplate <class _Tp, class _Container>
3617a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
3627a984708SDavid Chisnallbool
3637a984708SDavid Chisnalloperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3647a984708SDavid Chisnall{
3657a984708SDavid Chisnall    return __x.c == __y.c;
3667a984708SDavid Chisnall}
3677a984708SDavid Chisnall
3687a984708SDavid Chisnalltemplate <class _Tp, class _Container>
3697a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
3707a984708SDavid Chisnallbool
3717a984708SDavid Chisnalloperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3727a984708SDavid Chisnall{
3737a984708SDavid Chisnall    return __x.c < __y.c;
3747a984708SDavid Chisnall}
3757a984708SDavid Chisnall
3767a984708SDavid Chisnalltemplate <class _Tp, class _Container>
3777a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
3787a984708SDavid Chisnallbool
3797a984708SDavid Chisnalloperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3807a984708SDavid Chisnall{
3817a984708SDavid Chisnall    return !(__x == __y);
3827a984708SDavid Chisnall}
3837a984708SDavid Chisnall
3847a984708SDavid Chisnalltemplate <class _Tp, class _Container>
3857a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
3867a984708SDavid Chisnallbool
3877a984708SDavid Chisnalloperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3887a984708SDavid Chisnall{
3897a984708SDavid Chisnall    return __y < __x;
3907a984708SDavid Chisnall}
3917a984708SDavid Chisnall
3927a984708SDavid Chisnalltemplate <class _Tp, class _Container>
3937a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
3947a984708SDavid Chisnallbool
3957a984708SDavid Chisnalloperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
3967a984708SDavid Chisnall{
3977a984708SDavid Chisnall    return !(__x < __y);
3987a984708SDavid Chisnall}
3997a984708SDavid Chisnall
4007a984708SDavid Chisnalltemplate <class _Tp, class _Container>
4017a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
4027a984708SDavid Chisnallbool
4037a984708SDavid Chisnalloperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
4047a984708SDavid Chisnall{
4057a984708SDavid Chisnall    return !(__y < __x);
4067a984708SDavid Chisnall}
4077a984708SDavid Chisnall
4087a984708SDavid Chisnalltemplate <class _Tp, class _Container>
4097a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
4107c82a1ecSDimitry Andrictypename enable_if<
4117c82a1ecSDimitry Andric    __is_swappable<_Container>::value,
4127a984708SDavid Chisnall    void
4137c82a1ecSDimitry Andric>::type
4147a984708SDavid Chisnallswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
4157a984708SDavid Chisnall    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
4167a984708SDavid Chisnall{
4177a984708SDavid Chisnall    __x.swap(__y);
4187a984708SDavid Chisnall}
4197a984708SDavid Chisnall
4207a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Alloc>
421aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>
4227a984708SDavid Chisnall    : public uses_allocator<_Container, _Alloc>
4237a984708SDavid Chisnall{
4247a984708SDavid Chisnall};
4257a984708SDavid Chisnall
4267a984708SDavid Chisnalltemplate <class _Tp, class _Container = vector<_Tp>,
4277a984708SDavid Chisnall          class _Compare = less<typename _Container::value_type> >
428aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue
4297a984708SDavid Chisnall{
4307a984708SDavid Chisnallpublic:
4317a984708SDavid Chisnall    typedef _Container                               container_type;
4327a984708SDavid Chisnall    typedef _Compare                                 value_compare;
4337a984708SDavid Chisnall    typedef typename container_type::value_type      value_type;
4347a984708SDavid Chisnall    typedef typename container_type::reference       reference;
4357a984708SDavid Chisnall    typedef typename container_type::const_reference const_reference;
4367a984708SDavid Chisnall    typedef typename container_type::size_type       size_type;
4377c82a1ecSDimitry Andric    static_assert((is_same<_Tp, value_type>::value), "" );
4387a984708SDavid Chisnall
4397a984708SDavid Chisnallprotected:
4407a984708SDavid Chisnall    container_type c;
4417a984708SDavid Chisnall    value_compare comp;
4427a984708SDavid Chisnall
4437a984708SDavid Chisnallpublic:
4447a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4457a984708SDavid Chisnall    priority_queue()
4467a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value &&
4477a984708SDavid Chisnall                   is_nothrow_default_constructible<value_compare>::value)
4487a984708SDavid Chisnall        : c(), comp() {}
4497a984708SDavid Chisnall
4507a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4517a984708SDavid Chisnall    priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}
4527a984708SDavid Chisnall
453540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
454540d2a8bSDimitry Andric    priority_queue& operator=(const priority_queue& __q)
455540d2a8bSDimitry Andric        {c = __q.c; comp = __q.comp; return *this;}
456540d2a8bSDimitry Andric
457540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4587a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4597a984708SDavid Chisnall    priority_queue(priority_queue&& __q)
4607a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value &&
4617a984708SDavid Chisnall                   is_nothrow_move_constructible<value_compare>::value)
4627a984708SDavid Chisnall        : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {}
4637a984708SDavid Chisnall
4647a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4657a984708SDavid Chisnall    priority_queue& operator=(priority_queue&& __q)
4667a984708SDavid Chisnall        _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value &&
4677a984708SDavid Chisnall                   is_nothrow_move_assignable<value_compare>::value)
4687a984708SDavid Chisnall        {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;}
469540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4707a984708SDavid Chisnall
4717a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
4727a984708SDavid Chisnall    explicit priority_queue(const value_compare& __comp)
4737a984708SDavid Chisnall        : c(), comp(__comp) {}
4747c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4757a984708SDavid Chisnall    priority_queue(const value_compare& __comp, const container_type& __c);
476540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4777c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
4787a984708SDavid Chisnall    explicit priority_queue(const value_compare& __comp, container_type&& __c);
4797a984708SDavid Chisnall#endif
4807a984708SDavid Chisnall    template <class _InputIter>
4817c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4827a984708SDavid Chisnall        priority_queue(_InputIter __f, _InputIter __l,
4837a984708SDavid Chisnall                       const value_compare& __comp = value_compare());
4847a984708SDavid Chisnall    template <class _InputIter>
4857c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4867a984708SDavid Chisnall        priority_queue(_InputIter __f, _InputIter __l,
4877a984708SDavid Chisnall                       const value_compare& __comp, const container_type& __c);
488540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
4897a984708SDavid Chisnall    template <class _InputIter>
4907c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4917a984708SDavid Chisnall        priority_queue(_InputIter __f, _InputIter __l,
4927a984708SDavid Chisnall                       const value_compare& __comp, container_type&& __c);
493540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
4947a984708SDavid Chisnall    template <class _Alloc>
4957c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
4967a984708SDavid Chisnall        explicit priority_queue(const _Alloc& __a,
4977a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
4987a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
4997a984708SDavid Chisnall    template <class _Alloc>
5007c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5017a984708SDavid Chisnall        priority_queue(const value_compare& __comp, const _Alloc& __a,
5027a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
5037a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
5047a984708SDavid Chisnall    template <class _Alloc>
5057c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5067a984708SDavid Chisnall        priority_queue(const value_compare& __comp, const container_type& __c,
5077a984708SDavid Chisnall                       const _Alloc& __a,
5087a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
5097a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
5107a984708SDavid Chisnall    template <class _Alloc>
5117c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5127a984708SDavid Chisnall        priority_queue(const priority_queue& __q, const _Alloc& __a,
5137a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
5147a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
515540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5167a984708SDavid Chisnall    template <class _Alloc>
5177c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5187a984708SDavid Chisnall        priority_queue(const value_compare& __comp, container_type&& __c,
5197a984708SDavid Chisnall                       const _Alloc& __a,
5207a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
5217a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
5227a984708SDavid Chisnall    template <class _Alloc>
5237c82a1ecSDimitry Andric        _LIBCPP_INLINE_VISIBILITY
5247a984708SDavid Chisnall        priority_queue(priority_queue&& __q, const _Alloc& __a,
5257a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
5267a984708SDavid Chisnall                                                         _Alloc>::value>::type* = 0);
527540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5287a984708SDavid Chisnall
529b2c7081bSDimitry Andric    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
5307a984708SDavid Chisnall    bool            empty() const {return c.empty();}
5317a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5327a984708SDavid Chisnall    size_type       size() const  {return c.size();}
5337a984708SDavid Chisnall    _LIBCPP_INLINE_VISIBILITY
5347a984708SDavid Chisnall    const_reference top() const   {return c.front();}
5357a984708SDavid Chisnall
5367c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5377a984708SDavid Chisnall    void push(const value_type& __v);
538540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5397c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5407a984708SDavid Chisnall    void push(value_type&& __v);
541540d2a8bSDimitry Andric    template <class... _Args>
542540d2a8bSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
543540d2a8bSDimitry Andric    void emplace(_Args&&... __args);
544540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
5457c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5467a984708SDavid Chisnall    void pop();
5477a984708SDavid Chisnall
5487c82a1ecSDimitry Andric    _LIBCPP_INLINE_VISIBILITY
5497a984708SDavid Chisnall    void swap(priority_queue& __q)
5507a984708SDavid Chisnall        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
5517a984708SDavid Chisnall                   __is_nothrow_swappable<value_compare>::value);
5527a984708SDavid Chisnall};
5537a984708SDavid Chisnall
554*4ba319b5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
555*4ba319b5SDimitry Andrictemplate <class _Compare,
556*4ba319b5SDimitry Andric          class _Container,
557*4ba319b5SDimitry Andric          class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
558*4ba319b5SDimitry Andric          class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
559*4ba319b5SDimitry Andric>
560*4ba319b5SDimitry Andricpriority_queue(_Compare, _Container)
561*4ba319b5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
562*4ba319b5SDimitry Andric
563*4ba319b5SDimitry Andrictemplate<class _InputIterator,
564*4ba319b5SDimitry Andric         class _Compare   = less<typename iterator_traits<_InputIterator>::value_type>,
565*4ba319b5SDimitry Andric         class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,
566*4ba319b5SDimitry Andric         class = typename enable_if< __is_input_iterator<_InputIterator>::value, nullptr_t>::type,
567*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
568*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type
569*4ba319b5SDimitry Andric>
570*4ba319b5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())
571*4ba319b5SDimitry Andric    -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;
572*4ba319b5SDimitry Andric
573*4ba319b5SDimitry Andrictemplate<class _Compare,
574*4ba319b5SDimitry Andric         class _Container,
575*4ba319b5SDimitry Andric         class _Alloc,
576*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,
577*4ba319b5SDimitry Andric         class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,
578*4ba319b5SDimitry Andric         class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type
579*4ba319b5SDimitry Andric>
580*4ba319b5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc)
581*4ba319b5SDimitry Andric    -> priority_queue<typename _Container::value_type, _Container, _Compare>;
582*4ba319b5SDimitry Andric#endif
583*4ba319b5SDimitry Andric
5847a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
5857c82a1ecSDimitry Andricinline
5867a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
5877a984708SDavid Chisnall                                                          const container_type& __c)
5887a984708SDavid Chisnall    : c(__c),
5897a984708SDavid Chisnall      comp(__comp)
5907a984708SDavid Chisnall{
5917a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
5927a984708SDavid Chisnall}
5937a984708SDavid Chisnall
594540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
5957a984708SDavid Chisnall
5967a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
5977c82a1ecSDimitry Andricinline
5987a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
5997a984708SDavid Chisnall                                                          container_type&& __c)
6007a984708SDavid Chisnall    : c(_VSTD::move(__c)),
6017a984708SDavid Chisnall      comp(__comp)
6027a984708SDavid Chisnall{
6037a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6047a984708SDavid Chisnall}
6057a984708SDavid Chisnall
606540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
6077a984708SDavid Chisnall
6087a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6097a984708SDavid Chisnalltemplate <class _InputIter>
6107c82a1ecSDimitry Andricinline
6117a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6127a984708SDavid Chisnall                                                          const value_compare& __comp)
6137a984708SDavid Chisnall    : c(__f, __l),
6147a984708SDavid Chisnall      comp(__comp)
6157a984708SDavid Chisnall{
6167a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6177a984708SDavid Chisnall}
6187a984708SDavid Chisnall
6197a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6207a984708SDavid Chisnalltemplate <class _InputIter>
6217c82a1ecSDimitry Andricinline
6227a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6237a984708SDavid Chisnall                                                          const value_compare& __comp,
6247a984708SDavid Chisnall                                                          const container_type& __c)
6257a984708SDavid Chisnall    : c(__c),
6267a984708SDavid Chisnall      comp(__comp)
6277a984708SDavid Chisnall{
6287a984708SDavid Chisnall    c.insert(c.end(), __f, __l);
6297a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6307a984708SDavid Chisnall}
6317a984708SDavid Chisnall
632540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6337a984708SDavid Chisnall
6347a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6357a984708SDavid Chisnalltemplate <class _InputIter>
6367c82a1ecSDimitry Andricinline
6377a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
6387a984708SDavid Chisnall                                                          const value_compare& __comp,
6397a984708SDavid Chisnall                                                          container_type&& __c)
6407a984708SDavid Chisnall    : c(_VSTD::move(__c)),
6417a984708SDavid Chisnall      comp(__comp)
6427a984708SDavid Chisnall{
6437a984708SDavid Chisnall    c.insert(c.end(), __f, __l);
6447a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6457a984708SDavid Chisnall}
6467a984708SDavid Chisnall
647540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
6487a984708SDavid Chisnall
6497a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6507a984708SDavid Chisnalltemplate <class _Alloc>
6517c82a1ecSDimitry Andricinline
6527a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
6537a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
6547a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
6557a984708SDavid Chisnall    : c(__a)
6567a984708SDavid Chisnall{
6577a984708SDavid Chisnall}
6587a984708SDavid Chisnall
6597a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6607a984708SDavid Chisnalltemplate <class _Alloc>
6617c82a1ecSDimitry Andricinline
6627a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6637a984708SDavid Chisnall                                                          const _Alloc& __a,
6647a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
6657a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
6667a984708SDavid Chisnall    : c(__a),
6677a984708SDavid Chisnall      comp(__comp)
6687a984708SDavid Chisnall{
6697a984708SDavid Chisnall}
6707a984708SDavid Chisnall
6717a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6727a984708SDavid Chisnalltemplate <class _Alloc>
6737c82a1ecSDimitry Andricinline
6747a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
6757a984708SDavid Chisnall                                                          const container_type& __c,
6767a984708SDavid Chisnall                                                          const _Alloc& __a,
6777a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
6787a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
6797a984708SDavid Chisnall    : c(__c, __a),
6807a984708SDavid Chisnall      comp(__comp)
6817a984708SDavid Chisnall{
6827a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6837a984708SDavid Chisnall}
6847a984708SDavid Chisnall
6857a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
6867a984708SDavid Chisnalltemplate <class _Alloc>
6877c82a1ecSDimitry Andricinline
6887a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
6897a984708SDavid Chisnall                                                          const _Alloc& __a,
6907a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
6917a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
6927a984708SDavid Chisnall    : c(__q.c, __a),
6937a984708SDavid Chisnall      comp(__q.comp)
6947a984708SDavid Chisnall{
6957a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
6967a984708SDavid Chisnall}
6977a984708SDavid Chisnall
698540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
6997a984708SDavid Chisnall
7007a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7017a984708SDavid Chisnalltemplate <class _Alloc>
7027c82a1ecSDimitry Andricinline
7037a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
7047a984708SDavid Chisnall                                                          container_type&& __c,
7057a984708SDavid Chisnall                                                          const _Alloc& __a,
7067a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
7077a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
7087a984708SDavid Chisnall    : c(_VSTD::move(__c), __a),
7097a984708SDavid Chisnall      comp(__comp)
7107a984708SDavid Chisnall{
7117a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
7127a984708SDavid Chisnall}
7137a984708SDavid Chisnall
7147a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7157a984708SDavid Chisnalltemplate <class _Alloc>
7167c82a1ecSDimitry Andricinline
7177a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
7187a984708SDavid Chisnall                                                          const _Alloc& __a,
7197a984708SDavid Chisnall                       typename enable_if<uses_allocator<container_type,
7207a984708SDavid Chisnall                                                         _Alloc>::value>::type*)
7217a984708SDavid Chisnall    : c(_VSTD::move(__q.c), __a),
7227a984708SDavid Chisnall      comp(_VSTD::move(__q.comp))
7237a984708SDavid Chisnall{
7247a984708SDavid Chisnall    _VSTD::make_heap(c.begin(), c.end(), comp);
7257a984708SDavid Chisnall}
7267a984708SDavid Chisnall
727540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
7287a984708SDavid Chisnall
7297a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7307c82a1ecSDimitry Andricinline
7317a984708SDavid Chisnallvoid
7327a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
7337a984708SDavid Chisnall{
7347a984708SDavid Chisnall    c.push_back(__v);
7357a984708SDavid Chisnall    _VSTD::push_heap(c.begin(), c.end(), comp);
7367a984708SDavid Chisnall}
7377a984708SDavid Chisnall
738540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG
7397a984708SDavid Chisnall
7407a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7417c82a1ecSDimitry Andricinline
7427a984708SDavid Chisnallvoid
7437a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
7447a984708SDavid Chisnall{
7457a984708SDavid Chisnall    c.push_back(_VSTD::move(__v));
7467a984708SDavid Chisnall    _VSTD::push_heap(c.begin(), c.end(), comp);
7477a984708SDavid Chisnall}
7487a984708SDavid Chisnall
7497a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7507a984708SDavid Chisnalltemplate <class... _Args>
7517c82a1ecSDimitry Andricinline
7527a984708SDavid Chisnallvoid
7537a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
7547a984708SDavid Chisnall{
7557a984708SDavid Chisnall    c.emplace_back(_VSTD::forward<_Args>(__args)...);
7567a984708SDavid Chisnall    _VSTD::push_heap(c.begin(), c.end(), comp);
7577a984708SDavid Chisnall}
7587a984708SDavid Chisnall
759540d2a8bSDimitry Andric#endif  // _LIBCPP_CXX03_LANG
7607a984708SDavid Chisnall
7617a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7627c82a1ecSDimitry Andricinline
7637a984708SDavid Chisnallvoid
7647a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::pop()
7657a984708SDavid Chisnall{
7667a984708SDavid Chisnall    _VSTD::pop_heap(c.begin(), c.end(), comp);
7677a984708SDavid Chisnall    c.pop_back();
7687a984708SDavid Chisnall}
7697a984708SDavid Chisnall
7707a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7717c82a1ecSDimitry Andricinline
7727a984708SDavid Chisnallvoid
7737a984708SDavid Chisnallpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
7747a984708SDavid Chisnall        _NOEXCEPT_(__is_nothrow_swappable<container_type>::value &&
7757a984708SDavid Chisnall                   __is_nothrow_swappable<value_compare>::value)
7767a984708SDavid Chisnall{
7777a984708SDavid Chisnall    using _VSTD::swap;
7787a984708SDavid Chisnall    swap(c, __q.c);
7797a984708SDavid Chisnall    swap(comp, __q.comp);
7807a984708SDavid Chisnall}
7817a984708SDavid Chisnall
7827a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare>
7837a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY
7847c82a1ecSDimitry Andrictypename enable_if<
7857c82a1ecSDimitry Andric    __is_swappable<_Container>::value
7867c82a1ecSDimitry Andric    && __is_swappable<_Compare>::value,
7877a984708SDavid Chisnall    void
7887c82a1ecSDimitry Andric>::type
7897a984708SDavid Chisnallswap(priority_queue<_Tp, _Container, _Compare>& __x,
7907a984708SDavid Chisnall     priority_queue<_Tp, _Container, _Compare>& __y)
7917a984708SDavid Chisnall    _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
7927a984708SDavid Chisnall{
7937a984708SDavid Chisnall    __x.swap(__y);
7947a984708SDavid Chisnall}
7957a984708SDavid Chisnall
7967a984708SDavid Chisnalltemplate <class _Tp, class _Container, class _Compare, class _Alloc>
797aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
7987a984708SDavid Chisnall    : public uses_allocator<_Container, _Alloc>
7997a984708SDavid Chisnall{
8007a984708SDavid Chisnall};
8017a984708SDavid Chisnall
8027a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD
8037a984708SDavid Chisnall
8047a984708SDavid Chisnall#endif  // _LIBCPP_QUEUE
805