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> 22534f73804SNikolas 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> 2293e519524SHoward Hinnant#include <deque> 230f3aed369SNikolas Klauser#include <type_traits> 231bfbd73f8SArthur O'Dwyer#include <vector> 232bd6e6846SMark de Wever#include <version> 2333e519524SHoward Hinnant 234*db1978b6SNikolas Klauser// standard-mandated includes 235*db1978b6SNikolas Klauser#include <compare> 236*db1978b6SNikolas Klauser#include <initializer_list> 237*db1978b6SNikolas Klauser 238073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2393e519524SHoward Hinnant# pragma GCC system_header 240073458b1SHoward Hinnant#endif 2413e519524SHoward Hinnant 2423e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 2433e519524SHoward Hinnant 244e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2453e519524SHoward Hinnant 2463e519524SHoward Hinnanttemplate <class _Tp, class _Container> 247aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2483e519524SHoward Hinnantbool 2493e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2503e519524SHoward Hinnant 2513e519524SHoward Hinnanttemplate <class _Tp, class _Container> 252aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2533e519524SHoward Hinnantbool 2543e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2553e519524SHoward Hinnant 2563afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/> 257e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue 2583e519524SHoward Hinnant{ 2593e519524SHoward Hinnantpublic: 2603e519524SHoward Hinnant typedef _Container container_type; 2613e519524SHoward Hinnant typedef typename container_type::value_type value_type; 2623e519524SHoward Hinnant typedef typename container_type::reference reference; 2633e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 2643e519524SHoward Hinnant typedef typename container_type::size_type size_type; 265c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 2663e519524SHoward Hinnant 2673e519524SHoward Hinnantprotected: 2683e519524SHoward Hinnant container_type c; 2693e519524SHoward Hinnant 2703e519524SHoward Hinnantpublic: 271392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2726971d826SHoward Hinnant queue() 2736971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2746971d826SHoward Hinnant : c() {} 2756971d826SHoward Hinnant 2766971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2776971d826SHoward Hinnant queue(const queue& __q) : c(__q.c) {} 2786971d826SHoward Hinnant 279f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 280f3aed369SNikolas Klauser template <class _InputIterator, 281f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 282f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 283f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 284f3aed369SNikolas Klauser 285f3aed369SNikolas Klauser template <class _InputIterator, 286f3aed369SNikolas Klauser class _Alloc, 287f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 288f3aed369SNikolas Klauser class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 289f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 290f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 291f3aed369SNikolas Klauser#endif 292f3aed369SNikolas Klauser 293f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 294f5427b26SEric Fiselier queue& operator=(const queue& __q) {c = __q.c; return *this;} 295f5427b26SEric Fiselier 296f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2976971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2986971d826SHoward Hinnant queue(queue&& __q) 2996971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 300ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)) {} 3016971d826SHoward Hinnant 3026971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3036971d826SHoward Hinnant queue& operator=(queue&& __q) 3046971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 305ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); return *this;} 306f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3076971d826SHoward Hinnant 308392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3093e519524SHoward Hinnant explicit queue(const container_type& __c) : c(__c) {} 310f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 311392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 312ce48a113SHoward Hinnant explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 313f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3143e519524SHoward Hinnant template <class _Alloc> 315392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3163e519524SHoward Hinnant explicit queue(const _Alloc& __a, 317b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3183e519524SHoward Hinnant : c(__a) {} 3193e519524SHoward Hinnant template <class _Alloc> 320392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3213e519524SHoward Hinnant queue(const queue& __q, const _Alloc& __a, 322b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3233e519524SHoward Hinnant : c(__q.c, __a) {} 3243e519524SHoward Hinnant template <class _Alloc> 325392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3263e519524SHoward Hinnant queue(const container_type& __c, const _Alloc& __a, 327b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3283e519524SHoward Hinnant : c(__c, __a) {} 329f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 3303e519524SHoward Hinnant template <class _Alloc> 331392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3323e519524SHoward Hinnant queue(container_type&& __c, const _Alloc& __a, 333b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 334ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a) {} 3353e519524SHoward Hinnant template <class _Alloc> 336392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3373e519524SHoward Hinnant queue(queue&& __q, const _Alloc& __a, 338b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 339ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a) {} 3403e519524SHoward Hinnant 341f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3423e519524SHoward Hinnant 34372c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3443e519524SHoward Hinnant bool empty() const {return c.empty();} 345392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3463e519524SHoward Hinnant size_type size() const {return c.size();} 3473e519524SHoward Hinnant 348392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3493e519524SHoward Hinnant reference front() {return c.front();} 350392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3513e519524SHoward Hinnant const_reference front() const {return c.front();} 352392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3533e519524SHoward Hinnant reference back() {return c.back();} 354392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3553e519524SHoward Hinnant const_reference back() const {return c.back();} 3563e519524SHoward Hinnant 357392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3583e519524SHoward Hinnant void push(const value_type& __v) {c.push_back(__v);} 359f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 360392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 361ce48a113SHoward Hinnant void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3623e519524SHoward Hinnant template <class... _Args> 363392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 36463b560beSMarshall Clow#if _LIBCPP_STD_VER > 14 365e34f5ffeSMarshall Clow decltype(auto) emplace(_Args&&... __args) 3660e411641SEric Fiselier { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 36763b560beSMarshall Clow#else 36863b560beSMarshall Clow void emplace(_Args&&... __args) 36963b560beSMarshall Clow { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 37063b560beSMarshall Clow#endif 371f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 372392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3733e519524SHoward Hinnant void pop() {c.pop_front();} 3743e519524SHoward Hinnant 375392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3763e519524SHoward Hinnant void swap(queue& __q) 3776971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3783e519524SHoward Hinnant { 379ce48a113SHoward Hinnant using _VSTD::swap; 3803e519524SHoward Hinnant swap(c, __q.c); 3813e519524SHoward Hinnant } 3823e519524SHoward Hinnant 3833e519524SHoward Hinnant template <class _T1, class _C1> 3843e519524SHoward Hinnant friend 385392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3863e519524SHoward Hinnant bool 3873e519524SHoward Hinnant operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3883e519524SHoward Hinnant 3893e519524SHoward Hinnant template <class _T1, class _C1> 3903e519524SHoward Hinnant friend 391392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3923e519524SHoward Hinnant bool 3933e519524SHoward Hinnant operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3943e519524SHoward Hinnant}; 3953e519524SHoward Hinnant 396f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14 3975b8b8b5dSMarshall Clowtemplate<class _Container, 3984e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 3995b8b8b5dSMarshall Clow> 4005b8b8b5dSMarshall Clowqueue(_Container) 4015b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4025b8b8b5dSMarshall Clow 4035b8b8b5dSMarshall Clowtemplate<class _Container, 4045b8b8b5dSMarshall Clow class _Alloc, 4054e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 4064e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4075b8b8b5dSMarshall Clow> 4085b8b8b5dSMarshall Clowqueue(_Container, _Alloc) 4095b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4105b8b8b5dSMarshall Clow#endif 4115b8b8b5dSMarshall Clow 412f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 413f3aed369SNikolas Klausertemplate <class _InputIterator, 414f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 415f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator) 416f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>>; 417f3aed369SNikolas Klauser 418f3aed369SNikolas Klausertemplate <class _InputIterator, 419f3aed369SNikolas Klauser class _Alloc, 420f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 421f3aed369SNikolas Klauser class = __enable_if_t<__is_allocator<_Alloc>::value>> 422f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator, _Alloc) 423f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 424f3aed369SNikolas Klauser#endif 425f3aed369SNikolas Klauser 4263e519524SHoward Hinnanttemplate <class _Tp, class _Container> 427392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4283e519524SHoward Hinnantbool 4293e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4303e519524SHoward Hinnant{ 4313e519524SHoward Hinnant return __x.c == __y.c; 4323e519524SHoward Hinnant} 4333e519524SHoward Hinnant 4343e519524SHoward Hinnanttemplate <class _Tp, class _Container> 435392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4363e519524SHoward Hinnantbool 4373e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4383e519524SHoward Hinnant{ 4393e519524SHoward Hinnant return __x.c < __y.c; 4403e519524SHoward Hinnant} 4413e519524SHoward Hinnant 4423e519524SHoward Hinnanttemplate <class _Tp, class _Container> 443392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4443e519524SHoward Hinnantbool 4453e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4463e519524SHoward Hinnant{ 4473e519524SHoward Hinnant return !(__x == __y); 4483e519524SHoward Hinnant} 4493e519524SHoward Hinnant 4503e519524SHoward Hinnanttemplate <class _Tp, class _Container> 451392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4523e519524SHoward Hinnantbool 4533e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4543e519524SHoward Hinnant{ 4553e519524SHoward Hinnant return __y < __x; 4563e519524SHoward Hinnant} 4573e519524SHoward Hinnant 4583e519524SHoward Hinnanttemplate <class _Tp, class _Container> 459392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4603e519524SHoward Hinnantbool 4613e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4623e519524SHoward Hinnant{ 4633e519524SHoward Hinnant return !(__x < __y); 4643e519524SHoward Hinnant} 4653e519524SHoward Hinnant 4663e519524SHoward Hinnanttemplate <class _Tp, class _Container> 467392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4683e519524SHoward Hinnantbool 4693e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4703e519524SHoward Hinnant{ 4713e519524SHoward Hinnant return !(__y < __x); 4723e519524SHoward Hinnant} 4733e519524SHoward Hinnant 4743e519524SHoward Hinnanttemplate <class _Tp, class _Container> 475392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 476b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void> 4773e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4786971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4793e519524SHoward Hinnant{ 4803e519524SHoward Hinnant __x.swap(__y); 4813e519524SHoward Hinnant} 4823e519524SHoward Hinnant 4833e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc> 484e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4853e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 4863e519524SHoward Hinnant{ 4873e519524SHoward Hinnant}; 4883e519524SHoward Hinnant 4893e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>, 4903e519524SHoward Hinnant class _Compare = less<typename _Container::value_type> > 491e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue 4923e519524SHoward Hinnant{ 4933e519524SHoward Hinnantpublic: 4943e519524SHoward Hinnant typedef _Container container_type; 4953e519524SHoward Hinnant typedef _Compare value_compare; 4963e519524SHoward Hinnant typedef typename container_type::value_type value_type; 4973e519524SHoward Hinnant typedef typename container_type::reference reference; 4983e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 4993e519524SHoward Hinnant typedef typename container_type::size_type size_type; 500c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 5013e519524SHoward Hinnant 5023e519524SHoward Hinnantprotected: 5033e519524SHoward Hinnant container_type c; 5043e519524SHoward Hinnant value_compare comp; 5053e519524SHoward Hinnant 5063e519524SHoward Hinnantpublic: 507392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5086971d826SHoward Hinnant priority_queue() 5096971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 5106971d826SHoward Hinnant is_nothrow_default_constructible<value_compare>::value) 5116971d826SHoward Hinnant : c(), comp() {} 5126971d826SHoward Hinnant 5136971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5146971d826SHoward Hinnant priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5156971d826SHoward Hinnant 516f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 517f5427b26SEric Fiselier priority_queue& operator=(const priority_queue& __q) 518f5427b26SEric Fiselier {c = __q.c; comp = __q.comp; return *this;} 519f5427b26SEric Fiselier 520f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5216971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5226971d826SHoward Hinnant priority_queue(priority_queue&& __q) 5236971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 5246971d826SHoward Hinnant is_nothrow_move_constructible<value_compare>::value) 525ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 5266971d826SHoward Hinnant 5276971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5286971d826SHoward Hinnant priority_queue& operator=(priority_queue&& __q) 5296971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 5306971d826SHoward Hinnant is_nothrow_move_assignable<value_compare>::value) 531ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 532f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5336971d826SHoward Hinnant 5346971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5356971d826SHoward Hinnant explicit priority_queue(const value_compare& __comp) 5363e519524SHoward Hinnant : c(), comp(__comp) {} 537cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5383e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c); 539f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 540cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 541a11f8b1aSMarek Kurdej priority_queue(const value_compare& __comp, container_type&& __c); 5423e519524SHoward Hinnant#endif 543b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 544cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5453e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5463e519524SHoward Hinnant const value_compare& __comp = value_compare()); 547b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 548cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5493e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5503e519524SHoward Hinnant const value_compare& __comp, const container_type& __c); 551f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 552b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 553cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5543e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5553e519524SHoward Hinnant const value_compare& __comp, container_type&& __c); 556f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5573e519524SHoward Hinnant template <class _Alloc> 558cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5593e519524SHoward Hinnant explicit priority_queue(const _Alloc& __a, 560b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5613e519524SHoward Hinnant template <class _Alloc> 562cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5633e519524SHoward Hinnant priority_queue(const value_compare& __comp, const _Alloc& __a, 564b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5653e519524SHoward Hinnant template <class _Alloc> 566cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5673e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c, 5683e519524SHoward Hinnant const _Alloc& __a, 569b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5703e519524SHoward Hinnant template <class _Alloc> 571cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5723e519524SHoward Hinnant priority_queue(const priority_queue& __q, const _Alloc& __a, 573b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 574f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5753e519524SHoward Hinnant template <class _Alloc> 576cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5773e519524SHoward Hinnant priority_queue(const value_compare& __comp, container_type&& __c, 5783e519524SHoward Hinnant const _Alloc& __a, 579b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5803e519524SHoward Hinnant template <class _Alloc> 581cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5823e519524SHoward Hinnant priority_queue(priority_queue&& __q, const _Alloc& __a, 583b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 584f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5853e519524SHoward Hinnant 586b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5873894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5883894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 589b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5903894a8a4SArthur O'Dwyer 591b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5923894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5933894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5943894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 595b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5963894a8a4SArthur O'Dwyer 597b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5983894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5993894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 6003894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 601b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6023894a8a4SArthur O'Dwyer 6033894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 604b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 6053894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 6063894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 6073894a8a4SArthur O'Dwyer const value_compare& __comp, container_type&& __c, const _Alloc& __a, 608b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6093894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 6103894a8a4SArthur O'Dwyer 61172c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6123e519524SHoward Hinnant bool empty() const {return c.empty();} 613392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6143e519524SHoward Hinnant size_type size() const {return c.size();} 615392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6163e519524SHoward Hinnant const_reference top() const {return c.front();} 6173e519524SHoward Hinnant 618cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6193e519524SHoward Hinnant void push(const value_type& __v); 620f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 621cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6223e519524SHoward Hinnant void push(value_type&& __v); 623f5427b26SEric Fiselier template <class... _Args> 624f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 625f5427b26SEric Fiselier void emplace(_Args&&... __args); 626f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 627cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6283e519524SHoward Hinnant void pop(); 6293e519524SHoward Hinnant 630cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6316971d826SHoward Hinnant void swap(priority_queue& __q) 6326971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 6336971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value); 6343e519524SHoward Hinnant}; 6353e519524SHoward Hinnant 63601666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 6375b8b8b5dSMarshall Clowtemplate <class _Compare, 6385b8b8b5dSMarshall Clow class _Container, 6394e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6404e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6415b8b8b5dSMarshall Clow> 6425b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container) 6435b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6445b8b8b5dSMarshall Clow 6455b8b8b5dSMarshall Clowtemplate<class _InputIterator, 646199d2ebeSArthur O'Dwyer class _Compare = less<__iter_value_type<_InputIterator>>, 647199d2ebeSArthur O'Dwyer class _Container = vector<__iter_value_type<_InputIterator>>, 6484e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6494e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6504e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6515b8b8b5dSMarshall Clow> 6525b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 653199d2ebeSArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6545b8b8b5dSMarshall Clow 6555b8b8b5dSMarshall Clowtemplate<class _Compare, 6565b8b8b5dSMarshall Clow class _Container, 6575b8b8b5dSMarshall Clow class _Alloc, 6584e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6594e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6604e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6615b8b8b5dSMarshall Clow> 6625b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc) 6635b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6643894a8a4SArthur O'Dwyer 6653894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator, 6664e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6674e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6683894a8a4SArthur O'Dwyer> 6693894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator) 6703894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6713894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, 6723894a8a4SArthur O'Dwyer less<__iter_value_type<_InputIterator>>>; 6733894a8a4SArthur O'Dwyer 6743894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator, 6754e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6764e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6774e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6783894a8a4SArthur O'Dwyer> 6793894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 6803894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6813894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 6823894a8a4SArthur O'Dwyer 6833894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 6844e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6854e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6864e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6874e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6883894a8a4SArthur O'Dwyer> 6893894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 6903894a8a4SArthur O'Dwyer -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6915b8b8b5dSMarshall Clow#endif 6925b8b8b5dSMarshall Clow 6933e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 694cd31b434SEvgeniy Stepanovinline 6953e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6963e519524SHoward Hinnant const container_type& __c) 6973e519524SHoward Hinnant : c(__c), 6983e519524SHoward Hinnant comp(__comp) 6993e519524SHoward Hinnant{ 700ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7013e519524SHoward Hinnant} 7023e519524SHoward Hinnant 703f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7043e519524SHoward Hinnant 7053e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 706cd31b434SEvgeniy Stepanovinline 7073e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7083e519524SHoward Hinnant container_type&& __c) 709ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7103e519524SHoward Hinnant comp(__comp) 7113e519524SHoward Hinnant{ 712ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7133e519524SHoward Hinnant} 7143e519524SHoward Hinnant 715f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7163e519524SHoward Hinnant 7173e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7183894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 719cd31b434SEvgeniy Stepanovinline 7203e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7213e519524SHoward Hinnant const value_compare& __comp) 7223e519524SHoward Hinnant : c(__f, __l), 7233e519524SHoward Hinnant comp(__comp) 7243e519524SHoward Hinnant{ 725ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7263e519524SHoward Hinnant} 7273e519524SHoward Hinnant 7283e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7293894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 730cd31b434SEvgeniy Stepanovinline 7313e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7323e519524SHoward Hinnant const value_compare& __comp, 7333e519524SHoward Hinnant const container_type& __c) 7343e519524SHoward Hinnant : c(__c), 7353e519524SHoward Hinnant comp(__comp) 7363e519524SHoward Hinnant{ 7373e519524SHoward Hinnant c.insert(c.end(), __f, __l); 738ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7393e519524SHoward Hinnant} 7403e519524SHoward Hinnant 741f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7423e519524SHoward Hinnant 7433e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7443894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 745cd31b434SEvgeniy Stepanovinline 7463e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7473e519524SHoward Hinnant const value_compare& __comp, 7483e519524SHoward Hinnant container_type&& __c) 749ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7503e519524SHoward Hinnant comp(__comp) 7513e519524SHoward Hinnant{ 7523e519524SHoward Hinnant c.insert(c.end(), __f, __l); 753ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7543e519524SHoward Hinnant} 7553e519524SHoward Hinnant 756f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7573e519524SHoward Hinnant 7583e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7593e519524SHoward Hinnanttemplate <class _Alloc> 760cd31b434SEvgeniy Stepanovinline 7613e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 762b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7633e519524SHoward Hinnant : c(__a) 7643e519524SHoward Hinnant{ 7653e519524SHoward Hinnant} 7663e519524SHoward Hinnant 7673e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7683e519524SHoward Hinnanttemplate <class _Alloc> 769cd31b434SEvgeniy Stepanovinline 7703e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7713e519524SHoward Hinnant const _Alloc& __a, 772b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7733e519524SHoward Hinnant : c(__a), 7743e519524SHoward Hinnant comp(__comp) 7753e519524SHoward Hinnant{ 7763e519524SHoward Hinnant} 7773e519524SHoward Hinnant 7783e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7793e519524SHoward Hinnanttemplate <class _Alloc> 780cd31b434SEvgeniy Stepanovinline 7813e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7823e519524SHoward Hinnant const container_type& __c, 7833e519524SHoward Hinnant const _Alloc& __a, 784b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7853e519524SHoward Hinnant : c(__c, __a), 7863e519524SHoward Hinnant comp(__comp) 7873e519524SHoward Hinnant{ 788ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7893e519524SHoward Hinnant} 7903e519524SHoward Hinnant 7913e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7923e519524SHoward Hinnanttemplate <class _Alloc> 793cd31b434SEvgeniy Stepanovinline 7943e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7953e519524SHoward Hinnant const _Alloc& __a, 796b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7973e519524SHoward Hinnant : c(__q.c, __a), 7983e519524SHoward Hinnant comp(__q.comp) 7993e519524SHoward Hinnant{ 8003e519524SHoward Hinnant} 8013e519524SHoward Hinnant 802f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8033e519524SHoward Hinnant 8043e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8053e519524SHoward Hinnanttemplate <class _Alloc> 806cd31b434SEvgeniy Stepanovinline 8073e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8083e519524SHoward Hinnant container_type&& __c, 8093e519524SHoward Hinnant const _Alloc& __a, 810b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 811ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a), 8123e519524SHoward Hinnant comp(__comp) 8133e519524SHoward Hinnant{ 814ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8153e519524SHoward Hinnant} 8163e519524SHoward Hinnant 8173e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8183e519524SHoward Hinnanttemplate <class _Alloc> 819cd31b434SEvgeniy Stepanovinline 8203e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 8213e519524SHoward Hinnant const _Alloc& __a, 822b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 823ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a), 824ce48a113SHoward Hinnant comp(_VSTD::move(__q.comp)) 8253e519524SHoward Hinnant{ 8263894a8a4SArthur O'Dwyer} 8273894a8a4SArthur O'Dwyer 8283894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 8293894a8a4SArthur O'Dwyer 8303894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8313894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8323894a8a4SArthur O'Dwyerinline 8333894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8343894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const _Alloc& __a, 835b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8363894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8373894a8a4SArthur O'Dwyer comp() 8383894a8a4SArthur O'Dwyer{ 839ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8403e519524SHoward Hinnant} 8413e519524SHoward Hinnant 8423894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8433894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8443894a8a4SArthur O'Dwyerinline 8453894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8463894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8473894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 848b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8493894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8503894a8a4SArthur O'Dwyer comp(__comp) 8513894a8a4SArthur O'Dwyer{ 8523894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8533894a8a4SArthur O'Dwyer} 8543894a8a4SArthur O'Dwyer 8553894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8563894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8573894a8a4SArthur O'Dwyerinline 8583894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8593894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8603894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 861b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8623894a8a4SArthur O'Dwyer : c(__c, __a), 8633894a8a4SArthur O'Dwyer comp(__comp) 8643894a8a4SArthur O'Dwyer{ 8653894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8663894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8673894a8a4SArthur O'Dwyer} 8683894a8a4SArthur O'Dwyer 8693894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 8703894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8713894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8723894a8a4SArthur O'Dwyerinline 8733894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8743894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const value_compare& __comp, 8753894a8a4SArthur O'Dwyer container_type&& __c, const _Alloc& __a, 876b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8773894a8a4SArthur O'Dwyer : c(_VSTD::move(__c), __a), 8783894a8a4SArthur O'Dwyer comp(__comp) 8793894a8a4SArthur O'Dwyer{ 8803894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8813894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8823894a8a4SArthur O'Dwyer} 883f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8843e519524SHoward Hinnant 8853e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 886cd31b434SEvgeniy Stepanovinline 8873e519524SHoward Hinnantvoid 8883e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8893e519524SHoward Hinnant{ 8903e519524SHoward Hinnant c.push_back(__v); 891ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8923e519524SHoward Hinnant} 8933e519524SHoward Hinnant 894f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8953e519524SHoward Hinnant 8963e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 897cd31b434SEvgeniy Stepanovinline 8983e519524SHoward Hinnantvoid 8993e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 9003e519524SHoward Hinnant{ 901ce48a113SHoward Hinnant c.push_back(_VSTD::move(__v)); 902ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9033e519524SHoward Hinnant} 9043e519524SHoward Hinnant 9053e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 9063e519524SHoward Hinnanttemplate <class... _Args> 907cd31b434SEvgeniy Stepanovinline 9083e519524SHoward Hinnantvoid 9093e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 9103e519524SHoward Hinnant{ 911ce48a113SHoward Hinnant c.emplace_back(_VSTD::forward<_Args>(__args)...); 912ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9133e519524SHoward Hinnant} 9143e519524SHoward Hinnant 915f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 9163e519524SHoward Hinnant 9173e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 918cd31b434SEvgeniy Stepanovinline 9193e519524SHoward Hinnantvoid 9203e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop() 9213e519524SHoward Hinnant{ 922ce48a113SHoward Hinnant _VSTD::pop_heap(c.begin(), c.end(), comp); 9233e519524SHoward Hinnant c.pop_back(); 9243e519524SHoward Hinnant} 9253e519524SHoward Hinnant 9263e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 927cd31b434SEvgeniy Stepanovinline 9283e519524SHoward Hinnantvoid 9293e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 9306971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 9316971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value) 9323e519524SHoward Hinnant{ 933ce48a113SHoward Hinnant using _VSTD::swap; 9343e519524SHoward Hinnant swap(c, __q.c); 9353e519524SHoward Hinnant swap(comp, __q.comp); 9363e519524SHoward Hinnant} 9373e519524SHoward Hinnant 9383e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 939392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 940b4e88d4dSLouis Dionne__enable_if_t< 941199d2ebeSArthur O'Dwyer __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 9423e519524SHoward Hinnant void 943199d2ebeSArthur O'Dwyer> 9443e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x, 9453e519524SHoward Hinnant priority_queue<_Tp, _Container, _Compare>& __y) 9466971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9473e519524SHoward Hinnant{ 9483e519524SHoward Hinnant __x.swap(__y); 9493e519524SHoward Hinnant} 9503e519524SHoward Hinnant 9513e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc> 952e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9533e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 9543e519524SHoward Hinnant{ 9553e519524SHoward Hinnant}; 9563e519524SHoward Hinnant 9573e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 9583e519524SHoward Hinnant 9593e519524SHoward Hinnant#endif // _LIBCPP_QUEUE 960