13e519524SHoward Hinnant// -*- C++ -*- 2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 103e519524SHoward Hinnant#ifndef _LIBCPP_QUEUE 113e519524SHoward Hinnant#define _LIBCPP_QUEUE 123e519524SHoward Hinnant 133e519524SHoward Hinnant/* 143e519524SHoward Hinnant queue synopsis 153e519524SHoward Hinnant 163e519524SHoward Hinnantnamespace std 173e519524SHoward Hinnant{ 183e519524SHoward Hinnant 193e519524SHoward Hinnanttemplate <class T, class Container = deque<T>> 203e519524SHoward Hinnantclass queue 213e519524SHoward Hinnant{ 223e519524SHoward Hinnantpublic: 233e519524SHoward Hinnant typedef Container container_type; 243e519524SHoward Hinnant typedef typename container_type::value_type value_type; 253e519524SHoward Hinnant typedef typename container_type::reference reference; 263e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 273e519524SHoward Hinnant typedef typename container_type::size_type size_type; 283e519524SHoward Hinnant 293e519524SHoward Hinnantprotected: 303e519524SHoward Hinnant container_type c; 313e519524SHoward Hinnant 323e519524SHoward Hinnantpublic: 336971d826SHoward Hinnant queue() = default; 346971d826SHoward Hinnant ~queue() = default; 356971d826SHoward Hinnant 366971d826SHoward Hinnant queue(const queue& q) = default; 376971d826SHoward Hinnant queue(queue&& q) = default; 386971d826SHoward Hinnant 396971d826SHoward Hinnant queue& operator=(const queue& q) = default; 406971d826SHoward Hinnant queue& operator=(queue&& q) = default; 416971d826SHoward Hinnant 423e519524SHoward Hinnant explicit queue(const container_type& c); 436971d826SHoward Hinnant explicit queue(container_type&& c) 44f3aed369SNikolas Klauser template<class InputIterator> 45f3aed369SNikolas Klauser queue(InputIterator first, InputIterator last); // since C++23 463e519524SHoward Hinnant template <class Alloc> 473e519524SHoward Hinnant explicit queue(const Alloc& a); 483e519524SHoward Hinnant template <class Alloc> 493e519524SHoward Hinnant queue(const container_type& c, const Alloc& a); 503e519524SHoward Hinnant template <class Alloc> 513e519524SHoward Hinnant queue(container_type&& c, const Alloc& a); 523e519524SHoward Hinnant template <class Alloc> 536971d826SHoward Hinnant queue(const queue& q, const Alloc& a); 546971d826SHoward Hinnant template <class Alloc> 553e519524SHoward Hinnant queue(queue&& q, const Alloc& a); 56f3aed369SNikolas Klauser template <class InputIterator, class Alloc> 57f3aed369SNikolas Klauser queue(InputIterator first, InputIterator last, const Alloc&); // since C++23 583e519524SHoward Hinnant 593e519524SHoward Hinnant bool empty() const; 603e519524SHoward Hinnant size_type size() const; 613e519524SHoward Hinnant 623e519524SHoward Hinnant reference front(); 633e519524SHoward Hinnant const_reference front() const; 643e519524SHoward Hinnant reference back(); 653e519524SHoward Hinnant const_reference back() const; 663e519524SHoward Hinnant 673e519524SHoward Hinnant void push(const value_type& v); 683e519524SHoward Hinnant void push(value_type&& v); 6963b560beSMarshall Clow template <class... Args> reference emplace(Args&&... args); // reference in C++17 703e519524SHoward Hinnant void pop(); 713e519524SHoward Hinnant 72f07dd8d0SEric Fiselier void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) 733e519524SHoward Hinnant}; 743e519524SHoward Hinnant 755b8b8b5dSMarshall Clowtemplate<class Container> 765b8b8b5dSMarshall Clow queue(Container) -> queue<typename Container::value_type, Container>; // C++17 775b8b8b5dSMarshall Clow 78f3aed369SNikolas Klausertemplate<class InputIterator> 79f3aed369SNikolas Klauser queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 80f3aed369SNikolas Klauser 815b8b8b5dSMarshall Clowtemplate<class Container, class Allocator> 825b8b8b5dSMarshall Clow queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 835b8b8b5dSMarshall Clow 84f3aed369SNikolas Klausertemplate<class InputIterator, class Allocator> 85f3aed369SNikolas Klauser queue(InputIterator, InputIterator, Allocator) 86f3aed369SNikolas Klauser -> queue<iter-value-type<InputIterator>, 87f3aed369SNikolas Klauser deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 88f3aed369SNikolas Klauser 893e519524SHoward Hinnanttemplate <class T, class Container> 903e519524SHoward Hinnant bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); 913e519524SHoward Hinnant 923e519524SHoward Hinnanttemplate <class T, class Container> 933e519524SHoward Hinnant bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); 943e519524SHoward Hinnant 953e519524SHoward Hinnanttemplate <class T, class Container> 963e519524SHoward Hinnant bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); 973e519524SHoward Hinnant 983e519524SHoward Hinnanttemplate <class T, class Container> 993e519524SHoward Hinnant bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); 1003e519524SHoward Hinnant 1013e519524SHoward Hinnanttemplate <class T, class Container> 1023e519524SHoward Hinnant bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); 1033e519524SHoward Hinnant 1043e519524SHoward Hinnanttemplate <class T, class Container> 1053e519524SHoward Hinnant bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); 1063e519524SHoward Hinnant 1073e519524SHoward Hinnanttemplate <class T, class Container> 1086971d826SHoward Hinnant void swap(queue<T, Container>& x, queue<T, Container>& y) 1096971d826SHoward Hinnant noexcept(noexcept(x.swap(y))); 1103e519524SHoward Hinnant 1113e519524SHoward Hinnanttemplate <class T, class Container = vector<T>, 1123e519524SHoward Hinnant class Compare = less<typename Container::value_type>> 1133e519524SHoward Hinnantclass priority_queue 1143e519524SHoward Hinnant{ 1153e519524SHoward Hinnantpublic: 1163e519524SHoward Hinnant typedef Container container_type; 1173e519524SHoward Hinnant typedef typename container_type::value_type value_type; 1183e519524SHoward Hinnant typedef typename container_type::reference reference; 1193e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 1203e519524SHoward Hinnant typedef typename container_type::size_type size_type; 1213e519524SHoward Hinnant 1223e519524SHoward Hinnantprotected: 1233e519524SHoward Hinnant container_type c; 1243e519524SHoward Hinnant Compare comp; 1253e519524SHoward Hinnant 1263e519524SHoward Hinnantpublic: 127a11f8b1aSMarek Kurdej priority_queue() : priority_queue(Compare()) {} // C++20 128a11f8b1aSMarek Kurdej explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} 129a11f8b1aSMarek Kurdej priority_queue(const Compare& x, const Container&); 130a11f8b1aSMarek Kurdej explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 131a11f8b1aSMarek Kurdej priority_queue(const Compare& x, Container&&); // C++20 1323e519524SHoward Hinnant template <class InputIterator> 1333e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1343e519524SHoward Hinnant const Compare& comp = Compare()); 1353e519524SHoward Hinnant template <class InputIterator> 1363e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1373894a8a4SArthur O'Dwyer const Compare& comp, const Container& c); 1383e519524SHoward Hinnant template <class InputIterator> 1393e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1403894a8a4SArthur O'Dwyer const Compare& comp, Container&& c); 1413e519524SHoward Hinnant template <class Alloc> 1423e519524SHoward Hinnant explicit priority_queue(const Alloc& a); 1433e519524SHoward Hinnant template <class Alloc> 1443e519524SHoward Hinnant priority_queue(const Compare& comp, const Alloc& a); 1453e519524SHoward Hinnant template <class Alloc> 1463894a8a4SArthur O'Dwyer priority_queue(const Compare& comp, const Container& c, 1473e519524SHoward Hinnant const Alloc& a); 1483e519524SHoward Hinnant template <class Alloc> 1493894a8a4SArthur O'Dwyer priority_queue(const Compare& comp, Container&& c, 1503e519524SHoward Hinnant const Alloc& a); 1513894a8a4SArthur O'Dwyer template <class InputIterator> 1523894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1533894a8a4SArthur O'Dwyer const Alloc& a); 1543894a8a4SArthur O'Dwyer template <class InputIterator> 1553894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1563894a8a4SArthur O'Dwyer const Compare& comp, const Alloc& a); 1573894a8a4SArthur O'Dwyer template <class InputIterator> 1583894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1593894a8a4SArthur O'Dwyer const Compare& comp, const Container& c, const Alloc& a); 1603894a8a4SArthur O'Dwyer template <class InputIterator> 1613894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1623894a8a4SArthur O'Dwyer const Compare& comp, Container&& c, const Alloc& a); 1633e519524SHoward Hinnant template <class Alloc> 1646971d826SHoward Hinnant priority_queue(const priority_queue& q, const Alloc& a); 1656971d826SHoward Hinnant template <class Alloc> 1663e519524SHoward Hinnant priority_queue(priority_queue&& q, const Alloc& a); 1673e519524SHoward Hinnant 1683e519524SHoward Hinnant bool empty() const; 1693e519524SHoward Hinnant size_type size() const; 1703e519524SHoward Hinnant const_reference top() const; 1713e519524SHoward Hinnant 1723e519524SHoward Hinnant void push(const value_type& v); 1733e519524SHoward Hinnant void push(value_type&& v); 1743e519524SHoward Hinnant template <class... Args> void emplace(Args&&... args); 1753e519524SHoward Hinnant void pop(); 1763e519524SHoward Hinnant 1776971d826SHoward Hinnant void swap(priority_queue& q) 178f07dd8d0SEric Fiselier noexcept(is_nothrow_swappable_v<Container> && 179f07dd8d0SEric Fiselier is_nothrow_swappable_v<Comp>) 1803e519524SHoward Hinnant}; 1813e519524SHoward Hinnant 1825b8b8b5dSMarshall Clowtemplate <class Compare, class Container> 1835b8b8b5dSMarshall Clowpriority_queue(Compare, Container) 1845b8b8b5dSMarshall Clow -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1855b8b8b5dSMarshall Clow 1865b8b8b5dSMarshall Clowtemplate<class InputIterator, 1873894a8a4SArthur O'Dwyer class Compare = less<iter-value-type<InputIterator>>, 1883894a8a4SArthur O'Dwyer class Container = vector<iter-value-type<InputIterator>>> 1895b8b8b5dSMarshall Clowpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) 1903894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 1915b8b8b5dSMarshall Clow 1925b8b8b5dSMarshall Clowtemplate<class Compare, class Container, class Allocator> 1935b8b8b5dSMarshall Clowpriority_queue(Compare, Container, Allocator) 1945b8b8b5dSMarshall Clow -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1955b8b8b5dSMarshall Clow 1963894a8a4SArthur O'Dwyertemplate<class InputIterator, class Allocator> 1973894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Allocator) 1983894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, 1993894a8a4SArthur O'Dwyer vector<iter-value-type<InputIterator>, Allocator>, 20068072a71SKonstantin Varlamov less<iter-value-type<InputIterator>>>; // C++17 2013894a8a4SArthur O'Dwyer 2023894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Allocator> 2033894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Allocator) 2043894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, 20568072a71SKonstantin Varlamov vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 2063894a8a4SArthur O'Dwyer 2073894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Container, class Allocator> 2083894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator) 20968072a71SKonstantin Varlamov -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 2103894a8a4SArthur O'Dwyer 2113e519524SHoward Hinnanttemplate <class T, class Container, class Compare> 2123e519524SHoward Hinnant void swap(priority_queue<T, Container, Compare>& x, 2136971d826SHoward Hinnant priority_queue<T, Container, Compare>& y) 2146971d826SHoward Hinnant noexcept(noexcept(x.swap(y))); 2153e519524SHoward Hinnant 2163e519524SHoward Hinnant} // std 2173e519524SHoward Hinnant 2183e519524SHoward Hinnant*/ 2193e519524SHoward Hinnant 2202e2f3158SNikolas Klauser#include <__algorithm/make_heap.h> 2212e2f3158SNikolas Klauser#include <__algorithm/pop_heap.h> 2222e2f3158SNikolas Klauser#include <__algorithm/push_heap.h> 223385cc25aSLouis Dionne#include <__assert> // all public C++ headers provide the assertion handler 2243e519524SHoward Hinnant#include <__config> 225*34f73804SNikolas Klauser#include <__functional/operations.h> 226f3aed369SNikolas Klauser#include <__iterator/iterator_traits.h> 227050b064fSChristopher Di Bella#include <__memory/uses_allocator.h> 2286adbc83eSChristopher Di Bella#include <__utility/forward.h> 2292d0f1fa4SArthur O'Dwyer#include <compare> 2303e519524SHoward Hinnant#include <deque> 231f3aed369SNikolas Klauser#include <type_traits> 232bfbd73f8SArthur O'Dwyer#include <vector> 233bd6e6846SMark de Wever#include <version> 2343e519524SHoward Hinnant 235073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2363e519524SHoward Hinnant# pragma GCC system_header 237073458b1SHoward Hinnant#endif 2383e519524SHoward Hinnant 2393e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 2403e519524SHoward Hinnant 241e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2423e519524SHoward Hinnant 2433e519524SHoward Hinnanttemplate <class _Tp, class _Container> 244aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2453e519524SHoward Hinnantbool 2463e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2473e519524SHoward Hinnant 2483e519524SHoward Hinnanttemplate <class _Tp, class _Container> 249aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2503e519524SHoward Hinnantbool 2513e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2523e519524SHoward Hinnant 2533afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/> 254e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue 2553e519524SHoward Hinnant{ 2563e519524SHoward Hinnantpublic: 2573e519524SHoward Hinnant typedef _Container container_type; 2583e519524SHoward Hinnant typedef typename container_type::value_type value_type; 2593e519524SHoward Hinnant typedef typename container_type::reference reference; 2603e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 2613e519524SHoward Hinnant typedef typename container_type::size_type size_type; 262c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 2633e519524SHoward Hinnant 2643e519524SHoward Hinnantprotected: 2653e519524SHoward Hinnant container_type c; 2663e519524SHoward Hinnant 2673e519524SHoward Hinnantpublic: 268392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2696971d826SHoward Hinnant queue() 2706971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2716971d826SHoward Hinnant : c() {} 2726971d826SHoward Hinnant 2736971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2746971d826SHoward Hinnant queue(const queue& __q) : c(__q.c) {} 2756971d826SHoward Hinnant 276f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 277f3aed369SNikolas Klauser template <class _InputIterator, 278f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 279f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 280f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 281f3aed369SNikolas Klauser 282f3aed369SNikolas Klauser template <class _InputIterator, 283f3aed369SNikolas Klauser class _Alloc, 284f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 285f3aed369SNikolas Klauser class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 286f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 287f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 288f3aed369SNikolas Klauser#endif 289f3aed369SNikolas Klauser 290f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 291f5427b26SEric Fiselier queue& operator=(const queue& __q) {c = __q.c; return *this;} 292f5427b26SEric Fiselier 293f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2946971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2956971d826SHoward Hinnant queue(queue&& __q) 2966971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 297ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)) {} 2986971d826SHoward Hinnant 2996971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3006971d826SHoward Hinnant queue& operator=(queue&& __q) 3016971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 302ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); return *this;} 303f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3046971d826SHoward Hinnant 305392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3063e519524SHoward Hinnant explicit queue(const container_type& __c) : c(__c) {} 307f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 308392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 309ce48a113SHoward Hinnant explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 310f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3113e519524SHoward Hinnant template <class _Alloc> 312392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3133e519524SHoward Hinnant explicit queue(const _Alloc& __a, 314b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3153e519524SHoward Hinnant : c(__a) {} 3163e519524SHoward Hinnant template <class _Alloc> 317392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3183e519524SHoward Hinnant queue(const queue& __q, const _Alloc& __a, 319b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3203e519524SHoward Hinnant : c(__q.c, __a) {} 3213e519524SHoward Hinnant template <class _Alloc> 322392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3233e519524SHoward Hinnant queue(const container_type& __c, const _Alloc& __a, 324b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3253e519524SHoward Hinnant : c(__c, __a) {} 326f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 3273e519524SHoward Hinnant template <class _Alloc> 328392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3293e519524SHoward Hinnant queue(container_type&& __c, const _Alloc& __a, 330b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 331ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a) {} 3323e519524SHoward Hinnant template <class _Alloc> 333392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3343e519524SHoward Hinnant queue(queue&& __q, const _Alloc& __a, 335b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 336ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a) {} 3373e519524SHoward Hinnant 338f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3393e519524SHoward Hinnant 34072c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3413e519524SHoward Hinnant bool empty() const {return c.empty();} 342392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3433e519524SHoward Hinnant size_type size() const {return c.size();} 3443e519524SHoward Hinnant 345392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3463e519524SHoward Hinnant reference front() {return c.front();} 347392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3483e519524SHoward Hinnant const_reference front() const {return c.front();} 349392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3503e519524SHoward Hinnant reference back() {return c.back();} 351392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3523e519524SHoward Hinnant const_reference back() const {return c.back();} 3533e519524SHoward Hinnant 354392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3553e519524SHoward Hinnant void push(const value_type& __v) {c.push_back(__v);} 356f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 357392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 358ce48a113SHoward Hinnant void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3593e519524SHoward Hinnant template <class... _Args> 360392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 36163b560beSMarshall Clow#if _LIBCPP_STD_VER > 14 362e34f5ffeSMarshall Clow decltype(auto) emplace(_Args&&... __args) 3630e411641SEric Fiselier { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 36463b560beSMarshall Clow#else 36563b560beSMarshall Clow void emplace(_Args&&... __args) 36663b560beSMarshall Clow { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 36763b560beSMarshall Clow#endif 368f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 369392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3703e519524SHoward Hinnant void pop() {c.pop_front();} 3713e519524SHoward Hinnant 372392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3733e519524SHoward Hinnant void swap(queue& __q) 3746971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3753e519524SHoward Hinnant { 376ce48a113SHoward Hinnant using _VSTD::swap; 3773e519524SHoward Hinnant swap(c, __q.c); 3783e519524SHoward Hinnant } 3793e519524SHoward Hinnant 3803e519524SHoward Hinnant template <class _T1, class _C1> 3813e519524SHoward Hinnant friend 382392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3833e519524SHoward Hinnant bool 3843e519524SHoward Hinnant operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3853e519524SHoward Hinnant 3863e519524SHoward Hinnant template <class _T1, class _C1> 3873e519524SHoward Hinnant friend 388392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3893e519524SHoward Hinnant bool 3903e519524SHoward Hinnant operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3913e519524SHoward Hinnant}; 3923e519524SHoward Hinnant 393f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14 3945b8b8b5dSMarshall Clowtemplate<class _Container, 3954e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 3965b8b8b5dSMarshall Clow> 3975b8b8b5dSMarshall Clowqueue(_Container) 3985b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 3995b8b8b5dSMarshall Clow 4005b8b8b5dSMarshall Clowtemplate<class _Container, 4015b8b8b5dSMarshall Clow class _Alloc, 4024e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 4034e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4045b8b8b5dSMarshall Clow> 4055b8b8b5dSMarshall Clowqueue(_Container, _Alloc) 4065b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4075b8b8b5dSMarshall Clow#endif 4085b8b8b5dSMarshall Clow 409f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 410f3aed369SNikolas Klausertemplate <class _InputIterator, 411f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 412f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator) 413f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>>; 414f3aed369SNikolas Klauser 415f3aed369SNikolas Klausertemplate <class _InputIterator, 416f3aed369SNikolas Klauser class _Alloc, 417f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 418f3aed369SNikolas Klauser class = __enable_if_t<__is_allocator<_Alloc>::value>> 419f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator, _Alloc) 420f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 421f3aed369SNikolas Klauser#endif 422f3aed369SNikolas Klauser 4233e519524SHoward Hinnanttemplate <class _Tp, class _Container> 424392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4253e519524SHoward Hinnantbool 4263e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4273e519524SHoward Hinnant{ 4283e519524SHoward Hinnant return __x.c == __y.c; 4293e519524SHoward Hinnant} 4303e519524SHoward Hinnant 4313e519524SHoward Hinnanttemplate <class _Tp, class _Container> 432392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4333e519524SHoward Hinnantbool 4343e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4353e519524SHoward Hinnant{ 4363e519524SHoward Hinnant return __x.c < __y.c; 4373e519524SHoward Hinnant} 4383e519524SHoward Hinnant 4393e519524SHoward Hinnanttemplate <class _Tp, class _Container> 440392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4413e519524SHoward Hinnantbool 4423e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4433e519524SHoward Hinnant{ 4443e519524SHoward Hinnant return !(__x == __y); 4453e519524SHoward Hinnant} 4463e519524SHoward Hinnant 4473e519524SHoward Hinnanttemplate <class _Tp, class _Container> 448392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4493e519524SHoward Hinnantbool 4503e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4513e519524SHoward Hinnant{ 4523e519524SHoward Hinnant return __y < __x; 4533e519524SHoward Hinnant} 4543e519524SHoward Hinnant 4553e519524SHoward Hinnanttemplate <class _Tp, class _Container> 456392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4573e519524SHoward Hinnantbool 4583e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4593e519524SHoward Hinnant{ 4603e519524SHoward Hinnant return !(__x < __y); 4613e519524SHoward Hinnant} 4623e519524SHoward Hinnant 4633e519524SHoward Hinnanttemplate <class _Tp, class _Container> 464392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4653e519524SHoward Hinnantbool 4663e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4673e519524SHoward Hinnant{ 4683e519524SHoward Hinnant return !(__y < __x); 4693e519524SHoward Hinnant} 4703e519524SHoward Hinnant 4713e519524SHoward Hinnanttemplate <class _Tp, class _Container> 472392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 473b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void> 4743e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4756971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4763e519524SHoward Hinnant{ 4773e519524SHoward Hinnant __x.swap(__y); 4783e519524SHoward Hinnant} 4793e519524SHoward Hinnant 4803e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc> 481e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4823e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 4833e519524SHoward Hinnant{ 4843e519524SHoward Hinnant}; 4853e519524SHoward Hinnant 4863e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>, 4873e519524SHoward Hinnant class _Compare = less<typename _Container::value_type> > 488e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue 4893e519524SHoward Hinnant{ 4903e519524SHoward Hinnantpublic: 4913e519524SHoward Hinnant typedef _Container container_type; 4923e519524SHoward Hinnant typedef _Compare value_compare; 4933e519524SHoward Hinnant typedef typename container_type::value_type value_type; 4943e519524SHoward Hinnant typedef typename container_type::reference reference; 4953e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 4963e519524SHoward Hinnant typedef typename container_type::size_type size_type; 497c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 4983e519524SHoward Hinnant 4993e519524SHoward Hinnantprotected: 5003e519524SHoward Hinnant container_type c; 5013e519524SHoward Hinnant value_compare comp; 5023e519524SHoward Hinnant 5033e519524SHoward Hinnantpublic: 504392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5056971d826SHoward Hinnant priority_queue() 5066971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 5076971d826SHoward Hinnant is_nothrow_default_constructible<value_compare>::value) 5086971d826SHoward Hinnant : c(), comp() {} 5096971d826SHoward Hinnant 5106971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5116971d826SHoward Hinnant priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5126971d826SHoward Hinnant 513f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 514f5427b26SEric Fiselier priority_queue& operator=(const priority_queue& __q) 515f5427b26SEric Fiselier {c = __q.c; comp = __q.comp; return *this;} 516f5427b26SEric Fiselier 517f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5186971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5196971d826SHoward Hinnant priority_queue(priority_queue&& __q) 5206971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 5216971d826SHoward Hinnant is_nothrow_move_constructible<value_compare>::value) 522ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 5236971d826SHoward Hinnant 5246971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5256971d826SHoward Hinnant priority_queue& operator=(priority_queue&& __q) 5266971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 5276971d826SHoward Hinnant is_nothrow_move_assignable<value_compare>::value) 528ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 529f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5306971d826SHoward Hinnant 5316971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5326971d826SHoward Hinnant explicit priority_queue(const value_compare& __comp) 5333e519524SHoward Hinnant : c(), comp(__comp) {} 534cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5353e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c); 536f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 537cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 538a11f8b1aSMarek Kurdej priority_queue(const value_compare& __comp, container_type&& __c); 5393e519524SHoward Hinnant#endif 540b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 541cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5423e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5433e519524SHoward Hinnant const value_compare& __comp = value_compare()); 544b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 545cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5463e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5473e519524SHoward Hinnant const value_compare& __comp, const container_type& __c); 548f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 549b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 550cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5513e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5523e519524SHoward Hinnant const value_compare& __comp, container_type&& __c); 553f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5543e519524SHoward Hinnant template <class _Alloc> 555cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5563e519524SHoward Hinnant explicit priority_queue(const _Alloc& __a, 557b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5583e519524SHoward Hinnant template <class _Alloc> 559cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5603e519524SHoward Hinnant priority_queue(const value_compare& __comp, const _Alloc& __a, 561b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5623e519524SHoward Hinnant template <class _Alloc> 563cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5643e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c, 5653e519524SHoward Hinnant const _Alloc& __a, 566b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5673e519524SHoward Hinnant template <class _Alloc> 568cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5693e519524SHoward Hinnant priority_queue(const priority_queue& __q, const _Alloc& __a, 570b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 571f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5723e519524SHoward Hinnant template <class _Alloc> 573cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5743e519524SHoward Hinnant priority_queue(const value_compare& __comp, container_type&& __c, 5753e519524SHoward Hinnant const _Alloc& __a, 576b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5773e519524SHoward Hinnant template <class _Alloc> 578cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5793e519524SHoward Hinnant priority_queue(priority_queue&& __q, const _Alloc& __a, 580b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 581f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5823e519524SHoward Hinnant 583b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5843894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5853894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 586b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5873894a8a4SArthur O'Dwyer 588b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5893894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5903894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5913894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 592b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5933894a8a4SArthur O'Dwyer 594b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5953894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5963894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5973894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 598b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5993894a8a4SArthur O'Dwyer 6003894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 601b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 6023894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 6033894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 6043894a8a4SArthur O'Dwyer const value_compare& __comp, container_type&& __c, const _Alloc& __a, 605b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6063894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 6073894a8a4SArthur O'Dwyer 60872c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6093e519524SHoward Hinnant bool empty() const {return c.empty();} 610392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6113e519524SHoward Hinnant size_type size() const {return c.size();} 612392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6133e519524SHoward Hinnant const_reference top() const {return c.front();} 6143e519524SHoward Hinnant 615cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6163e519524SHoward Hinnant void push(const value_type& __v); 617f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 618cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6193e519524SHoward Hinnant void push(value_type&& __v); 620f5427b26SEric Fiselier template <class... _Args> 621f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 622f5427b26SEric Fiselier void emplace(_Args&&... __args); 623f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 624cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6253e519524SHoward Hinnant void pop(); 6263e519524SHoward Hinnant 627cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6286971d826SHoward Hinnant void swap(priority_queue& __q) 6296971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 6306971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value); 6313e519524SHoward Hinnant}; 6323e519524SHoward Hinnant 63301666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 6345b8b8b5dSMarshall Clowtemplate <class _Compare, 6355b8b8b5dSMarshall Clow class _Container, 6364e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6374e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6385b8b8b5dSMarshall Clow> 6395b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container) 6405b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6415b8b8b5dSMarshall Clow 6425b8b8b5dSMarshall Clowtemplate<class _InputIterator, 643199d2ebeSArthur O'Dwyer class _Compare = less<__iter_value_type<_InputIterator>>, 644199d2ebeSArthur O'Dwyer class _Container = vector<__iter_value_type<_InputIterator>>, 6454e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6464e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6474e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6485b8b8b5dSMarshall Clow> 6495b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 650199d2ebeSArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6515b8b8b5dSMarshall Clow 6525b8b8b5dSMarshall Clowtemplate<class _Compare, 6535b8b8b5dSMarshall Clow class _Container, 6545b8b8b5dSMarshall Clow class _Alloc, 6554e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6564e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6574e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6585b8b8b5dSMarshall Clow> 6595b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc) 6605b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6613894a8a4SArthur O'Dwyer 6623894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator, 6634e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6644e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6653894a8a4SArthur O'Dwyer> 6663894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator) 6673894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6683894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, 6693894a8a4SArthur O'Dwyer less<__iter_value_type<_InputIterator>>>; 6703894a8a4SArthur O'Dwyer 6713894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator, 6724e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6734e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6744e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6753894a8a4SArthur O'Dwyer> 6763894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 6773894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6783894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 6793894a8a4SArthur O'Dwyer 6803894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 6814e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6824e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6834e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6844e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6853894a8a4SArthur O'Dwyer> 6863894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 6873894a8a4SArthur O'Dwyer -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6885b8b8b5dSMarshall Clow#endif 6895b8b8b5dSMarshall Clow 6903e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 691cd31b434SEvgeniy Stepanovinline 6923e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6933e519524SHoward Hinnant const container_type& __c) 6943e519524SHoward Hinnant : c(__c), 6953e519524SHoward Hinnant comp(__comp) 6963e519524SHoward Hinnant{ 697ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6983e519524SHoward Hinnant} 6993e519524SHoward Hinnant 700f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7013e519524SHoward Hinnant 7023e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 703cd31b434SEvgeniy Stepanovinline 7043e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7053e519524SHoward Hinnant container_type&& __c) 706ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7073e519524SHoward Hinnant comp(__comp) 7083e519524SHoward Hinnant{ 709ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7103e519524SHoward Hinnant} 7113e519524SHoward Hinnant 712f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7133e519524SHoward Hinnant 7143e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7153894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 716cd31b434SEvgeniy Stepanovinline 7173e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7183e519524SHoward Hinnant const value_compare& __comp) 7193e519524SHoward Hinnant : c(__f, __l), 7203e519524SHoward Hinnant comp(__comp) 7213e519524SHoward Hinnant{ 722ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7233e519524SHoward Hinnant} 7243e519524SHoward Hinnant 7253e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7263894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 727cd31b434SEvgeniy Stepanovinline 7283e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7293e519524SHoward Hinnant const value_compare& __comp, 7303e519524SHoward Hinnant const container_type& __c) 7313e519524SHoward Hinnant : c(__c), 7323e519524SHoward Hinnant comp(__comp) 7333e519524SHoward Hinnant{ 7343e519524SHoward Hinnant c.insert(c.end(), __f, __l); 735ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7363e519524SHoward Hinnant} 7373e519524SHoward Hinnant 738f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7393e519524SHoward Hinnant 7403e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7413894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 742cd31b434SEvgeniy Stepanovinline 7433e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7443e519524SHoward Hinnant const value_compare& __comp, 7453e519524SHoward Hinnant container_type&& __c) 746ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7473e519524SHoward Hinnant comp(__comp) 7483e519524SHoward Hinnant{ 7493e519524SHoward Hinnant c.insert(c.end(), __f, __l); 750ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7513e519524SHoward Hinnant} 7523e519524SHoward Hinnant 753f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7543e519524SHoward Hinnant 7553e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7563e519524SHoward Hinnanttemplate <class _Alloc> 757cd31b434SEvgeniy Stepanovinline 7583e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 759b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7603e519524SHoward Hinnant : c(__a) 7613e519524SHoward Hinnant{ 7623e519524SHoward Hinnant} 7633e519524SHoward Hinnant 7643e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7653e519524SHoward Hinnanttemplate <class _Alloc> 766cd31b434SEvgeniy Stepanovinline 7673e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7683e519524SHoward Hinnant const _Alloc& __a, 769b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7703e519524SHoward Hinnant : c(__a), 7713e519524SHoward Hinnant comp(__comp) 7723e519524SHoward Hinnant{ 7733e519524SHoward Hinnant} 7743e519524SHoward Hinnant 7753e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7763e519524SHoward Hinnanttemplate <class _Alloc> 777cd31b434SEvgeniy Stepanovinline 7783e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7793e519524SHoward Hinnant const container_type& __c, 7803e519524SHoward Hinnant const _Alloc& __a, 781b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7823e519524SHoward Hinnant : c(__c, __a), 7833e519524SHoward Hinnant comp(__comp) 7843e519524SHoward Hinnant{ 785ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7863e519524SHoward Hinnant} 7873e519524SHoward Hinnant 7883e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7893e519524SHoward Hinnanttemplate <class _Alloc> 790cd31b434SEvgeniy Stepanovinline 7913e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7923e519524SHoward Hinnant const _Alloc& __a, 793b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7943e519524SHoward Hinnant : c(__q.c, __a), 7953e519524SHoward Hinnant comp(__q.comp) 7963e519524SHoward Hinnant{ 7973e519524SHoward Hinnant} 7983e519524SHoward Hinnant 799f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8003e519524SHoward Hinnant 8013e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8023e519524SHoward Hinnanttemplate <class _Alloc> 803cd31b434SEvgeniy Stepanovinline 8043e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8053e519524SHoward Hinnant container_type&& __c, 8063e519524SHoward Hinnant const _Alloc& __a, 807b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 808ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a), 8093e519524SHoward Hinnant comp(__comp) 8103e519524SHoward Hinnant{ 811ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8123e519524SHoward Hinnant} 8133e519524SHoward Hinnant 8143e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8153e519524SHoward Hinnanttemplate <class _Alloc> 816cd31b434SEvgeniy Stepanovinline 8173e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 8183e519524SHoward Hinnant const _Alloc& __a, 819b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 820ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a), 821ce48a113SHoward Hinnant comp(_VSTD::move(__q.comp)) 8223e519524SHoward Hinnant{ 8233894a8a4SArthur O'Dwyer} 8243894a8a4SArthur O'Dwyer 8253894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 8263894a8a4SArthur O'Dwyer 8273894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8283894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8293894a8a4SArthur O'Dwyerinline 8303894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8313894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const _Alloc& __a, 832b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8333894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8343894a8a4SArthur O'Dwyer comp() 8353894a8a4SArthur O'Dwyer{ 836ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8373e519524SHoward Hinnant} 8383e519524SHoward Hinnant 8393894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8403894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8413894a8a4SArthur O'Dwyerinline 8423894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8433894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8443894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 845b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8463894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8473894a8a4SArthur O'Dwyer comp(__comp) 8483894a8a4SArthur O'Dwyer{ 8493894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8503894a8a4SArthur O'Dwyer} 8513894a8a4SArthur O'Dwyer 8523894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8533894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8543894a8a4SArthur O'Dwyerinline 8553894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8563894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8573894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 858b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8593894a8a4SArthur O'Dwyer : c(__c, __a), 8603894a8a4SArthur O'Dwyer comp(__comp) 8613894a8a4SArthur O'Dwyer{ 8623894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8633894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8643894a8a4SArthur O'Dwyer} 8653894a8a4SArthur O'Dwyer 8663894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 8673894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8683894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8693894a8a4SArthur O'Dwyerinline 8703894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8713894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const value_compare& __comp, 8723894a8a4SArthur O'Dwyer container_type&& __c, const _Alloc& __a, 873b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8743894a8a4SArthur O'Dwyer : c(_VSTD::move(__c), __a), 8753894a8a4SArthur O'Dwyer comp(__comp) 8763894a8a4SArthur O'Dwyer{ 8773894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8783894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8793894a8a4SArthur O'Dwyer} 880f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8813e519524SHoward Hinnant 8823e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 883cd31b434SEvgeniy Stepanovinline 8843e519524SHoward Hinnantvoid 8853e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8863e519524SHoward Hinnant{ 8873e519524SHoward Hinnant c.push_back(__v); 888ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8893e519524SHoward Hinnant} 8903e519524SHoward Hinnant 891f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8923e519524SHoward Hinnant 8933e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 894cd31b434SEvgeniy Stepanovinline 8953e519524SHoward Hinnantvoid 8963e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 8973e519524SHoward Hinnant{ 898ce48a113SHoward Hinnant c.push_back(_VSTD::move(__v)); 899ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9003e519524SHoward Hinnant} 9013e519524SHoward Hinnant 9023e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 9033e519524SHoward Hinnanttemplate <class... _Args> 904cd31b434SEvgeniy Stepanovinline 9053e519524SHoward Hinnantvoid 9063e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 9073e519524SHoward Hinnant{ 908ce48a113SHoward Hinnant c.emplace_back(_VSTD::forward<_Args>(__args)...); 909ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9103e519524SHoward Hinnant} 9113e519524SHoward Hinnant 912f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 9133e519524SHoward Hinnant 9143e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 915cd31b434SEvgeniy Stepanovinline 9163e519524SHoward Hinnantvoid 9173e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop() 9183e519524SHoward Hinnant{ 919ce48a113SHoward Hinnant _VSTD::pop_heap(c.begin(), c.end(), comp); 9203e519524SHoward Hinnant c.pop_back(); 9213e519524SHoward Hinnant} 9223e519524SHoward Hinnant 9233e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 924cd31b434SEvgeniy Stepanovinline 9253e519524SHoward Hinnantvoid 9263e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 9276971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 9286971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value) 9293e519524SHoward Hinnant{ 930ce48a113SHoward Hinnant using _VSTD::swap; 9313e519524SHoward Hinnant swap(c, __q.c); 9323e519524SHoward Hinnant swap(comp, __q.comp); 9333e519524SHoward Hinnant} 9343e519524SHoward Hinnant 9353e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 936392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 937b4e88d4dSLouis Dionne__enable_if_t< 938199d2ebeSArthur O'Dwyer __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 9393e519524SHoward Hinnant void 940199d2ebeSArthur O'Dwyer> 9413e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x, 9423e519524SHoward Hinnant priority_queue<_Tp, _Container, _Compare>& __y) 9436971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9443e519524SHoward Hinnant{ 9453e519524SHoward Hinnant __x.swap(__y); 9463e519524SHoward Hinnant} 9473e519524SHoward Hinnant 9483e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc> 949e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9503e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 9513e519524SHoward Hinnant{ 9523e519524SHoward Hinnant}; 9533e519524SHoward Hinnant 9543e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 9553e519524SHoward Hinnant 9563e519524SHoward Hinnant#endif // _LIBCPP_QUEUE 957