10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_QUEUE 110b57cec5SDimitry Andric#define _LIBCPP_QUEUE 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric queue synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andrictemplate <class T, class Container = deque<T>> 200b57cec5SDimitry Andricclass queue 210b57cec5SDimitry Andric{ 220b57cec5SDimitry Andricpublic: 230b57cec5SDimitry Andric typedef Container container_type; 240b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 250b57cec5SDimitry Andric typedef typename container_type::reference reference; 260b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 270b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andricprotected: 300b57cec5SDimitry Andric container_type c; 310b57cec5SDimitry Andric 320b57cec5SDimitry Andricpublic: 330b57cec5SDimitry Andric queue() = default; 340b57cec5SDimitry Andric ~queue() = default; 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric queue(const queue& q) = default; 370b57cec5SDimitry Andric queue(queue&& q) = default; 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric queue& operator=(const queue& q) = default; 400b57cec5SDimitry Andric queue& operator=(queue&& q) = default; 410b57cec5SDimitry Andric 420b57cec5SDimitry Andric explicit queue(const container_type& c); 430b57cec5SDimitry Andric explicit queue(container_type&& c) 4404eeddc0SDimitry Andric template<class InputIterator> 4504eeddc0SDimitry Andric queue(InputIterator first, InputIterator last); // since C++23 460b57cec5SDimitry Andric template <class Alloc> 470b57cec5SDimitry Andric explicit queue(const Alloc& a); 480b57cec5SDimitry Andric template <class Alloc> 490b57cec5SDimitry Andric queue(const container_type& c, const Alloc& a); 500b57cec5SDimitry Andric template <class Alloc> 510b57cec5SDimitry Andric queue(container_type&& c, const Alloc& a); 520b57cec5SDimitry Andric template <class Alloc> 530b57cec5SDimitry Andric queue(const queue& q, const Alloc& a); 540b57cec5SDimitry Andric template <class Alloc> 550b57cec5SDimitry Andric queue(queue&& q, const Alloc& a); 5604eeddc0SDimitry Andric template <class InputIterator, class Alloc> 5704eeddc0SDimitry Andric queue(InputIterator first, InputIterator last, const Alloc&); // since C++23 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric bool empty() const; 600b57cec5SDimitry Andric size_type size() const; 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric reference front(); 630b57cec5SDimitry Andric const_reference front() const; 640b57cec5SDimitry Andric reference back(); 650b57cec5SDimitry Andric const_reference back() const; 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric void push(const value_type& v); 680b57cec5SDimitry Andric void push(value_type&& v); 690b57cec5SDimitry Andric template <class... Args> reference emplace(Args&&... args); // reference in C++17 700b57cec5SDimitry Andric void pop(); 710b57cec5SDimitry Andric 720b57cec5SDimitry Andric void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) 730b57cec5SDimitry Andric}; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andrictemplate<class Container> 760b57cec5SDimitry Andric queue(Container) -> queue<typename Container::value_type, Container>; // C++17 770b57cec5SDimitry Andric 7804eeddc0SDimitry Andrictemplate<class InputIterator> 7904eeddc0SDimitry Andric queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 8004eeddc0SDimitry Andric 810b57cec5SDimitry Andrictemplate<class Container, class Allocator> 820b57cec5SDimitry Andric queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 830b57cec5SDimitry Andric 8404eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator> 8504eeddc0SDimitry Andric queue(InputIterator, InputIterator, Allocator) 8604eeddc0SDimitry Andric -> queue<iter-value-type<InputIterator>, 8704eeddc0SDimitry Andric deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 8804eeddc0SDimitry Andric 890b57cec5SDimitry Andrictemplate <class T, class Container> 900b57cec5SDimitry Andric bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); 910b57cec5SDimitry Andric 920b57cec5SDimitry Andrictemplate <class T, class Container> 930b57cec5SDimitry Andric bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); 940b57cec5SDimitry Andric 950b57cec5SDimitry Andrictemplate <class T, class Container> 960b57cec5SDimitry Andric bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); 970b57cec5SDimitry Andric 980b57cec5SDimitry Andrictemplate <class T, class Container> 990b57cec5SDimitry Andric bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andrictemplate <class T, class Container> 1020b57cec5SDimitry Andric bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andrictemplate <class T, class Container> 1050b57cec5SDimitry Andric bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andrictemplate <class T, class Container> 1080b57cec5SDimitry Andric void swap(queue<T, Container>& x, queue<T, Container>& y) 1090b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>, 1120b57cec5SDimitry Andric class Compare = less<typename Container::value_type>> 1130b57cec5SDimitry Andricclass priority_queue 1140b57cec5SDimitry Andric{ 1150b57cec5SDimitry Andricpublic: 1160b57cec5SDimitry Andric typedef Container container_type; 1170b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 1180b57cec5SDimitry Andric typedef typename container_type::reference reference; 1190b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 1200b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andricprotected: 1230b57cec5SDimitry Andric container_type c; 1240b57cec5SDimitry Andric Compare comp; 1250b57cec5SDimitry Andric 1260b57cec5SDimitry Andricpublic: 127e8d8bef9SDimitry Andric priority_queue() : priority_queue(Compare()) {} // C++20 128e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} 129e8d8bef9SDimitry Andric priority_queue(const Compare& x, const Container&); 130e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 131e8d8bef9SDimitry Andric priority_queue(const Compare& x, Container&&); // C++20 1320b57cec5SDimitry Andric template <class InputIterator> 1330b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 1340b57cec5SDimitry Andric const Compare& comp = Compare()); 1350b57cec5SDimitry Andric template <class InputIterator> 1360b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 137349cc55cSDimitry Andric const Compare& comp, const Container& c); 1380b57cec5SDimitry Andric template <class InputIterator> 1390b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 140349cc55cSDimitry Andric const Compare& comp, Container&& c); 1410b57cec5SDimitry Andric template <class Alloc> 1420b57cec5SDimitry Andric explicit priority_queue(const Alloc& a); 1430b57cec5SDimitry Andric template <class Alloc> 1440b57cec5SDimitry Andric priority_queue(const Compare& comp, const Alloc& a); 1450b57cec5SDimitry Andric template <class Alloc> 146349cc55cSDimitry Andric priority_queue(const Compare& comp, const Container& c, 1470b57cec5SDimitry Andric const Alloc& a); 1480b57cec5SDimitry Andric template <class Alloc> 149349cc55cSDimitry Andric priority_queue(const Compare& comp, Container&& c, 1500b57cec5SDimitry Andric const Alloc& a); 151349cc55cSDimitry Andric template <class InputIterator> 152349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 153349cc55cSDimitry Andric const Alloc& a); 154349cc55cSDimitry Andric template <class InputIterator> 155349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 156349cc55cSDimitry Andric const Compare& comp, const Alloc& a); 157349cc55cSDimitry Andric template <class InputIterator> 158349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 159349cc55cSDimitry Andric const Compare& comp, const Container& c, const Alloc& a); 160349cc55cSDimitry Andric template <class InputIterator> 161349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 162349cc55cSDimitry Andric const Compare& comp, Container&& c, const Alloc& a); 1630b57cec5SDimitry Andric template <class Alloc> 1640b57cec5SDimitry Andric priority_queue(const priority_queue& q, const Alloc& a); 1650b57cec5SDimitry Andric template <class Alloc> 1660b57cec5SDimitry Andric priority_queue(priority_queue&& q, const Alloc& a); 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andric bool empty() const; 1690b57cec5SDimitry Andric size_type size() const; 1700b57cec5SDimitry Andric const_reference top() const; 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric void push(const value_type& v); 1730b57cec5SDimitry Andric void push(value_type&& v); 1740b57cec5SDimitry Andric template <class... Args> void emplace(Args&&... args); 1750b57cec5SDimitry Andric void pop(); 1760b57cec5SDimitry Andric 1770b57cec5SDimitry Andric void swap(priority_queue& q) 1780b57cec5SDimitry Andric noexcept(is_nothrow_swappable_v<Container> && 1790b57cec5SDimitry Andric is_nothrow_swappable_v<Comp>) 1800b57cec5SDimitry Andric}; 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andrictemplate <class Compare, class Container> 1830b57cec5SDimitry Andricpriority_queue(Compare, Container) 1840b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1850b57cec5SDimitry Andric 1860b57cec5SDimitry Andrictemplate<class InputIterator, 187349cc55cSDimitry Andric class Compare = less<iter-value-type<InputIterator>>, 188349cc55cSDimitry Andric class Container = vector<iter-value-type<InputIterator>>> 1890b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) 190349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator> 1930b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator) 1940b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1950b57cec5SDimitry Andric 196349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 197349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator) 198349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 199349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, 200349cc55cSDimitry Andric less<iter-value-type<InputIterator>>>; // C++17 201349cc55cSDimitry Andric 202349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator> 203349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator) 204349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 205349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 206349cc55cSDimitry Andric 207349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator> 208349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator) 209349cc55cSDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 210349cc55cSDimitry Andric 2110b57cec5SDimitry Andrictemplate <class T, class Container, class Compare> 2120b57cec5SDimitry Andric void swap(priority_queue<T, Container, Compare>& x, 2130b57cec5SDimitry Andric priority_queue<T, Container, Compare>& y) 2140b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2150b57cec5SDimitry Andric 2160b57cec5SDimitry Andric} // std 2170b57cec5SDimitry Andric 2180b57cec5SDimitry Andric*/ 2190b57cec5SDimitry Andric 2200b57cec5SDimitry Andric#include <__config> 22104eeddc0SDimitry Andric#include <__iterator/iterator_traits.h> 222fe6060f1SDimitry Andric#include <__memory/uses_allocator.h> 223fe6060f1SDimitry Andric#include <__utility/forward.h> 2240b57cec5SDimitry Andric#include <algorithm> 225fe6060f1SDimitry Andric#include <compare> 226fe6060f1SDimitry Andric#include <deque> 227fe6060f1SDimitry Andric#include <functional> 22804eeddc0SDimitry Andric#include <type_traits> 229fe6060f1SDimitry Andric#include <vector> 23004eeddc0SDimitry Andric#include <version> 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2330b57cec5SDimitry Andric#pragma GCC system_header 2340b57cec5SDimitry Andric#endif 2350b57cec5SDimitry Andric 2360b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 2410b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 2420b57cec5SDimitry Andricbool 2430b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2440b57cec5SDimitry Andric 2450b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 2460b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 2470b57cec5SDimitry Andricbool 2480b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2490b57cec5SDimitry Andric 2500b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 2510b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue 2520b57cec5SDimitry Andric{ 2530b57cec5SDimitry Andricpublic: 2540b57cec5SDimitry Andric typedef _Container container_type; 2550b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 2560b57cec5SDimitry Andric typedef typename container_type::reference reference; 2570b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 2580b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 2590b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andricprotected: 2620b57cec5SDimitry Andric container_type c; 2630b57cec5SDimitry Andric 2640b57cec5SDimitry Andricpublic: 2650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2660b57cec5SDimitry Andric queue() 2670b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2680b57cec5SDimitry Andric : c() {} 2690b57cec5SDimitry Andric 2700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2710b57cec5SDimitry Andric queue(const queue& __q) : c(__q.c) {} 2720b57cec5SDimitry Andric 27304eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20 27404eeddc0SDimitry Andric template <class _InputIterator, 27504eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 27604eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 27704eeddc0SDimitry Andric queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 27804eeddc0SDimitry Andric 27904eeddc0SDimitry Andric template <class _InputIterator, 28004eeddc0SDimitry Andric class _Alloc, 28104eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 28204eeddc0SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 28304eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 28404eeddc0SDimitry Andric queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 28504eeddc0SDimitry Andric#endif 28604eeddc0SDimitry Andric 2870b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2880b57cec5SDimitry Andric queue& operator=(const queue& __q) {c = __q.c; return *this;} 2890b57cec5SDimitry Andric 2900b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2920b57cec5SDimitry Andric queue(queue&& __q) 2930b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 2940b57cec5SDimitry Andric : c(_VSTD::move(__q.c)) {} 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2970b57cec5SDimitry Andric queue& operator=(queue&& __q) 2980b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 2990b57cec5SDimitry Andric {c = _VSTD::move(__q.c); return *this;} 3000b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3010b57cec5SDimitry Andric 3020b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3030b57cec5SDimitry Andric explicit queue(const container_type& __c) : c(__c) {} 3040b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3050b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3060b57cec5SDimitry Andric explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 3070b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3080b57cec5SDimitry Andric template <class _Alloc> 3090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3100b57cec5SDimitry Andric explicit queue(const _Alloc& __a, 311349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3120b57cec5SDimitry Andric : c(__a) {} 3130b57cec5SDimitry Andric template <class _Alloc> 3140b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3150b57cec5SDimitry Andric queue(const queue& __q, const _Alloc& __a, 316349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3170b57cec5SDimitry Andric : c(__q.c, __a) {} 3180b57cec5SDimitry Andric template <class _Alloc> 3190b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3200b57cec5SDimitry Andric queue(const container_type& __c, const _Alloc& __a, 321349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3220b57cec5SDimitry Andric : c(__c, __a) {} 3230b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3240b57cec5SDimitry Andric template <class _Alloc> 3250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3260b57cec5SDimitry Andric queue(container_type&& __c, const _Alloc& __a, 327349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3280b57cec5SDimitry Andric : c(_VSTD::move(__c), __a) {} 3290b57cec5SDimitry Andric template <class _Alloc> 3300b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3310b57cec5SDimitry Andric queue(queue&& __q, const _Alloc& __a, 332349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3330b57cec5SDimitry Andric : c(_VSTD::move(__q.c), __a) {} 3340b57cec5SDimitry Andric 3350b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3380b57cec5SDimitry Andric bool empty() const {return c.empty();} 3390b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3400b57cec5SDimitry Andric size_type size() const {return c.size();} 3410b57cec5SDimitry Andric 3420b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3430b57cec5SDimitry Andric reference front() {return c.front();} 3440b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3450b57cec5SDimitry Andric const_reference front() const {return c.front();} 3460b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3470b57cec5SDimitry Andric reference back() {return c.back();} 3480b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3490b57cec5SDimitry Andric const_reference back() const {return c.back();} 3500b57cec5SDimitry Andric 3510b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3520b57cec5SDimitry Andric void push(const value_type& __v) {c.push_back(__v);} 3530b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3540b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3550b57cec5SDimitry Andric void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3560b57cec5SDimitry Andric template <class... _Args> 3570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3580b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 3590b57cec5SDimitry Andric decltype(auto) emplace(_Args&&... __args) 3600b57cec5SDimitry Andric { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 3610b57cec5SDimitry Andric#else 3620b57cec5SDimitry Andric void emplace(_Args&&... __args) 3630b57cec5SDimitry Andric { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 3640b57cec5SDimitry Andric#endif 3650b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3670b57cec5SDimitry Andric void pop() {c.pop_front();} 3680b57cec5SDimitry Andric 3690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3700b57cec5SDimitry Andric void swap(queue& __q) 3710b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3720b57cec5SDimitry Andric { 3730b57cec5SDimitry Andric using _VSTD::swap; 3740b57cec5SDimitry Andric swap(c, __q.c); 3750b57cec5SDimitry Andric } 3760b57cec5SDimitry Andric 3770b57cec5SDimitry Andric template <class _T1, class _C1> 3780b57cec5SDimitry Andric friend 3790b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3800b57cec5SDimitry Andric bool 3810b57cec5SDimitry Andric operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3820b57cec5SDimitry Andric 3830b57cec5SDimitry Andric template <class _T1, class _C1> 3840b57cec5SDimitry Andric friend 3850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3860b57cec5SDimitry Andric bool 3870b57cec5SDimitry Andric operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3880b57cec5SDimitry Andric}; 3890b57cec5SDimitry Andric 39004eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 14 3910b57cec5SDimitry Andrictemplate<class _Container, 392349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 3930b57cec5SDimitry Andric> 3940b57cec5SDimitry Andricqueue(_Container) 3950b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 3960b57cec5SDimitry Andric 3970b57cec5SDimitry Andrictemplate<class _Container, 3980b57cec5SDimitry Andric class _Alloc, 399349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 400349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4010b57cec5SDimitry Andric> 4020b57cec5SDimitry Andricqueue(_Container, _Alloc) 4030b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 4040b57cec5SDimitry Andric#endif 4050b57cec5SDimitry Andric 40604eeddc0SDimitry Andric#if _LIBCPP_STD_VER > 20 40704eeddc0SDimitry Andrictemplate <class _InputIterator, 40804eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> 40904eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator) 41004eeddc0SDimitry Andric -> queue<__iter_value_type<_InputIterator>>; 41104eeddc0SDimitry Andric 41204eeddc0SDimitry Andrictemplate <class _InputIterator, 41304eeddc0SDimitry Andric class _Alloc, 41404eeddc0SDimitry Andric class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 41504eeddc0SDimitry Andric class = __enable_if_t<__is_allocator<_Alloc>::value>> 41604eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc) 41704eeddc0SDimitry Andric -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 41804eeddc0SDimitry Andric#endif 41904eeddc0SDimitry Andric 4200b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4210b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4220b57cec5SDimitry Andricbool 4230b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4240b57cec5SDimitry Andric{ 4250b57cec5SDimitry Andric return __x.c == __y.c; 4260b57cec5SDimitry Andric} 4270b57cec5SDimitry Andric 4280b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4290b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4300b57cec5SDimitry Andricbool 4310b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4320b57cec5SDimitry Andric{ 4330b57cec5SDimitry Andric return __x.c < __y.c; 4340b57cec5SDimitry Andric} 4350b57cec5SDimitry Andric 4360b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4370b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4380b57cec5SDimitry Andricbool 4390b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4400b57cec5SDimitry Andric{ 4410b57cec5SDimitry Andric return !(__x == __y); 4420b57cec5SDimitry Andric} 4430b57cec5SDimitry Andric 4440b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4450b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4460b57cec5SDimitry Andricbool 4470b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4480b57cec5SDimitry Andric{ 4490b57cec5SDimitry Andric return __y < __x; 4500b57cec5SDimitry Andric} 4510b57cec5SDimitry Andric 4520b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4530b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4540b57cec5SDimitry Andricbool 4550b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4560b57cec5SDimitry Andric{ 4570b57cec5SDimitry Andric return !(__x < __y); 4580b57cec5SDimitry Andric} 4590b57cec5SDimitry Andric 4600b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4610b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4620b57cec5SDimitry Andricbool 4630b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4640b57cec5SDimitry Andric{ 4650b57cec5SDimitry Andric return !(__y < __x); 4660b57cec5SDimitry Andric} 4670b57cec5SDimitry Andric 4680b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4690b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 470349cc55cSDimitry Andric__enable_if_t<__is_swappable<_Container>::value, void> 4710b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4720b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4730b57cec5SDimitry Andric{ 4740b57cec5SDimitry Andric __x.swap(__y); 4750b57cec5SDimitry Andric} 4760b57cec5SDimitry Andric 4770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 4780b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4790b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 4800b57cec5SDimitry Andric{ 4810b57cec5SDimitry Andric}; 4820b57cec5SDimitry Andric 4830b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, 4840b57cec5SDimitry Andric class _Compare = less<typename _Container::value_type> > 4850b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue 4860b57cec5SDimitry Andric{ 4870b57cec5SDimitry Andricpublic: 4880b57cec5SDimitry Andric typedef _Container container_type; 4890b57cec5SDimitry Andric typedef _Compare value_compare; 4900b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 4910b57cec5SDimitry Andric typedef typename container_type::reference reference; 4920b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 4930b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 4940b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 4950b57cec5SDimitry Andric 4960b57cec5SDimitry Andricprotected: 4970b57cec5SDimitry Andric container_type c; 4980b57cec5SDimitry Andric value_compare comp; 4990b57cec5SDimitry Andric 5000b57cec5SDimitry Andricpublic: 5010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5020b57cec5SDimitry Andric priority_queue() 5030b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 5040b57cec5SDimitry Andric is_nothrow_default_constructible<value_compare>::value) 5050b57cec5SDimitry Andric : c(), comp() {} 5060b57cec5SDimitry Andric 5070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5080b57cec5SDimitry Andric priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5090b57cec5SDimitry Andric 5100b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5110b57cec5SDimitry Andric priority_queue& operator=(const priority_queue& __q) 5120b57cec5SDimitry Andric {c = __q.c; comp = __q.comp; return *this;} 5130b57cec5SDimitry Andric 5140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5160b57cec5SDimitry Andric priority_queue(priority_queue&& __q) 5170b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 5180b57cec5SDimitry Andric is_nothrow_move_constructible<value_compare>::value) 5190b57cec5SDimitry Andric : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 5200b57cec5SDimitry Andric 5210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5220b57cec5SDimitry Andric priority_queue& operator=(priority_queue&& __q) 5230b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 5240b57cec5SDimitry Andric is_nothrow_move_assignable<value_compare>::value) 5250b57cec5SDimitry Andric {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 5260b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5270b57cec5SDimitry Andric 5280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5290b57cec5SDimitry Andric explicit priority_queue(const value_compare& __comp) 5300b57cec5SDimitry Andric : c(), comp(__comp) {} 5310b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5320b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c); 5330b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5340b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 535e8d8bef9SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c); 5360b57cec5SDimitry Andric#endif 537349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5380b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5390b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 5400b57cec5SDimitry Andric const value_compare& __comp = value_compare()); 541349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5420b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5430b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 5440b57cec5SDimitry Andric const value_compare& __comp, const container_type& __c); 5450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 546349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5480b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 5490b57cec5SDimitry Andric const value_compare& __comp, container_type&& __c); 5500b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5510b57cec5SDimitry Andric template <class _Alloc> 5520b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5530b57cec5SDimitry Andric explicit priority_queue(const _Alloc& __a, 554349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5550b57cec5SDimitry Andric template <class _Alloc> 5560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5570b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const _Alloc& __a, 558349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5590b57cec5SDimitry Andric template <class _Alloc> 5600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5610b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c, 5620b57cec5SDimitry Andric const _Alloc& __a, 563349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5640b57cec5SDimitry Andric template <class _Alloc> 5650b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5660b57cec5SDimitry Andric priority_queue(const priority_queue& __q, const _Alloc& __a, 567349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5680b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5690b57cec5SDimitry Andric template <class _Alloc> 5700b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5710b57cec5SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c, 5720b57cec5SDimitry Andric const _Alloc& __a, 573349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5740b57cec5SDimitry Andric template <class _Alloc> 5750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5760b57cec5SDimitry Andric priority_queue(priority_queue&& __q, const _Alloc& __a, 577349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 578349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 579349cc55cSDimitry Andric 580349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 581349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 582349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 583349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 584349cc55cSDimitry Andric 585349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 586349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 587349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 588349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 589349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 590349cc55cSDimitry Andric 591349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 592349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 593349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 594349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 595349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 596349cc55cSDimitry Andric 597349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 598349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 599349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 600349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 601349cc55cSDimitry Andric const value_compare& __comp, container_type&& __c, const _Alloc& __a, 602349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6030b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6040b57cec5SDimitry Andric 6050b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 6060b57cec5SDimitry Andric bool empty() const {return c.empty();} 6070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6080b57cec5SDimitry Andric size_type size() const {return c.size();} 6090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6100b57cec5SDimitry Andric const_reference top() const {return c.front();} 6110b57cec5SDimitry Andric 6120b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6130b57cec5SDimitry Andric void push(const value_type& __v); 6140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6160b57cec5SDimitry Andric void push(value_type&& __v); 6170b57cec5SDimitry Andric template <class... _Args> 6180b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6190b57cec5SDimitry Andric void emplace(_Args&&... __args); 6200b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6210b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6220b57cec5SDimitry Andric void pop(); 6230b57cec5SDimitry Andric 6240b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6250b57cec5SDimitry Andric void swap(priority_queue& __q) 6260b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 6270b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value); 6280b57cec5SDimitry Andric}; 6290b57cec5SDimitry Andric 630349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 6310b57cec5SDimitry Andrictemplate <class _Compare, 6320b57cec5SDimitry Andric class _Container, 633349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 634349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 6350b57cec5SDimitry Andric> 6360b57cec5SDimitry Andricpriority_queue(_Compare, _Container) 6370b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6380b57cec5SDimitry Andric 6390b57cec5SDimitry Andrictemplate<class _InputIterator, 640fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 641fe6060f1SDimitry Andric class _Container = vector<__iter_value_type<_InputIterator>>, 642349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 643349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 644349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 6450b57cec5SDimitry Andric> 6460b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 647fe6060f1SDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6480b57cec5SDimitry Andric 6490b57cec5SDimitry Andrictemplate<class _Compare, 6500b57cec5SDimitry Andric class _Container, 6510b57cec5SDimitry Andric class _Alloc, 652349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 653349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 654349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6550b57cec5SDimitry Andric> 6560b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc) 6570b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 658349cc55cSDimitry Andric 659349cc55cSDimitry Andrictemplate<class _InputIterator, class _Allocator, 660349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 661349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 662349cc55cSDimitry Andric> 663349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator) 664349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 665349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 666349cc55cSDimitry Andric less<__iter_value_type<_InputIterator>>>; 667349cc55cSDimitry Andric 668349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Allocator, 669349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 670349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 671349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 672349cc55cSDimitry Andric> 673349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 674349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 675349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 676349cc55cSDimitry Andric 677349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 678349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 679349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 680349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 681349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 682349cc55cSDimitry Andric> 683349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 684349cc55cSDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6850b57cec5SDimitry Andric#endif 6860b57cec5SDimitry Andric 6870b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 6880b57cec5SDimitry Andricinline 6890b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6900b57cec5SDimitry Andric const container_type& __c) 6910b57cec5SDimitry Andric : c(__c), 6920b57cec5SDimitry Andric comp(__comp) 6930b57cec5SDimitry Andric{ 6940b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 6950b57cec5SDimitry Andric} 6960b57cec5SDimitry Andric 6970b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6980b57cec5SDimitry Andric 6990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7000b57cec5SDimitry Andricinline 7010b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7020b57cec5SDimitry Andric container_type&& __c) 7030b57cec5SDimitry Andric : c(_VSTD::move(__c)), 7040b57cec5SDimitry Andric comp(__comp) 7050b57cec5SDimitry Andric{ 7060b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7070b57cec5SDimitry Andric} 7080b57cec5SDimitry Andric 7090b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7100b57cec5SDimitry Andric 7110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 712349cc55cSDimitry Andrictemplate <class _InputIter, class> 7130b57cec5SDimitry Andricinline 7140b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7150b57cec5SDimitry Andric const value_compare& __comp) 7160b57cec5SDimitry Andric : c(__f, __l), 7170b57cec5SDimitry Andric comp(__comp) 7180b57cec5SDimitry Andric{ 7190b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7200b57cec5SDimitry Andric} 7210b57cec5SDimitry Andric 7220b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 723349cc55cSDimitry Andrictemplate <class _InputIter, class> 7240b57cec5SDimitry Andricinline 7250b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7260b57cec5SDimitry Andric const value_compare& __comp, 7270b57cec5SDimitry Andric const container_type& __c) 7280b57cec5SDimitry Andric : c(__c), 7290b57cec5SDimitry Andric comp(__comp) 7300b57cec5SDimitry Andric{ 7310b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 7320b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7330b57cec5SDimitry Andric} 7340b57cec5SDimitry Andric 7350b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7360b57cec5SDimitry Andric 7370b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 738349cc55cSDimitry Andrictemplate <class _InputIter, class> 7390b57cec5SDimitry Andricinline 7400b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 7410b57cec5SDimitry Andric const value_compare& __comp, 7420b57cec5SDimitry Andric container_type&& __c) 7430b57cec5SDimitry Andric : c(_VSTD::move(__c)), 7440b57cec5SDimitry Andric comp(__comp) 7450b57cec5SDimitry Andric{ 7460b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 7470b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7480b57cec5SDimitry Andric} 7490b57cec5SDimitry Andric 7500b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7510b57cec5SDimitry Andric 7520b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7530b57cec5SDimitry Andrictemplate <class _Alloc> 7540b57cec5SDimitry Andricinline 7550b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 756349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7570b57cec5SDimitry Andric : c(__a) 7580b57cec5SDimitry Andric{ 7590b57cec5SDimitry Andric} 7600b57cec5SDimitry Andric 7610b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7620b57cec5SDimitry Andrictemplate <class _Alloc> 7630b57cec5SDimitry Andricinline 7640b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7650b57cec5SDimitry Andric const _Alloc& __a, 766349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7670b57cec5SDimitry Andric : c(__a), 7680b57cec5SDimitry Andric comp(__comp) 7690b57cec5SDimitry Andric{ 7700b57cec5SDimitry Andric} 7710b57cec5SDimitry Andric 7720b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7730b57cec5SDimitry Andrictemplate <class _Alloc> 7740b57cec5SDimitry Andricinline 7750b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7760b57cec5SDimitry Andric const container_type& __c, 7770b57cec5SDimitry Andric const _Alloc& __a, 778349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7790b57cec5SDimitry Andric : c(__c, __a), 7800b57cec5SDimitry Andric comp(__comp) 7810b57cec5SDimitry Andric{ 7820b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7830b57cec5SDimitry Andric} 7840b57cec5SDimitry Andric 7850b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7860b57cec5SDimitry Andrictemplate <class _Alloc> 7870b57cec5SDimitry Andricinline 7880b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7890b57cec5SDimitry Andric const _Alloc& __a, 790349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7910b57cec5SDimitry Andric : c(__q.c, __a), 7920b57cec5SDimitry Andric comp(__q.comp) 7930b57cec5SDimitry Andric{ 7940b57cec5SDimitry Andric} 7950b57cec5SDimitry Andric 7960b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7970b57cec5SDimitry Andric 7980b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7990b57cec5SDimitry Andrictemplate <class _Alloc> 8000b57cec5SDimitry Andricinline 8010b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8020b57cec5SDimitry Andric container_type&& __c, 8030b57cec5SDimitry Andric const _Alloc& __a, 804349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8050b57cec5SDimitry Andric : c(_VSTD::move(__c), __a), 8060b57cec5SDimitry Andric comp(__comp) 8070b57cec5SDimitry Andric{ 8080b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 8090b57cec5SDimitry Andric} 8100b57cec5SDimitry Andric 8110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8120b57cec5SDimitry Andrictemplate <class _Alloc> 8130b57cec5SDimitry Andricinline 8140b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 8150b57cec5SDimitry Andric const _Alloc& __a, 816349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 8170b57cec5SDimitry Andric : c(_VSTD::move(__q.c), __a), 8180b57cec5SDimitry Andric comp(_VSTD::move(__q.comp)) 8190b57cec5SDimitry Andric{ 820349cc55cSDimitry Andric} 821349cc55cSDimitry Andric 822349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 823349cc55cSDimitry Andric 824349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 825349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 826349cc55cSDimitry Andricinline 827349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 828349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const _Alloc& __a, 829349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 830349cc55cSDimitry Andric : c(__f, __l, __a), 831349cc55cSDimitry Andric comp() 832349cc55cSDimitry Andric{ 8330b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 8340b57cec5SDimitry Andric} 8350b57cec5SDimitry Andric 836349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 837349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 838349cc55cSDimitry Andricinline 839349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 840349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 841349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 842349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 843349cc55cSDimitry Andric : c(__f, __l, __a), 844349cc55cSDimitry Andric comp(__comp) 845349cc55cSDimitry Andric{ 846349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 847349cc55cSDimitry Andric} 848349cc55cSDimitry Andric 849349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 850349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 851349cc55cSDimitry Andricinline 852349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 853349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 854349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 855349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 856349cc55cSDimitry Andric : c(__c, __a), 857349cc55cSDimitry Andric comp(__comp) 858349cc55cSDimitry Andric{ 859349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 860349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 861349cc55cSDimitry Andric} 862349cc55cSDimitry Andric 863349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 864349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 865349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 866349cc55cSDimitry Andricinline 867349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 868349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, 869349cc55cSDimitry Andric container_type&& __c, const _Alloc& __a, 870349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 871349cc55cSDimitry Andric : c(_VSTD::move(__c), __a), 872349cc55cSDimitry Andric comp(__comp) 873349cc55cSDimitry Andric{ 874349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 875349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 876349cc55cSDimitry Andric} 8770b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8780b57cec5SDimitry Andric 8790b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8800b57cec5SDimitry Andricinline 8810b57cec5SDimitry Andricvoid 8820b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8830b57cec5SDimitry Andric{ 8840b57cec5SDimitry Andric c.push_back(__v); 8850b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 8860b57cec5SDimitry Andric} 8870b57cec5SDimitry Andric 8880b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8890b57cec5SDimitry Andric 8900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8910b57cec5SDimitry Andricinline 8920b57cec5SDimitry Andricvoid 8930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 8940b57cec5SDimitry Andric{ 8950b57cec5SDimitry Andric c.push_back(_VSTD::move(__v)); 8960b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 8970b57cec5SDimitry Andric} 8980b57cec5SDimitry Andric 8990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9000b57cec5SDimitry Andrictemplate <class... _Args> 9010b57cec5SDimitry Andricinline 9020b57cec5SDimitry Andricvoid 9030b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 9040b57cec5SDimitry Andric{ 9050b57cec5SDimitry Andric c.emplace_back(_VSTD::forward<_Args>(__args)...); 9060b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 9070b57cec5SDimitry Andric} 9080b57cec5SDimitry Andric 9090b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 9100b57cec5SDimitry Andric 9110b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9120b57cec5SDimitry Andricinline 9130b57cec5SDimitry Andricvoid 9140b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop() 9150b57cec5SDimitry Andric{ 9160b57cec5SDimitry Andric _VSTD::pop_heap(c.begin(), c.end(), comp); 9170b57cec5SDimitry Andric c.pop_back(); 9180b57cec5SDimitry Andric} 9190b57cec5SDimitry Andric 9200b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9210b57cec5SDimitry Andricinline 9220b57cec5SDimitry Andricvoid 9230b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 9240b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 9250b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value) 9260b57cec5SDimitry Andric{ 9270b57cec5SDimitry Andric using _VSTD::swap; 9280b57cec5SDimitry Andric swap(c, __q.c); 9290b57cec5SDimitry Andric swap(comp, __q.comp); 9300b57cec5SDimitry Andric} 9310b57cec5SDimitry Andric 9320b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9330b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 934349cc55cSDimitry Andric__enable_if_t< 935fe6060f1SDimitry Andric __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 9360b57cec5SDimitry Andric void 937fe6060f1SDimitry Andric> 9380b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, 9390b57cec5SDimitry Andric priority_queue<_Tp, _Container, _Compare>& __y) 9400b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 9410b57cec5SDimitry Andric{ 9420b57cec5SDimitry Andric __x.swap(__y); 9430b57cec5SDimitry Andric} 9440b57cec5SDimitry Andric 9450b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc> 9460b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9470b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 9480b57cec5SDimitry Andric{ 9490b57cec5SDimitry Andric}; 9500b57cec5SDimitry Andric 9510b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 9520b57cec5SDimitry Andric 9530b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE 954