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*de4a57cbSLouis Dionne#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES 235*de4a57cbSLouis Dionne# include <functional> 236*de4a57cbSLouis Dionne#endif 237*de4a57cbSLouis Dionne 238db1978b6SNikolas Klauser// standard-mandated includes 239db1978b6SNikolas Klauser#include <compare> 240db1978b6SNikolas Klauser#include <initializer_list> 241db1978b6SNikolas Klauser 242073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2433e519524SHoward Hinnant# pragma GCC system_header 244073458b1SHoward Hinnant#endif 2453e519524SHoward Hinnant 2463e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 2473e519524SHoward Hinnant 248e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2493e519524SHoward Hinnant 2503e519524SHoward Hinnanttemplate <class _Tp, class _Container> 251aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2523e519524SHoward Hinnantbool 2533e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2543e519524SHoward Hinnant 2553e519524SHoward Hinnanttemplate <class _Tp, class _Container> 256aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2573e519524SHoward Hinnantbool 2583e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2593e519524SHoward Hinnant 2603afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/> 261e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue 2623e519524SHoward Hinnant{ 2633e519524SHoward Hinnantpublic: 2643e519524SHoward Hinnant typedef _Container container_type; 2653e519524SHoward Hinnant typedef typename container_type::value_type value_type; 2663e519524SHoward Hinnant typedef typename container_type::reference reference; 2673e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 2683e519524SHoward Hinnant typedef typename container_type::size_type size_type; 269c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 2703e519524SHoward Hinnant 2713e519524SHoward Hinnantprotected: 2723e519524SHoward Hinnant container_type c; 2733e519524SHoward Hinnant 2743e519524SHoward Hinnantpublic: 275392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2766971d826SHoward Hinnant queue() 2776971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2786971d826SHoward Hinnant : c() {} 2796971d826SHoward Hinnant 2806971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2816971d826SHoward Hinnant queue(const queue& __q) : c(__q.c) {} 2826971d826SHoward Hinnant 283f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 284f3aed369SNikolas Klauser template <class _InputIterator, 285f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 286f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 287f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 288f3aed369SNikolas Klauser 289f3aed369SNikolas Klauser template <class _InputIterator, 290f3aed369SNikolas Klauser class _Alloc, 291f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 292f3aed369SNikolas Klauser class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 293f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 294f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 295f3aed369SNikolas Klauser#endif 296f3aed369SNikolas Klauser 297f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 298f5427b26SEric Fiselier queue& operator=(const queue& __q) {c = __q.c; return *this;} 299f5427b26SEric Fiselier 300f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 3016971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3026971d826SHoward Hinnant queue(queue&& __q) 3036971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 304ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)) {} 3056971d826SHoward Hinnant 3066971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3076971d826SHoward Hinnant queue& operator=(queue&& __q) 3086971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 309ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); return *this;} 310f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3116971d826SHoward Hinnant 312392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3133e519524SHoward Hinnant explicit queue(const container_type& __c) : c(__c) {} 314f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 315392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 316ce48a113SHoward Hinnant explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 317f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3183e519524SHoward Hinnant template <class _Alloc> 319392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3203e519524SHoward Hinnant explicit queue(const _Alloc& __a, 321b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3223e519524SHoward Hinnant : c(__a) {} 3233e519524SHoward Hinnant template <class _Alloc> 324392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3253e519524SHoward Hinnant queue(const queue& __q, const _Alloc& __a, 326b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3273e519524SHoward Hinnant : c(__q.c, __a) {} 3283e519524SHoward Hinnant template <class _Alloc> 329392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3303e519524SHoward Hinnant queue(const container_type& __c, const _Alloc& __a, 331b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3323e519524SHoward Hinnant : c(__c, __a) {} 333f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 3343e519524SHoward Hinnant template <class _Alloc> 335392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3363e519524SHoward Hinnant queue(container_type&& __c, const _Alloc& __a, 337b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 338ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a) {} 3393e519524SHoward Hinnant template <class _Alloc> 340392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3413e519524SHoward Hinnant queue(queue&& __q, const _Alloc& __a, 342b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 343ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a) {} 3443e519524SHoward Hinnant 345f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3463e519524SHoward Hinnant 34772c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3483e519524SHoward Hinnant bool empty() const {return c.empty();} 349392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3503e519524SHoward Hinnant size_type size() const {return c.size();} 3513e519524SHoward Hinnant 352392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3533e519524SHoward Hinnant reference front() {return c.front();} 354392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3553e519524SHoward Hinnant const_reference front() const {return c.front();} 356392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3573e519524SHoward Hinnant reference back() {return c.back();} 358392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3593e519524SHoward Hinnant const_reference back() const {return c.back();} 3603e519524SHoward Hinnant 361392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3623e519524SHoward Hinnant void push(const value_type& __v) {c.push_back(__v);} 363f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 364392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 365ce48a113SHoward Hinnant void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3663e519524SHoward Hinnant template <class... _Args> 367392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 36863b560beSMarshall Clow#if _LIBCPP_STD_VER > 14 369e34f5ffeSMarshall Clow decltype(auto) emplace(_Args&&... __args) 3700e411641SEric Fiselier { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 37163b560beSMarshall Clow#else 37263b560beSMarshall Clow void emplace(_Args&&... __args) 37363b560beSMarshall Clow { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 37463b560beSMarshall Clow#endif 375f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 376392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3773e519524SHoward Hinnant void pop() {c.pop_front();} 3783e519524SHoward Hinnant 379392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3803e519524SHoward Hinnant void swap(queue& __q) 3816971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3823e519524SHoward Hinnant { 383ce48a113SHoward Hinnant using _VSTD::swap; 3843e519524SHoward Hinnant swap(c, __q.c); 3853e519524SHoward Hinnant } 3863e519524SHoward Hinnant 3873e519524SHoward Hinnant template <class _T1, class _C1> 3883e519524SHoward Hinnant friend 389392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3903e519524SHoward Hinnant bool 3913e519524SHoward Hinnant operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3923e519524SHoward Hinnant 3933e519524SHoward Hinnant template <class _T1, class _C1> 3943e519524SHoward Hinnant friend 395392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3963e519524SHoward Hinnant bool 3973e519524SHoward Hinnant operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3983e519524SHoward Hinnant}; 3993e519524SHoward Hinnant 400f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14 4015b8b8b5dSMarshall Clowtemplate<class _Container, 4024e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 4035b8b8b5dSMarshall Clow> 4045b8b8b5dSMarshall Clowqueue(_Container) 4055b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4065b8b8b5dSMarshall Clow 4075b8b8b5dSMarshall Clowtemplate<class _Container, 4085b8b8b5dSMarshall Clow class _Alloc, 4094e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 4104e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4115b8b8b5dSMarshall Clow> 4125b8b8b5dSMarshall Clowqueue(_Container, _Alloc) 4135b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4145b8b8b5dSMarshall Clow#endif 4155b8b8b5dSMarshall Clow 416f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 417f3aed369SNikolas Klausertemplate <class _InputIterator, 418f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 419f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator) 420f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>>; 421f3aed369SNikolas Klauser 422f3aed369SNikolas Klausertemplate <class _InputIterator, 423f3aed369SNikolas Klauser class _Alloc, 424f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 425f3aed369SNikolas Klauser class = __enable_if_t<__is_allocator<_Alloc>::value>> 426f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator, _Alloc) 427f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 428f3aed369SNikolas Klauser#endif 429f3aed369SNikolas Klauser 4303e519524SHoward Hinnanttemplate <class _Tp, class _Container> 431392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4323e519524SHoward Hinnantbool 4333e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4343e519524SHoward Hinnant{ 4353e519524SHoward Hinnant return __x.c == __y.c; 4363e519524SHoward Hinnant} 4373e519524SHoward Hinnant 4383e519524SHoward Hinnanttemplate <class _Tp, class _Container> 439392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4403e519524SHoward Hinnantbool 4413e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4423e519524SHoward Hinnant{ 4433e519524SHoward Hinnant return __x.c < __y.c; 4443e519524SHoward Hinnant} 4453e519524SHoward Hinnant 4463e519524SHoward Hinnanttemplate <class _Tp, class _Container> 447392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4483e519524SHoward Hinnantbool 4493e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4503e519524SHoward Hinnant{ 4513e519524SHoward Hinnant return !(__x == __y); 4523e519524SHoward Hinnant} 4533e519524SHoward Hinnant 4543e519524SHoward Hinnanttemplate <class _Tp, class _Container> 455392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4563e519524SHoward Hinnantbool 4573e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4583e519524SHoward Hinnant{ 4593e519524SHoward Hinnant return __y < __x; 4603e519524SHoward Hinnant} 4613e519524SHoward Hinnant 4623e519524SHoward Hinnanttemplate <class _Tp, class _Container> 463392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4643e519524SHoward Hinnantbool 4653e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4663e519524SHoward Hinnant{ 4673e519524SHoward Hinnant return !(__x < __y); 4683e519524SHoward Hinnant} 4693e519524SHoward Hinnant 4703e519524SHoward Hinnanttemplate <class _Tp, class _Container> 471392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4723e519524SHoward Hinnantbool 4733e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4743e519524SHoward Hinnant{ 4753e519524SHoward Hinnant return !(__y < __x); 4763e519524SHoward Hinnant} 4773e519524SHoward Hinnant 4783e519524SHoward Hinnanttemplate <class _Tp, class _Container> 479392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 480b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void> 4813e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4826971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4833e519524SHoward Hinnant{ 4843e519524SHoward Hinnant __x.swap(__y); 4853e519524SHoward Hinnant} 4863e519524SHoward Hinnant 4873e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc> 488e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4893e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 4903e519524SHoward Hinnant{ 4913e519524SHoward Hinnant}; 4923e519524SHoward Hinnant 4933e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>, 4943e519524SHoward Hinnant class _Compare = less<typename _Container::value_type> > 495e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue 4963e519524SHoward Hinnant{ 4973e519524SHoward Hinnantpublic: 4983e519524SHoward Hinnant typedef _Container container_type; 4993e519524SHoward Hinnant typedef _Compare value_compare; 5003e519524SHoward Hinnant typedef typename container_type::value_type value_type; 5013e519524SHoward Hinnant typedef typename container_type::reference reference; 5023e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 5033e519524SHoward Hinnant typedef typename container_type::size_type size_type; 504c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 5053e519524SHoward Hinnant 5063e519524SHoward Hinnantprotected: 5073e519524SHoward Hinnant container_type c; 5083e519524SHoward Hinnant value_compare comp; 5093e519524SHoward Hinnant 5103e519524SHoward Hinnantpublic: 511392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5126971d826SHoward Hinnant priority_queue() 5136971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 5146971d826SHoward Hinnant is_nothrow_default_constructible<value_compare>::value) 5156971d826SHoward Hinnant : c(), comp() {} 5166971d826SHoward Hinnant 5176971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5186971d826SHoward Hinnant priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5196971d826SHoward Hinnant 520f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 521f5427b26SEric Fiselier priority_queue& operator=(const priority_queue& __q) 522f5427b26SEric Fiselier {c = __q.c; comp = __q.comp; return *this;} 523f5427b26SEric Fiselier 524f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5256971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5266971d826SHoward Hinnant priority_queue(priority_queue&& __q) 5276971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 5286971d826SHoward Hinnant is_nothrow_move_constructible<value_compare>::value) 529ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 5306971d826SHoward Hinnant 5316971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5326971d826SHoward Hinnant priority_queue& operator=(priority_queue&& __q) 5336971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 5346971d826SHoward Hinnant is_nothrow_move_assignable<value_compare>::value) 535ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 536f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5376971d826SHoward Hinnant 5386971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5396971d826SHoward Hinnant explicit priority_queue(const value_compare& __comp) 5403e519524SHoward Hinnant : c(), comp(__comp) {} 541cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5423e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c); 543f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 544cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 545a11f8b1aSMarek Kurdej priority_queue(const value_compare& __comp, container_type&& __c); 5463e519524SHoward Hinnant#endif 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 = value_compare()); 551b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 552cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5533e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5543e519524SHoward Hinnant const value_compare& __comp, const container_type& __c); 555f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 556b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 557cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5583e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5593e519524SHoward Hinnant const value_compare& __comp, container_type&& __c); 560f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5613e519524SHoward Hinnant template <class _Alloc> 562cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5633e519524SHoward Hinnant explicit priority_queue(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 _Alloc& __a, 568b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5693e519524SHoward Hinnant template <class _Alloc> 570cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5713e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c, 5723e519524SHoward Hinnant const _Alloc& __a, 573b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5743e519524SHoward Hinnant template <class _Alloc> 575cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5763e519524SHoward Hinnant priority_queue(const priority_queue& __q, const _Alloc& __a, 577b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 578f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5793e519524SHoward Hinnant template <class _Alloc> 580cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5813e519524SHoward Hinnant priority_queue(const value_compare& __comp, container_type&& __c, 5823e519524SHoward Hinnant const _Alloc& __a, 583b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5843e519524SHoward Hinnant template <class _Alloc> 585cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5863e519524SHoward Hinnant priority_queue(priority_queue&& __q, const _Alloc& __a, 587b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 588f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5893e519524SHoward Hinnant 590b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5913894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5923894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 593b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5943894a8a4SArthur O'Dwyer 595b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5963894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5973894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5983894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 599b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6003894a8a4SArthur O'Dwyer 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, const container_type& __c, const _Alloc& __a, 605b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6063894a8a4SArthur O'Dwyer 6073894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 608b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 6093894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 6103894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 6113894a8a4SArthur O'Dwyer const value_compare& __comp, container_type&& __c, const _Alloc& __a, 612b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6133894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 6143894a8a4SArthur O'Dwyer 61572c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6163e519524SHoward Hinnant bool empty() const {return c.empty();} 617392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6183e519524SHoward Hinnant size_type size() const {return c.size();} 619392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6203e519524SHoward Hinnant const_reference top() const {return c.front();} 6213e519524SHoward Hinnant 622cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6233e519524SHoward Hinnant void push(const value_type& __v); 624f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 625cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6263e519524SHoward Hinnant void push(value_type&& __v); 627f5427b26SEric Fiselier template <class... _Args> 628f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 629f5427b26SEric Fiselier void emplace(_Args&&... __args); 630f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 631cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6323e519524SHoward Hinnant void pop(); 6333e519524SHoward Hinnant 634cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6356971d826SHoward Hinnant void swap(priority_queue& __q) 6366971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 6376971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value); 6383e519524SHoward Hinnant}; 6393e519524SHoward Hinnant 64001666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 6415b8b8b5dSMarshall Clowtemplate <class _Compare, 6425b8b8b5dSMarshall Clow class _Container, 6434e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6444e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6455b8b8b5dSMarshall Clow> 6465b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container) 6475b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6485b8b8b5dSMarshall Clow 6495b8b8b5dSMarshall Clowtemplate<class _InputIterator, 650199d2ebeSArthur O'Dwyer class _Compare = less<__iter_value_type<_InputIterator>>, 651199d2ebeSArthur O'Dwyer class _Container = vector<__iter_value_type<_InputIterator>>, 6524e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6534e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6544e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6555b8b8b5dSMarshall Clow> 6565b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 657199d2ebeSArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6585b8b8b5dSMarshall Clow 6595b8b8b5dSMarshall Clowtemplate<class _Compare, 6605b8b8b5dSMarshall Clow class _Container, 6615b8b8b5dSMarshall Clow class _Alloc, 6624e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6634e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6644e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6655b8b8b5dSMarshall Clow> 6665b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc) 6675b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6683894a8a4SArthur O'Dwyer 6693894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator, 6704e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6714e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6723894a8a4SArthur O'Dwyer> 6733894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator) 6743894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6753894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, 6763894a8a4SArthur O'Dwyer less<__iter_value_type<_InputIterator>>>; 6773894a8a4SArthur O'Dwyer 6783894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator, 6794e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6804e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6814e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6823894a8a4SArthur O'Dwyer> 6833894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 6843894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6853894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 6863894a8a4SArthur O'Dwyer 6873894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 6884e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6894e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6904e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6914e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6923894a8a4SArthur O'Dwyer> 6933894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 6943894a8a4SArthur O'Dwyer -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6955b8b8b5dSMarshall Clow#endif 6965b8b8b5dSMarshall Clow 6973e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 698cd31b434SEvgeniy Stepanovinline 6993e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 7003e519524SHoward Hinnant const container_type& __c) 7013e519524SHoward Hinnant : c(__c), 7023e519524SHoward Hinnant comp(__comp) 7033e519524SHoward Hinnant{ 704ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7053e519524SHoward Hinnant} 7063e519524SHoward Hinnant 707f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7083e519524SHoward Hinnant 7093e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 710cd31b434SEvgeniy Stepanovinline 7113e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7123e519524SHoward Hinnant container_type&& __c) 713ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7143e519524SHoward Hinnant comp(__comp) 7153e519524SHoward Hinnant{ 716ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7173e519524SHoward Hinnant} 7183e519524SHoward Hinnant 719f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7203e519524SHoward Hinnant 7213e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7223894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 723cd31b434SEvgeniy Stepanovinline 7243e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7253e519524SHoward Hinnant const value_compare& __comp) 7263e519524SHoward Hinnant : c(__f, __l), 7273e519524SHoward Hinnant comp(__comp) 7283e519524SHoward Hinnant{ 729ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7303e519524SHoward Hinnant} 7313e519524SHoward Hinnant 7323e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7333894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 734cd31b434SEvgeniy Stepanovinline 7353e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7363e519524SHoward Hinnant const value_compare& __comp, 7373e519524SHoward Hinnant const container_type& __c) 7383e519524SHoward Hinnant : c(__c), 7393e519524SHoward Hinnant comp(__comp) 7403e519524SHoward Hinnant{ 7413e519524SHoward Hinnant c.insert(c.end(), __f, __l); 742ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7433e519524SHoward Hinnant} 7443e519524SHoward Hinnant 745f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7463e519524SHoward Hinnant 7473e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7483894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 749cd31b434SEvgeniy Stepanovinline 7503e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7513e519524SHoward Hinnant const value_compare& __comp, 7523e519524SHoward Hinnant container_type&& __c) 753ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7543e519524SHoward Hinnant comp(__comp) 7553e519524SHoward Hinnant{ 7563e519524SHoward Hinnant c.insert(c.end(), __f, __l); 757ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7583e519524SHoward Hinnant} 7593e519524SHoward Hinnant 760f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7613e519524SHoward Hinnant 7623e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7633e519524SHoward Hinnanttemplate <class _Alloc> 764cd31b434SEvgeniy Stepanovinline 7653e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 766b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7673e519524SHoward Hinnant : c(__a) 7683e519524SHoward Hinnant{ 7693e519524SHoward Hinnant} 7703e519524SHoward Hinnant 7713e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7723e519524SHoward Hinnanttemplate <class _Alloc> 773cd31b434SEvgeniy Stepanovinline 7743e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7753e519524SHoward Hinnant const _Alloc& __a, 776b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7773e519524SHoward Hinnant : c(__a), 7783e519524SHoward Hinnant comp(__comp) 7793e519524SHoward Hinnant{ 7803e519524SHoward Hinnant} 7813e519524SHoward Hinnant 7823e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7833e519524SHoward Hinnanttemplate <class _Alloc> 784cd31b434SEvgeniy Stepanovinline 7853e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7863e519524SHoward Hinnant const container_type& __c, 7873e519524SHoward Hinnant const _Alloc& __a, 788b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7893e519524SHoward Hinnant : c(__c, __a), 7903e519524SHoward Hinnant comp(__comp) 7913e519524SHoward Hinnant{ 792ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7933e519524SHoward Hinnant} 7943e519524SHoward Hinnant 7953e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7963e519524SHoward Hinnanttemplate <class _Alloc> 797cd31b434SEvgeniy Stepanovinline 7983e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7993e519524SHoward Hinnant const _Alloc& __a, 800b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8013e519524SHoward Hinnant : c(__q.c, __a), 8023e519524SHoward Hinnant comp(__q.comp) 8033e519524SHoward Hinnant{ 8043e519524SHoward Hinnant} 8053e519524SHoward Hinnant 806f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8073e519524SHoward Hinnant 8083e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8093e519524SHoward Hinnanttemplate <class _Alloc> 810cd31b434SEvgeniy Stepanovinline 8113e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8123e519524SHoward Hinnant container_type&& __c, 8133e519524SHoward Hinnant const _Alloc& __a, 814b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 815ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a), 8163e519524SHoward Hinnant comp(__comp) 8173e519524SHoward Hinnant{ 818ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8193e519524SHoward Hinnant} 8203e519524SHoward Hinnant 8213e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8223e519524SHoward Hinnanttemplate <class _Alloc> 823cd31b434SEvgeniy Stepanovinline 8243e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 8253e519524SHoward Hinnant const _Alloc& __a, 826b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 827ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a), 828ce48a113SHoward Hinnant comp(_VSTD::move(__q.comp)) 8293e519524SHoward Hinnant{ 8303894a8a4SArthur O'Dwyer} 8313894a8a4SArthur O'Dwyer 8323894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 8333894a8a4SArthur O'Dwyer 8343894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8353894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8363894a8a4SArthur O'Dwyerinline 8373894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8383894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const _Alloc& __a, 839b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8403894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8413894a8a4SArthur O'Dwyer comp() 8423894a8a4SArthur O'Dwyer{ 843ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8443e519524SHoward Hinnant} 8453e519524SHoward Hinnant 8463894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8473894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8483894a8a4SArthur O'Dwyerinline 8493894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8503894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8513894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 852b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8533894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8543894a8a4SArthur O'Dwyer comp(__comp) 8553894a8a4SArthur O'Dwyer{ 8563894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8573894a8a4SArthur O'Dwyer} 8583894a8a4SArthur O'Dwyer 8593894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8603894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8613894a8a4SArthur O'Dwyerinline 8623894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8633894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8643894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 865b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8663894a8a4SArthur O'Dwyer : c(__c, __a), 8673894a8a4SArthur O'Dwyer comp(__comp) 8683894a8a4SArthur O'Dwyer{ 8693894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8703894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8713894a8a4SArthur O'Dwyer} 8723894a8a4SArthur O'Dwyer 8733894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 8743894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8753894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8763894a8a4SArthur O'Dwyerinline 8773894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8783894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const value_compare& __comp, 8793894a8a4SArthur O'Dwyer container_type&& __c, const _Alloc& __a, 880b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8813894a8a4SArthur O'Dwyer : c(_VSTD::move(__c), __a), 8823894a8a4SArthur O'Dwyer comp(__comp) 8833894a8a4SArthur O'Dwyer{ 8843894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8853894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8863894a8a4SArthur O'Dwyer} 887f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8883e519524SHoward Hinnant 8893e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 890cd31b434SEvgeniy Stepanovinline 8913e519524SHoward Hinnantvoid 8923e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8933e519524SHoward Hinnant{ 8943e519524SHoward Hinnant c.push_back(__v); 895ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8963e519524SHoward Hinnant} 8973e519524SHoward Hinnant 898f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8993e519524SHoward Hinnant 9003e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 901cd31b434SEvgeniy Stepanovinline 9023e519524SHoward Hinnantvoid 9033e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 9043e519524SHoward Hinnant{ 905ce48a113SHoward Hinnant c.push_back(_VSTD::move(__v)); 906ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9073e519524SHoward Hinnant} 9083e519524SHoward Hinnant 9093e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 9103e519524SHoward Hinnanttemplate <class... _Args> 911cd31b434SEvgeniy Stepanovinline 9123e519524SHoward Hinnantvoid 9133e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 9143e519524SHoward Hinnant{ 915ce48a113SHoward Hinnant c.emplace_back(_VSTD::forward<_Args>(__args)...); 916ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9173e519524SHoward Hinnant} 9183e519524SHoward Hinnant 919f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 9203e519524SHoward Hinnant 9213e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 922cd31b434SEvgeniy Stepanovinline 9233e519524SHoward Hinnantvoid 9243e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop() 9253e519524SHoward Hinnant{ 926ce48a113SHoward Hinnant _VSTD::pop_heap(c.begin(), c.end(), comp); 9273e519524SHoward Hinnant c.pop_back(); 9283e519524SHoward Hinnant} 9293e519524SHoward Hinnant 9303e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 931cd31b434SEvgeniy Stepanovinline 9323e519524SHoward Hinnantvoid 9333e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 9346971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 9356971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value) 9363e519524SHoward Hinnant{ 937ce48a113SHoward Hinnant using _VSTD::swap; 9383e519524SHoward Hinnant swap(c, __q.c); 9393e519524SHoward Hinnant swap(comp, __q.comp); 9403e519524SHoward Hinnant} 9413e519524SHoward Hinnant 9423e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 943392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 944b4e88d4dSLouis Dionne__enable_if_t< 945199d2ebeSArthur O'Dwyer __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 9463e519524SHoward Hinnant void 947199d2ebeSArthur O'Dwyer> 9483e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x, 9493e519524SHoward Hinnant priority_queue<_Tp, _Container, _Compare>& __y) 9506971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9513e519524SHoward Hinnant{ 9523e519524SHoward Hinnant __x.swap(__y); 9533e519524SHoward Hinnant} 9543e519524SHoward Hinnant 9553e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc> 956e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9573e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 9583e519524SHoward Hinnant{ 9593e519524SHoward Hinnant}; 9603e519524SHoward Hinnant 9613e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 9623e519524SHoward Hinnant 9633e519524SHoward Hinnant#endif // _LIBCPP_QUEUE 964