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) 44*f3aed369SNikolas Klauser template<class InputIterator> 45*f3aed369SNikolas 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); 56*f3aed369SNikolas Klauser template <class InputIterator, class Alloc> 57*f3aed369SNikolas 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 78*f3aed369SNikolas Klausertemplate<class InputIterator> 79*f3aed369SNikolas Klauser queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 80*f3aed369SNikolas Klauser 815b8b8b5dSMarshall Clowtemplate<class Container, class Allocator> 825b8b8b5dSMarshall Clow queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 835b8b8b5dSMarshall Clow 84*f3aed369SNikolas Klausertemplate<class InputIterator, class Allocator> 85*f3aed369SNikolas Klauser queue(InputIterator, InputIterator, Allocator) 86*f3aed369SNikolas Klauser -> queue<iter-value-type<InputIterator>, 87*f3aed369SNikolas Klauser deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 88*f3aed369SNikolas 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 2203e519524SHoward Hinnant#include <__config> 221*f3aed369SNikolas Klauser#include <__iterator/iterator_traits.h> 222050b064fSChristopher Di Bella#include <__memory/uses_allocator.h> 2236adbc83eSChristopher Di Bella#include <__utility/forward.h> 224bfbd73f8SArthur O'Dwyer#include <algorithm> 2252d0f1fa4SArthur O'Dwyer#include <compare> 2263e519524SHoward Hinnant#include <deque> 2273e519524SHoward Hinnant#include <functional> 228*f3aed369SNikolas Klauser#include <type_traits> 229bfbd73f8SArthur O'Dwyer#include <vector> 230bd6e6846SMark de Wever#include <version> 2313e519524SHoward Hinnant 232073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2333e519524SHoward Hinnant#pragma GCC system_header 234073458b1SHoward Hinnant#endif 2353e519524SHoward Hinnant 2363e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 2373e519524SHoward Hinnant 238e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2393e519524SHoward Hinnant 2403e519524SHoward Hinnanttemplate <class _Tp, class _Container> 241aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2423e519524SHoward Hinnantbool 2433e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2443e519524SHoward Hinnant 2453e519524SHoward Hinnanttemplate <class _Tp, class _Container> 246aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2473e519524SHoward Hinnantbool 2483e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2493e519524SHoward Hinnant 2503afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/> 251e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue 2523e519524SHoward Hinnant{ 2533e519524SHoward Hinnantpublic: 2543e519524SHoward Hinnant typedef _Container container_type; 2553e519524SHoward Hinnant typedef typename container_type::value_type value_type; 2563e519524SHoward Hinnant typedef typename container_type::reference reference; 2573e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 2583e519524SHoward Hinnant typedef typename container_type::size_type size_type; 259c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 2603e519524SHoward Hinnant 2613e519524SHoward Hinnantprotected: 2623e519524SHoward Hinnant container_type c; 2633e519524SHoward Hinnant 2643e519524SHoward Hinnantpublic: 265392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2666971d826SHoward Hinnant queue() 2676971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2686971d826SHoward Hinnant : c() {} 2696971d826SHoward Hinnant 2706971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2716971d826SHoward Hinnant queue(const queue& __q) : c(__q.c) {} 2726971d826SHoward Hinnant 273*f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 274*f3aed369SNikolas Klauser template <class _InputIterator, 275*f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 276*f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 277*f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 278*f3aed369SNikolas Klauser 279*f3aed369SNikolas Klauser template <class _InputIterator, 280*f3aed369SNikolas Klauser class _Alloc, 281*f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 282*f3aed369SNikolas Klauser class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 283*f3aed369SNikolas Klauser _LIBCPP_HIDE_FROM_ABI 284*f3aed369SNikolas Klauser queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 285*f3aed369SNikolas Klauser#endif 286*f3aed369SNikolas Klauser 287f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 288f5427b26SEric Fiselier queue& operator=(const queue& __q) {c = __q.c; return *this;} 289f5427b26SEric Fiselier 290f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2916971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2926971d826SHoward Hinnant queue(queue&& __q) 2936971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 294ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)) {} 2956971d826SHoward Hinnant 2966971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2976971d826SHoward Hinnant queue& operator=(queue&& __q) 2986971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 299ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); return *this;} 300f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3016971d826SHoward Hinnant 302392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3033e519524SHoward Hinnant explicit queue(const container_type& __c) : c(__c) {} 304f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 305392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 306ce48a113SHoward Hinnant explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 307f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3083e519524SHoward Hinnant template <class _Alloc> 309392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3103e519524SHoward Hinnant explicit queue(const _Alloc& __a, 311b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3123e519524SHoward Hinnant : c(__a) {} 3133e519524SHoward Hinnant template <class _Alloc> 314392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3153e519524SHoward Hinnant queue(const queue& __q, const _Alloc& __a, 316b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3173e519524SHoward Hinnant : c(__q.c, __a) {} 3183e519524SHoward Hinnant template <class _Alloc> 319392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3203e519524SHoward Hinnant queue(const container_type& __c, const _Alloc& __a, 321b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3223e519524SHoward Hinnant : c(__c, __a) {} 323f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 3243e519524SHoward Hinnant template <class _Alloc> 325392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3263e519524SHoward Hinnant queue(container_type&& __c, const _Alloc& __a, 327b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 328ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a) {} 3293e519524SHoward Hinnant template <class _Alloc> 330392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3313e519524SHoward Hinnant queue(queue&& __q, const _Alloc& __a, 332b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 333ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a) {} 3343e519524SHoward Hinnant 335f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3363e519524SHoward Hinnant 33772c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3383e519524SHoward Hinnant bool empty() const {return c.empty();} 339392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3403e519524SHoward Hinnant size_type size() const {return c.size();} 3413e519524SHoward Hinnant 342392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3433e519524SHoward Hinnant reference front() {return c.front();} 344392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3453e519524SHoward Hinnant const_reference front() const {return c.front();} 346392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3473e519524SHoward Hinnant reference back() {return c.back();} 348392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3493e519524SHoward Hinnant const_reference back() const {return c.back();} 3503e519524SHoward Hinnant 351392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3523e519524SHoward Hinnant void push(const value_type& __v) {c.push_back(__v);} 353f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 354392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 355ce48a113SHoward Hinnant void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3563e519524SHoward Hinnant template <class... _Args> 357392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 35863b560beSMarshall Clow#if _LIBCPP_STD_VER > 14 359e34f5ffeSMarshall Clow decltype(auto) emplace(_Args&&... __args) 3600e411641SEric Fiselier { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 36163b560beSMarshall Clow#else 36263b560beSMarshall Clow void emplace(_Args&&... __args) 36363b560beSMarshall Clow { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 36463b560beSMarshall Clow#endif 365f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 366392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3673e519524SHoward Hinnant void pop() {c.pop_front();} 3683e519524SHoward Hinnant 369392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3703e519524SHoward Hinnant void swap(queue& __q) 3716971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3723e519524SHoward Hinnant { 373ce48a113SHoward Hinnant using _VSTD::swap; 3743e519524SHoward Hinnant swap(c, __q.c); 3753e519524SHoward Hinnant } 3763e519524SHoward Hinnant 3773e519524SHoward Hinnant template <class _T1, class _C1> 3783e519524SHoward Hinnant friend 379392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3803e519524SHoward Hinnant bool 3813e519524SHoward Hinnant operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 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 390*f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 14 3915b8b8b5dSMarshall Clowtemplate<class _Container, 3924e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 3935b8b8b5dSMarshall Clow> 3945b8b8b5dSMarshall Clowqueue(_Container) 3955b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 3965b8b8b5dSMarshall Clow 3975b8b8b5dSMarshall Clowtemplate<class _Container, 3985b8b8b5dSMarshall Clow class _Alloc, 3994e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 4004e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4015b8b8b5dSMarshall Clow> 4025b8b8b5dSMarshall Clowqueue(_Container, _Alloc) 4035b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 4045b8b8b5dSMarshall Clow#endif 4055b8b8b5dSMarshall Clow 406*f3aed369SNikolas Klauser#if _LIBCPP_STD_VER > 20 407*f3aed369SNikolas Klausertemplate <class _InputIterator, 408*f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 409*f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator) 410*f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>>; 411*f3aed369SNikolas Klauser 412*f3aed369SNikolas Klausertemplate <class _InputIterator, 413*f3aed369SNikolas Klauser class _Alloc, 414*f3aed369SNikolas Klauser class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 415*f3aed369SNikolas Klauser class = __enable_if_t<__is_allocator<_Alloc>::value>> 416*f3aed369SNikolas Klauserqueue(_InputIterator, _InputIterator, _Alloc) 417*f3aed369SNikolas Klauser -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 418*f3aed369SNikolas Klauser#endif 419*f3aed369SNikolas Klauser 4203e519524SHoward Hinnanttemplate <class _Tp, class _Container> 421392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4223e519524SHoward Hinnantbool 4233e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4243e519524SHoward Hinnant{ 4253e519524SHoward Hinnant return __x.c == __y.c; 4263e519524SHoward Hinnant} 4273e519524SHoward Hinnant 4283e519524SHoward Hinnanttemplate <class _Tp, class _Container> 429392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4303e519524SHoward Hinnantbool 4313e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4323e519524SHoward Hinnant{ 4333e519524SHoward Hinnant return __x.c < __y.c; 4343e519524SHoward Hinnant} 4353e519524SHoward Hinnant 4363e519524SHoward Hinnanttemplate <class _Tp, class _Container> 437392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4383e519524SHoward Hinnantbool 4393e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4403e519524SHoward Hinnant{ 4413e519524SHoward Hinnant return !(__x == __y); 4423e519524SHoward Hinnant} 4433e519524SHoward Hinnant 4443e519524SHoward Hinnanttemplate <class _Tp, class _Container> 445392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4463e519524SHoward Hinnantbool 4473e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4483e519524SHoward Hinnant{ 4493e519524SHoward Hinnant return __y < __x; 4503e519524SHoward Hinnant} 4513e519524SHoward Hinnant 4523e519524SHoward Hinnanttemplate <class _Tp, class _Container> 453392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4543e519524SHoward Hinnantbool 4553e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4563e519524SHoward Hinnant{ 4573e519524SHoward Hinnant return !(__x < __y); 4583e519524SHoward Hinnant} 4593e519524SHoward Hinnant 4603e519524SHoward Hinnanttemplate <class _Tp, class _Container> 461392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4623e519524SHoward Hinnantbool 4633e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4643e519524SHoward Hinnant{ 4653e519524SHoward Hinnant return !(__y < __x); 4663e519524SHoward Hinnant} 4673e519524SHoward Hinnant 4683e519524SHoward Hinnanttemplate <class _Tp, class _Container> 469392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 470b4e88d4dSLouis Dionne__enable_if_t<__is_swappable<_Container>::value, void> 4713e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4726971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4733e519524SHoward Hinnant{ 4743e519524SHoward Hinnant __x.swap(__y); 4753e519524SHoward Hinnant} 4763e519524SHoward Hinnant 4773e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc> 478e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4793e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 4803e519524SHoward Hinnant{ 4813e519524SHoward Hinnant}; 4823e519524SHoward Hinnant 4833e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>, 4843e519524SHoward Hinnant class _Compare = less<typename _Container::value_type> > 485e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue 4863e519524SHoward Hinnant{ 4873e519524SHoward Hinnantpublic: 4883e519524SHoward Hinnant typedef _Container container_type; 4893e519524SHoward Hinnant typedef _Compare value_compare; 4903e519524SHoward Hinnant typedef typename container_type::value_type value_type; 4913e519524SHoward Hinnant typedef typename container_type::reference reference; 4923e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 4933e519524SHoward Hinnant typedef typename container_type::size_type size_type; 494c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 4953e519524SHoward Hinnant 4963e519524SHoward Hinnantprotected: 4973e519524SHoward Hinnant container_type c; 4983e519524SHoward Hinnant value_compare comp; 4993e519524SHoward Hinnant 5003e519524SHoward Hinnantpublic: 501392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5026971d826SHoward Hinnant priority_queue() 5036971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 5046971d826SHoward Hinnant is_nothrow_default_constructible<value_compare>::value) 5056971d826SHoward Hinnant : c(), comp() {} 5066971d826SHoward Hinnant 5076971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5086971d826SHoward Hinnant priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5096971d826SHoward Hinnant 510f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 511f5427b26SEric Fiselier priority_queue& operator=(const priority_queue& __q) 512f5427b26SEric Fiselier {c = __q.c; comp = __q.comp; return *this;} 513f5427b26SEric Fiselier 514f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5156971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5166971d826SHoward Hinnant priority_queue(priority_queue&& __q) 5176971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 5186971d826SHoward Hinnant is_nothrow_move_constructible<value_compare>::value) 519ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 5206971d826SHoward Hinnant 5216971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5226971d826SHoward Hinnant priority_queue& operator=(priority_queue&& __q) 5236971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 5246971d826SHoward Hinnant is_nothrow_move_assignable<value_compare>::value) 525ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 526f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5276971d826SHoward Hinnant 5286971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5296971d826SHoward Hinnant explicit priority_queue(const value_compare& __comp) 5303e519524SHoward Hinnant : c(), comp(__comp) {} 531cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5323e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c); 533f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 534cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 535a11f8b1aSMarek Kurdej priority_queue(const value_compare& __comp, container_type&& __c); 5363e519524SHoward Hinnant#endif 537b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 538cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5393e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5403e519524SHoward Hinnant const value_compare& __comp = value_compare()); 541b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 542cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5433e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5443e519524SHoward Hinnant const value_compare& __comp, const container_type& __c); 545f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 546b4e88d4dSLouis Dionne template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 547cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5483e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5493e519524SHoward Hinnant const value_compare& __comp, container_type&& __c); 550f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5513e519524SHoward Hinnant template <class _Alloc> 552cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5533e519524SHoward Hinnant explicit priority_queue(const _Alloc& __a, 554b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5553e519524SHoward Hinnant template <class _Alloc> 556cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5573e519524SHoward Hinnant priority_queue(const value_compare& __comp, const _Alloc& __a, 558b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5593e519524SHoward Hinnant template <class _Alloc> 560cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5613e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c, 5623e519524SHoward Hinnant const _Alloc& __a, 563b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5643e519524SHoward Hinnant template <class _Alloc> 565cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5663e519524SHoward Hinnant priority_queue(const priority_queue& __q, const _Alloc& __a, 567b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 568f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5693e519524SHoward Hinnant template <class _Alloc> 570cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5713e519524SHoward Hinnant priority_queue(const value_compare& __comp, 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(priority_queue&& __q, const _Alloc& __a, 577b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 578f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5793e519524SHoward Hinnant 580b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5813894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5823894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 583b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5843894a8a4SArthur O'Dwyer 585b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5863894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5873894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5883894a8a4SArthur O'Dwyer const value_compare& __comp, 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 container_type& __c, const _Alloc& __a, 595b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5963894a8a4SArthur O'Dwyer 5973894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 598b4e88d4dSLouis Dionne template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5993894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 6003894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 6013894a8a4SArthur O'Dwyer const value_compare& __comp, container_type&& __c, const _Alloc& __a, 602b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6033894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 6043894a8a4SArthur O'Dwyer 60572c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6063e519524SHoward Hinnant bool empty() const {return c.empty();} 607392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6083e519524SHoward Hinnant size_type size() const {return c.size();} 609392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 6103e519524SHoward Hinnant const_reference top() const {return c.front();} 6113e519524SHoward Hinnant 612cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6133e519524SHoward Hinnant void push(const value_type& __v); 614f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 615cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6163e519524SHoward Hinnant void push(value_type&& __v); 617f5427b26SEric Fiselier template <class... _Args> 618f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 619f5427b26SEric Fiselier void emplace(_Args&&... __args); 620f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 621cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6223e519524SHoward Hinnant void pop(); 6233e519524SHoward Hinnant 624cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 6256971d826SHoward Hinnant void swap(priority_queue& __q) 6266971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 6276971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value); 6283e519524SHoward Hinnant}; 6293e519524SHoward Hinnant 63001666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 6315b8b8b5dSMarshall Clowtemplate <class _Compare, 6325b8b8b5dSMarshall Clow class _Container, 6334e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6344e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6355b8b8b5dSMarshall Clow> 6365b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container) 6375b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6385b8b8b5dSMarshall Clow 6395b8b8b5dSMarshall Clowtemplate<class _InputIterator, 640199d2ebeSArthur O'Dwyer class _Compare = less<__iter_value_type<_InputIterator>>, 641199d2ebeSArthur O'Dwyer class _Container = vector<__iter_value_type<_InputIterator>>, 6424e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 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(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 647199d2ebeSArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6485b8b8b5dSMarshall Clow 6495b8b8b5dSMarshall Clowtemplate<class _Compare, 6505b8b8b5dSMarshall Clow class _Container, 6515b8b8b5dSMarshall Clow class _Alloc, 6524e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6534e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6544e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6555b8b8b5dSMarshall Clow> 6565b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc) 6575b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6583894a8a4SArthur O'Dwyer 6593894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator, 6604e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6614e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6623894a8a4SArthur O'Dwyer> 6633894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator) 6643894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6653894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, 6663894a8a4SArthur O'Dwyer less<__iter_value_type<_InputIterator>>>; 6673894a8a4SArthur O'Dwyer 6683894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator, 6694e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6704e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6714e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6723894a8a4SArthur O'Dwyer> 6733894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 6743894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6753894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 6763894a8a4SArthur O'Dwyer 6773894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 6784e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 6794e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 6804e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 6814e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6823894a8a4SArthur O'Dwyer> 6833894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 6843894a8a4SArthur O'Dwyer -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6855b8b8b5dSMarshall Clow#endif 6865b8b8b5dSMarshall Clow 6873e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 688cd31b434SEvgeniy Stepanovinline 6893e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6903e519524SHoward Hinnant const container_type& __c) 6913e519524SHoward Hinnant : c(__c), 6923e519524SHoward Hinnant comp(__comp) 6933e519524SHoward Hinnant{ 694ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6953e519524SHoward Hinnant} 6963e519524SHoward Hinnant 697f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 6983e519524SHoward Hinnant 6993e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 700cd31b434SEvgeniy Stepanovinline 7013e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7023e519524SHoward Hinnant container_type&& __c) 703ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7043e519524SHoward Hinnant comp(__comp) 7053e519524SHoward Hinnant{ 706ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7073e519524SHoward Hinnant} 7083e519524SHoward Hinnant 709f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7103e519524SHoward Hinnant 7113e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7123894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 713cd31b434SEvgeniy Stepanovinline 7143e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7153e519524SHoward Hinnant const value_compare& __comp) 7163e519524SHoward Hinnant : c(__f, __l), 7173e519524SHoward Hinnant comp(__comp) 7183e519524SHoward Hinnant{ 719ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7203e519524SHoward Hinnant} 7213e519524SHoward Hinnant 7223e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7233894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 724cd31b434SEvgeniy Stepanovinline 7253e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7263e519524SHoward Hinnant const value_compare& __comp, 7273e519524SHoward Hinnant const container_type& __c) 7283e519524SHoward Hinnant : c(__c), 7293e519524SHoward Hinnant comp(__comp) 7303e519524SHoward Hinnant{ 7313e519524SHoward Hinnant c.insert(c.end(), __f, __l); 732ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7333e519524SHoward Hinnant} 7343e519524SHoward Hinnant 735f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7363e519524SHoward Hinnant 7373e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7383894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 739cd31b434SEvgeniy Stepanovinline 7403e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7413e519524SHoward Hinnant const value_compare& __comp, 7423e519524SHoward Hinnant container_type&& __c) 743ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7443e519524SHoward Hinnant comp(__comp) 7453e519524SHoward Hinnant{ 7463e519524SHoward Hinnant c.insert(c.end(), __f, __l); 747ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7483e519524SHoward Hinnant} 7493e519524SHoward Hinnant 750f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7513e519524SHoward Hinnant 7523e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7533e519524SHoward Hinnanttemplate <class _Alloc> 754cd31b434SEvgeniy Stepanovinline 7553e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 756b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7573e519524SHoward Hinnant : c(__a) 7583e519524SHoward Hinnant{ 7593e519524SHoward Hinnant} 7603e519524SHoward Hinnant 7613e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7623e519524SHoward Hinnanttemplate <class _Alloc> 763cd31b434SEvgeniy Stepanovinline 7643e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7653e519524SHoward Hinnant const _Alloc& __a, 766b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7673e519524SHoward Hinnant : c(__a), 7683e519524SHoward Hinnant comp(__comp) 7693e519524SHoward Hinnant{ 7703e519524SHoward Hinnant} 7713e519524SHoward Hinnant 7723e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7733e519524SHoward Hinnanttemplate <class _Alloc> 774cd31b434SEvgeniy Stepanovinline 7753e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7763e519524SHoward Hinnant const container_type& __c, 7773e519524SHoward Hinnant const _Alloc& __a, 778b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7793e519524SHoward Hinnant : c(__c, __a), 7803e519524SHoward Hinnant comp(__comp) 7813e519524SHoward Hinnant{ 782ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7833e519524SHoward Hinnant} 7843e519524SHoward Hinnant 7853e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7863e519524SHoward Hinnanttemplate <class _Alloc> 787cd31b434SEvgeniy Stepanovinline 7883e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7893e519524SHoward Hinnant const _Alloc& __a, 790b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7913e519524SHoward Hinnant : c(__q.c, __a), 7923e519524SHoward Hinnant comp(__q.comp) 7933e519524SHoward Hinnant{ 7943e519524SHoward Hinnant} 7953e519524SHoward Hinnant 796f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7973e519524SHoward Hinnant 7983e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7993e519524SHoward Hinnanttemplate <class _Alloc> 800cd31b434SEvgeniy Stepanovinline 8013e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8023e519524SHoward Hinnant container_type&& __c, 8033e519524SHoward Hinnant const _Alloc& __a, 804b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 805ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a), 8063e519524SHoward Hinnant comp(__comp) 8073e519524SHoward Hinnant{ 808ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8093e519524SHoward Hinnant} 8103e519524SHoward Hinnant 8113e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8123e519524SHoward Hinnanttemplate <class _Alloc> 813cd31b434SEvgeniy Stepanovinline 8143e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 8153e519524SHoward Hinnant const _Alloc& __a, 816b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 817ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a), 818ce48a113SHoward Hinnant comp(_VSTD::move(__q.comp)) 8193e519524SHoward Hinnant{ 8203894a8a4SArthur O'Dwyer} 8213894a8a4SArthur O'Dwyer 8223894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 8233894a8a4SArthur O'Dwyer 8243894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8253894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8263894a8a4SArthur O'Dwyerinline 8273894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8283894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const _Alloc& __a, 829b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8303894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8313894a8a4SArthur O'Dwyer comp() 8323894a8a4SArthur O'Dwyer{ 833ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 8343e519524SHoward Hinnant} 8353e519524SHoward Hinnant 8363894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8373894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8383894a8a4SArthur O'Dwyerinline 8393894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8403894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8413894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 842b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8433894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8443894a8a4SArthur O'Dwyer comp(__comp) 8453894a8a4SArthur O'Dwyer{ 8463894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8473894a8a4SArthur O'Dwyer} 8483894a8a4SArthur O'Dwyer 8493894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8503894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8513894a8a4SArthur O'Dwyerinline 8523894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8533894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8543894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 855b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8563894a8a4SArthur O'Dwyer : c(__c, __a), 8573894a8a4SArthur O'Dwyer comp(__comp) 8583894a8a4SArthur O'Dwyer{ 8593894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8603894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8613894a8a4SArthur O'Dwyer} 8623894a8a4SArthur O'Dwyer 8633894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 8643894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8653894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8663894a8a4SArthur O'Dwyerinline 8673894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8683894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const value_compare& __comp, 8693894a8a4SArthur O'Dwyer container_type&& __c, const _Alloc& __a, 870b4e88d4dSLouis Dionne __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8713894a8a4SArthur O'Dwyer : c(_VSTD::move(__c), __a), 8723894a8a4SArthur O'Dwyer comp(__comp) 8733894a8a4SArthur O'Dwyer{ 8743894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8753894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8763894a8a4SArthur O'Dwyer} 877f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8783e519524SHoward Hinnant 8793e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 880cd31b434SEvgeniy Stepanovinline 8813e519524SHoward Hinnantvoid 8823e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8833e519524SHoward Hinnant{ 8843e519524SHoward Hinnant c.push_back(__v); 885ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8863e519524SHoward Hinnant} 8873e519524SHoward Hinnant 888f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8893e519524SHoward Hinnant 8903e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 891cd31b434SEvgeniy Stepanovinline 8923e519524SHoward Hinnantvoid 8933e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 8943e519524SHoward Hinnant{ 895ce48a113SHoward Hinnant c.push_back(_VSTD::move(__v)); 896ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8973e519524SHoward Hinnant} 8983e519524SHoward Hinnant 8993e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 9003e519524SHoward Hinnanttemplate <class... _Args> 901cd31b434SEvgeniy Stepanovinline 9023e519524SHoward Hinnantvoid 9033e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 9043e519524SHoward Hinnant{ 905ce48a113SHoward Hinnant c.emplace_back(_VSTD::forward<_Args>(__args)...); 906ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 9073e519524SHoward Hinnant} 9083e519524SHoward Hinnant 909f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 9103e519524SHoward Hinnant 9113e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 912cd31b434SEvgeniy Stepanovinline 9133e519524SHoward Hinnantvoid 9143e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop() 9153e519524SHoward Hinnant{ 916ce48a113SHoward Hinnant _VSTD::pop_heap(c.begin(), c.end(), comp); 9173e519524SHoward Hinnant c.pop_back(); 9183e519524SHoward Hinnant} 9193e519524SHoward Hinnant 9203e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 921cd31b434SEvgeniy Stepanovinline 9223e519524SHoward Hinnantvoid 9233e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 9246971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 9256971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value) 9263e519524SHoward Hinnant{ 927ce48a113SHoward Hinnant using _VSTD::swap; 9283e519524SHoward Hinnant swap(c, __q.c); 9293e519524SHoward Hinnant swap(comp, __q.comp); 9303e519524SHoward Hinnant} 9313e519524SHoward Hinnant 9323e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 933392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 934b4e88d4dSLouis Dionne__enable_if_t< 935199d2ebeSArthur O'Dwyer __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 9363e519524SHoward Hinnant void 937199d2ebeSArthur O'Dwyer> 9383e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x, 9393e519524SHoward Hinnant priority_queue<_Tp, _Container, _Compare>& __y) 9406971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9413e519524SHoward Hinnant{ 9423e519524SHoward Hinnant __x.swap(__y); 9433e519524SHoward Hinnant} 9443e519524SHoward Hinnant 9453e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc> 946e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9473e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 9483e519524SHoward Hinnant{ 9493e519524SHoward Hinnant}; 9503e519524SHoward Hinnant 9513e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 9523e519524SHoward Hinnant 9533e519524SHoward Hinnant#endif // _LIBCPP_QUEUE 954