10b57cec5SDimitry Andric// -*- C++ -*- 2*349cc55cSDimitry 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) 440b57cec5SDimitry Andric template <class Alloc> 450b57cec5SDimitry Andric explicit queue(const Alloc& a); 460b57cec5SDimitry Andric template <class Alloc> 470b57cec5SDimitry Andric queue(const container_type& c, const Alloc& a); 480b57cec5SDimitry Andric template <class Alloc> 490b57cec5SDimitry Andric queue(container_type&& c, const Alloc& a); 500b57cec5SDimitry Andric template <class Alloc> 510b57cec5SDimitry Andric queue(const queue& q, const Alloc& a); 520b57cec5SDimitry Andric template <class Alloc> 530b57cec5SDimitry Andric queue(queue&& q, const Alloc& a); 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric bool empty() const; 560b57cec5SDimitry Andric size_type size() const; 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric reference front(); 590b57cec5SDimitry Andric const_reference front() const; 600b57cec5SDimitry Andric reference back(); 610b57cec5SDimitry Andric const_reference back() const; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric void push(const value_type& v); 640b57cec5SDimitry Andric void push(value_type&& v); 650b57cec5SDimitry Andric template <class... Args> reference emplace(Args&&... args); // reference in C++17 660b57cec5SDimitry Andric void pop(); 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) 690b57cec5SDimitry Andric}; 700b57cec5SDimitry Andric 710b57cec5SDimitry Andrictemplate<class Container> 720b57cec5SDimitry Andric queue(Container) -> queue<typename Container::value_type, Container>; // C++17 730b57cec5SDimitry Andric 740b57cec5SDimitry Andrictemplate<class Container, class Allocator> 750b57cec5SDimitry Andric queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 760b57cec5SDimitry Andric 770b57cec5SDimitry Andrictemplate <class T, class Container> 780b57cec5SDimitry Andric bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); 790b57cec5SDimitry Andric 800b57cec5SDimitry Andrictemplate <class T, class Container> 810b57cec5SDimitry Andric bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); 820b57cec5SDimitry Andric 830b57cec5SDimitry Andrictemplate <class T, class Container> 840b57cec5SDimitry Andric bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); 850b57cec5SDimitry Andric 860b57cec5SDimitry Andrictemplate <class T, class Container> 870b57cec5SDimitry Andric bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); 880b57cec5SDimitry 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 void swap(queue<T, Container>& x, queue<T, Container>& y) 970b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 980b57cec5SDimitry Andric 990b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>, 1000b57cec5SDimitry Andric class Compare = less<typename Container::value_type>> 1010b57cec5SDimitry Andricclass priority_queue 1020b57cec5SDimitry Andric{ 1030b57cec5SDimitry Andricpublic: 1040b57cec5SDimitry Andric typedef Container container_type; 1050b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 1060b57cec5SDimitry Andric typedef typename container_type::reference reference; 1070b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 1080b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andricprotected: 1110b57cec5SDimitry Andric container_type c; 1120b57cec5SDimitry Andric Compare comp; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andricpublic: 115e8d8bef9SDimitry Andric priority_queue() : priority_queue(Compare()) {} // C++20 116e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} 117e8d8bef9SDimitry Andric priority_queue(const Compare& x, const Container&); 118e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 119e8d8bef9SDimitry Andric priority_queue(const Compare& x, Container&&); // C++20 1200b57cec5SDimitry Andric template <class InputIterator> 1210b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 1220b57cec5SDimitry Andric const Compare& comp = Compare()); 1230b57cec5SDimitry Andric template <class InputIterator> 1240b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 125*349cc55cSDimitry Andric const Compare& comp, const Container& c); 1260b57cec5SDimitry Andric template <class InputIterator> 1270b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 128*349cc55cSDimitry Andric const Compare& comp, Container&& c); 1290b57cec5SDimitry Andric template <class Alloc> 1300b57cec5SDimitry Andric explicit priority_queue(const Alloc& a); 1310b57cec5SDimitry Andric template <class Alloc> 1320b57cec5SDimitry Andric priority_queue(const Compare& comp, const Alloc& a); 1330b57cec5SDimitry Andric template <class Alloc> 134*349cc55cSDimitry Andric priority_queue(const Compare& comp, const Container& c, 1350b57cec5SDimitry Andric const Alloc& a); 1360b57cec5SDimitry Andric template <class Alloc> 137*349cc55cSDimitry Andric priority_queue(const Compare& comp, Container&& c, 1380b57cec5SDimitry Andric const Alloc& a); 139*349cc55cSDimitry Andric template <class InputIterator> 140*349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 141*349cc55cSDimitry Andric const Alloc& a); 142*349cc55cSDimitry Andric template <class InputIterator> 143*349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 144*349cc55cSDimitry Andric const Compare& comp, const Alloc& a); 145*349cc55cSDimitry Andric template <class InputIterator> 146*349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 147*349cc55cSDimitry Andric const Compare& comp, const Container& c, const Alloc& a); 148*349cc55cSDimitry Andric template <class InputIterator> 149*349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 150*349cc55cSDimitry Andric const Compare& comp, Container&& c, const Alloc& a); 1510b57cec5SDimitry Andric template <class Alloc> 1520b57cec5SDimitry Andric priority_queue(const priority_queue& q, const Alloc& a); 1530b57cec5SDimitry Andric template <class Alloc> 1540b57cec5SDimitry Andric priority_queue(priority_queue&& q, const Alloc& a); 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric bool empty() const; 1570b57cec5SDimitry Andric size_type size() const; 1580b57cec5SDimitry Andric const_reference top() const; 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric void push(const value_type& v); 1610b57cec5SDimitry Andric void push(value_type&& v); 1620b57cec5SDimitry Andric template <class... Args> void emplace(Args&&... args); 1630b57cec5SDimitry Andric void pop(); 1640b57cec5SDimitry Andric 1650b57cec5SDimitry Andric void swap(priority_queue& q) 1660b57cec5SDimitry Andric noexcept(is_nothrow_swappable_v<Container> && 1670b57cec5SDimitry Andric is_nothrow_swappable_v<Comp>) 1680b57cec5SDimitry Andric}; 1690b57cec5SDimitry Andric 1700b57cec5SDimitry Andrictemplate <class Compare, class Container> 1710b57cec5SDimitry Andricpriority_queue(Compare, Container) 1720b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andrictemplate<class InputIterator, 175*349cc55cSDimitry Andric class Compare = less<iter-value-type<InputIterator>>, 176*349cc55cSDimitry Andric class Container = vector<iter-value-type<InputIterator>>> 1770b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) 178*349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 1790b57cec5SDimitry Andric 1800b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator> 1810b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator) 1820b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1830b57cec5SDimitry Andric 184*349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 185*349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator) 186*349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 187*349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, 188*349cc55cSDimitry Andric less<iter-value-type<InputIterator>>>; // C++17 189*349cc55cSDimitry Andric 190*349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator> 191*349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator) 192*349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 193*349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 194*349cc55cSDimitry Andric 195*349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator> 196*349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator) 197*349cc55cSDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 198*349cc55cSDimitry Andric 1990b57cec5SDimitry Andrictemplate <class T, class Container, class Compare> 2000b57cec5SDimitry Andric void swap(priority_queue<T, Container, Compare>& x, 2010b57cec5SDimitry Andric priority_queue<T, Container, Compare>& y) 2020b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andric} // std 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andric*/ 2070b57cec5SDimitry Andric 2080b57cec5SDimitry Andric#include <__config> 209fe6060f1SDimitry Andric#include <__memory/uses_allocator.h> 210fe6060f1SDimitry Andric#include <__utility/forward.h> 2110b57cec5SDimitry Andric#include <algorithm> 212fe6060f1SDimitry Andric#include <compare> 213fe6060f1SDimitry Andric#include <deque> 214fe6060f1SDimitry Andric#include <functional> 215fe6060f1SDimitry Andric#include <vector> 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2180b57cec5SDimitry Andric#pragma GCC system_header 2190b57cec5SDimitry Andric#endif 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2240b57cec5SDimitry Andric 2250b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 2260b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 2270b57cec5SDimitry Andricbool 2280b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 2310b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 2320b57cec5SDimitry Andricbool 2330b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2340b57cec5SDimitry Andric 2350b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 2360b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue 2370b57cec5SDimitry Andric{ 2380b57cec5SDimitry Andricpublic: 2390b57cec5SDimitry Andric typedef _Container container_type; 2400b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 2410b57cec5SDimitry Andric typedef typename container_type::reference reference; 2420b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 2430b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 2440b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 2450b57cec5SDimitry Andric 2460b57cec5SDimitry Andricprotected: 2470b57cec5SDimitry Andric container_type c; 2480b57cec5SDimitry Andric 2490b57cec5SDimitry Andricpublic: 2500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2510b57cec5SDimitry Andric queue() 2520b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2530b57cec5SDimitry Andric : c() {} 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2560b57cec5SDimitry Andric queue(const queue& __q) : c(__q.c) {} 2570b57cec5SDimitry Andric 2580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2590b57cec5SDimitry Andric queue& operator=(const queue& __q) {c = __q.c; return *this;} 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2620b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2630b57cec5SDimitry Andric queue(queue&& __q) 2640b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 2650b57cec5SDimitry Andric : c(_VSTD::move(__q.c)) {} 2660b57cec5SDimitry Andric 2670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2680b57cec5SDimitry Andric queue& operator=(queue&& __q) 2690b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 2700b57cec5SDimitry Andric {c = _VSTD::move(__q.c); return *this;} 2710b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2720b57cec5SDimitry Andric 2730b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2740b57cec5SDimitry Andric explicit queue(const container_type& __c) : c(__c) {} 2750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2760b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2770b57cec5SDimitry Andric explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 2780b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2790b57cec5SDimitry Andric template <class _Alloc> 2800b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2810b57cec5SDimitry Andric explicit queue(const _Alloc& __a, 282*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2830b57cec5SDimitry Andric : c(__a) {} 2840b57cec5SDimitry Andric template <class _Alloc> 2850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2860b57cec5SDimitry Andric queue(const queue& __q, const _Alloc& __a, 287*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2880b57cec5SDimitry Andric : c(__q.c, __a) {} 2890b57cec5SDimitry Andric template <class _Alloc> 2900b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2910b57cec5SDimitry Andric queue(const container_type& __c, const _Alloc& __a, 292*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2930b57cec5SDimitry Andric : c(__c, __a) {} 2940b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2950b57cec5SDimitry Andric template <class _Alloc> 2960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2970b57cec5SDimitry Andric queue(container_type&& __c, const _Alloc& __a, 298*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 2990b57cec5SDimitry Andric : c(_VSTD::move(__c), __a) {} 3000b57cec5SDimitry Andric template <class _Alloc> 3010b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3020b57cec5SDimitry Andric queue(queue&& __q, const _Alloc& __a, 303*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3040b57cec5SDimitry Andric : c(_VSTD::move(__q.c), __a) {} 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3070b57cec5SDimitry Andric 3080b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3090b57cec5SDimitry Andric bool empty() const {return c.empty();} 3100b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3110b57cec5SDimitry Andric size_type size() const {return c.size();} 3120b57cec5SDimitry Andric 3130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3140b57cec5SDimitry Andric reference front() {return c.front();} 3150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3160b57cec5SDimitry Andric const_reference front() const {return c.front();} 3170b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3180b57cec5SDimitry Andric reference back() {return c.back();} 3190b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3200b57cec5SDimitry Andric const_reference back() const {return c.back();} 3210b57cec5SDimitry Andric 3220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3230b57cec5SDimitry Andric void push(const value_type& __v) {c.push_back(__v);} 3240b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3250b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3260b57cec5SDimitry Andric void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3270b57cec5SDimitry Andric template <class... _Args> 3280b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3290b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 3300b57cec5SDimitry Andric decltype(auto) emplace(_Args&&... __args) 3310b57cec5SDimitry Andric { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 3320b57cec5SDimitry Andric#else 3330b57cec5SDimitry Andric void emplace(_Args&&... __args) 3340b57cec5SDimitry Andric { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 3350b57cec5SDimitry Andric#endif 3360b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3370b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3380b57cec5SDimitry Andric void pop() {c.pop_front();} 3390b57cec5SDimitry Andric 3400b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3410b57cec5SDimitry Andric void swap(queue& __q) 3420b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3430b57cec5SDimitry Andric { 3440b57cec5SDimitry Andric using _VSTD::swap; 3450b57cec5SDimitry Andric swap(c, __q.c); 3460b57cec5SDimitry Andric } 3470b57cec5SDimitry Andric 3480b57cec5SDimitry Andric template <class _T1, class _C1> 3490b57cec5SDimitry Andric friend 3500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3510b57cec5SDimitry Andric bool 3520b57cec5SDimitry Andric operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andric template <class _T1, class _C1> 3550b57cec5SDimitry Andric friend 3560b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3570b57cec5SDimitry Andric bool 3580b57cec5SDimitry Andric operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3590b57cec5SDimitry Andric}; 3600b57cec5SDimitry Andric 361*349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 3620b57cec5SDimitry Andrictemplate<class _Container, 363*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 3640b57cec5SDimitry Andric> 3650b57cec5SDimitry Andricqueue(_Container) 3660b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 3670b57cec5SDimitry Andric 3680b57cec5SDimitry Andrictemplate<class _Container, 3690b57cec5SDimitry Andric class _Alloc, 370*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 371*349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 3720b57cec5SDimitry Andric> 3730b57cec5SDimitry Andricqueue(_Container, _Alloc) 3740b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 3750b57cec5SDimitry Andric#endif 3760b57cec5SDimitry Andric 3770b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3780b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3790b57cec5SDimitry Andricbool 3800b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3810b57cec5SDimitry Andric{ 3820b57cec5SDimitry Andric return __x.c == __y.c; 3830b57cec5SDimitry Andric} 3840b57cec5SDimitry Andric 3850b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3860b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3870b57cec5SDimitry Andricbool 3880b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3890b57cec5SDimitry Andric{ 3900b57cec5SDimitry Andric return __x.c < __y.c; 3910b57cec5SDimitry Andric} 3920b57cec5SDimitry Andric 3930b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 3940b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 3950b57cec5SDimitry Andricbool 3960b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3970b57cec5SDimitry Andric{ 3980b57cec5SDimitry Andric return !(__x == __y); 3990b57cec5SDimitry Andric} 4000b57cec5SDimitry Andric 4010b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4020b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4030b57cec5SDimitry Andricbool 4040b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4050b57cec5SDimitry Andric{ 4060b57cec5SDimitry Andric return __y < __x; 4070b57cec5SDimitry Andric} 4080b57cec5SDimitry Andric 4090b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4100b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4110b57cec5SDimitry Andricbool 4120b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4130b57cec5SDimitry Andric{ 4140b57cec5SDimitry Andric return !(__x < __y); 4150b57cec5SDimitry Andric} 4160b57cec5SDimitry Andric 4170b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4180b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4190b57cec5SDimitry Andricbool 4200b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4210b57cec5SDimitry Andric{ 4220b57cec5SDimitry Andric return !(__y < __x); 4230b57cec5SDimitry Andric} 4240b57cec5SDimitry Andric 4250b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 4260b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 427*349cc55cSDimitry Andric__enable_if_t<__is_swappable<_Container>::value, void> 4280b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4290b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4300b57cec5SDimitry Andric{ 4310b57cec5SDimitry Andric __x.swap(__y); 4320b57cec5SDimitry Andric} 4330b57cec5SDimitry Andric 4340b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 4350b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4360b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 4370b57cec5SDimitry Andric{ 4380b57cec5SDimitry Andric}; 4390b57cec5SDimitry Andric 4400b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, 4410b57cec5SDimitry Andric class _Compare = less<typename _Container::value_type> > 4420b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue 4430b57cec5SDimitry Andric{ 4440b57cec5SDimitry Andricpublic: 4450b57cec5SDimitry Andric typedef _Container container_type; 4460b57cec5SDimitry Andric typedef _Compare value_compare; 4470b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 4480b57cec5SDimitry Andric typedef typename container_type::reference reference; 4490b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 4500b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 4510b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 4520b57cec5SDimitry Andric 4530b57cec5SDimitry Andricprotected: 4540b57cec5SDimitry Andric container_type c; 4550b57cec5SDimitry Andric value_compare comp; 4560b57cec5SDimitry Andric 4570b57cec5SDimitry Andricpublic: 4580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4590b57cec5SDimitry Andric priority_queue() 4600b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 4610b57cec5SDimitry Andric is_nothrow_default_constructible<value_compare>::value) 4620b57cec5SDimitry Andric : c(), comp() {} 4630b57cec5SDimitry Andric 4640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4650b57cec5SDimitry Andric priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 4660b57cec5SDimitry Andric 4670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4680b57cec5SDimitry Andric priority_queue& operator=(const priority_queue& __q) 4690b57cec5SDimitry Andric {c = __q.c; comp = __q.comp; return *this;} 4700b57cec5SDimitry Andric 4710b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 4720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4730b57cec5SDimitry Andric priority_queue(priority_queue&& __q) 4740b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 4750b57cec5SDimitry Andric is_nothrow_move_constructible<value_compare>::value) 4760b57cec5SDimitry Andric : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 4770b57cec5SDimitry Andric 4780b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4790b57cec5SDimitry Andric priority_queue& operator=(priority_queue&& __q) 4800b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 4810b57cec5SDimitry Andric is_nothrow_move_assignable<value_compare>::value) 4820b57cec5SDimitry Andric {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 4830b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 4840b57cec5SDimitry Andric 4850b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4860b57cec5SDimitry Andric explicit priority_queue(const value_compare& __comp) 4870b57cec5SDimitry Andric : c(), comp(__comp) {} 4880b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4890b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c); 4900b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 4910b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 492e8d8bef9SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c); 4930b57cec5SDimitry Andric#endif 494*349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 4950b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4960b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 4970b57cec5SDimitry Andric const value_compare& __comp = value_compare()); 498*349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 4990b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5000b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 5010b57cec5SDimitry Andric const value_compare& __comp, const container_type& __c); 5020b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 503*349cc55cSDimitry Andric template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 5040b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5050b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 5060b57cec5SDimitry Andric const value_compare& __comp, container_type&& __c); 5070b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5080b57cec5SDimitry Andric template <class _Alloc> 5090b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5100b57cec5SDimitry Andric explicit priority_queue(const _Alloc& __a, 511*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5120b57cec5SDimitry Andric template <class _Alloc> 5130b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5140b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const _Alloc& __a, 515*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5160b57cec5SDimitry Andric template <class _Alloc> 5170b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5180b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c, 5190b57cec5SDimitry Andric const _Alloc& __a, 520*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5210b57cec5SDimitry Andric template <class _Alloc> 5220b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5230b57cec5SDimitry Andric priority_queue(const priority_queue& __q, const _Alloc& __a, 524*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5250b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5260b57cec5SDimitry Andric template <class _Alloc> 5270b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5280b57cec5SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c, 5290b57cec5SDimitry Andric const _Alloc& __a, 530*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5310b57cec5SDimitry Andric template <class _Alloc> 5320b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5330b57cec5SDimitry Andric priority_queue(priority_queue&& __q, const _Alloc& __a, 534*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 535*349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 536*349cc55cSDimitry Andric 537*349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 538*349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 539*349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 540*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 541*349cc55cSDimitry Andric 542*349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 543*349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 544*349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 545*349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 546*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 547*349cc55cSDimitry Andric 548*349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 549*349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 550*349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 551*349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 552*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 553*349cc55cSDimitry Andric 554*349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 555*349cc55cSDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > 556*349cc55cSDimitry Andric _LIBCPP_INLINE_VISIBILITY 557*349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 558*349cc55cSDimitry Andric const value_compare& __comp, container_type&& __c, const _Alloc& __a, 559*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5600b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5610b57cec5SDimitry Andric 5620b57cec5SDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 5630b57cec5SDimitry Andric bool empty() const {return c.empty();} 5640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5650b57cec5SDimitry Andric size_type size() const {return c.size();} 5660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5670b57cec5SDimitry Andric const_reference top() const {return c.front();} 5680b57cec5SDimitry Andric 5690b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5700b57cec5SDimitry Andric void push(const value_type& __v); 5710b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 5720b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5730b57cec5SDimitry Andric void push(value_type&& __v); 5740b57cec5SDimitry Andric template <class... _Args> 5750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5760b57cec5SDimitry Andric void emplace(_Args&&... __args); 5770b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5780b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5790b57cec5SDimitry Andric void pop(); 5800b57cec5SDimitry Andric 5810b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 5820b57cec5SDimitry Andric void swap(priority_queue& __q) 5830b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 5840b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value); 5850b57cec5SDimitry Andric}; 5860b57cec5SDimitry Andric 587*349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 5880b57cec5SDimitry Andrictemplate <class _Compare, 5890b57cec5SDimitry Andric class _Container, 590*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 591*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 5920b57cec5SDimitry Andric> 5930b57cec5SDimitry Andricpriority_queue(_Compare, _Container) 5940b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 5950b57cec5SDimitry Andric 5960b57cec5SDimitry Andrictemplate<class _InputIterator, 597fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 598fe6060f1SDimitry Andric class _Container = vector<__iter_value_type<_InputIterator>>, 599*349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 600*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 601*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 6020b57cec5SDimitry Andric> 6030b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 604fe6060f1SDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6050b57cec5SDimitry Andric 6060b57cec5SDimitry Andrictemplate<class _Compare, 6070b57cec5SDimitry Andric class _Container, 6080b57cec5SDimitry Andric class _Alloc, 609*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 610*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 611*349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6120b57cec5SDimitry Andric> 6130b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc) 6140b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 615*349cc55cSDimitry Andric 616*349cc55cSDimitry Andrictemplate<class _InputIterator, class _Allocator, 617*349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 618*349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 619*349cc55cSDimitry Andric> 620*349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator) 621*349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 622*349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 623*349cc55cSDimitry Andric less<__iter_value_type<_InputIterator>>>; 624*349cc55cSDimitry Andric 625*349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Allocator, 626*349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 627*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 628*349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 629*349cc55cSDimitry Andric> 630*349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 631*349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 632*349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 633*349cc55cSDimitry Andric 634*349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 635*349cc55cSDimitry Andric class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 636*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 637*349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 638*349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 639*349cc55cSDimitry Andric> 640*349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 641*349cc55cSDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6420b57cec5SDimitry Andric#endif 6430b57cec5SDimitry Andric 6440b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 6450b57cec5SDimitry Andricinline 6460b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6470b57cec5SDimitry Andric const container_type& __c) 6480b57cec5SDimitry Andric : c(__c), 6490b57cec5SDimitry Andric comp(__comp) 6500b57cec5SDimitry Andric{ 6510b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 6520b57cec5SDimitry Andric} 6530b57cec5SDimitry Andric 6540b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6550b57cec5SDimitry Andric 6560b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 6570b57cec5SDimitry Andricinline 6580b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 6590b57cec5SDimitry Andric container_type&& __c) 6600b57cec5SDimitry Andric : c(_VSTD::move(__c)), 6610b57cec5SDimitry Andric comp(__comp) 6620b57cec5SDimitry Andric{ 6630b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 6640b57cec5SDimitry Andric} 6650b57cec5SDimitry Andric 6660b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6670b57cec5SDimitry Andric 6680b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 669*349cc55cSDimitry Andrictemplate <class _InputIter, class> 6700b57cec5SDimitry Andricinline 6710b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6720b57cec5SDimitry Andric const value_compare& __comp) 6730b57cec5SDimitry Andric : c(__f, __l), 6740b57cec5SDimitry Andric comp(__comp) 6750b57cec5SDimitry Andric{ 6760b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 6770b57cec5SDimitry Andric} 6780b57cec5SDimitry Andric 6790b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 680*349cc55cSDimitry Andrictemplate <class _InputIter, class> 6810b57cec5SDimitry Andricinline 6820b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6830b57cec5SDimitry Andric const value_compare& __comp, 6840b57cec5SDimitry Andric const container_type& __c) 6850b57cec5SDimitry Andric : c(__c), 6860b57cec5SDimitry Andric comp(__comp) 6870b57cec5SDimitry Andric{ 6880b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 6890b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 6900b57cec5SDimitry Andric} 6910b57cec5SDimitry Andric 6920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6930b57cec5SDimitry Andric 6940b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 695*349cc55cSDimitry Andrictemplate <class _InputIter, class> 6960b57cec5SDimitry Andricinline 6970b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6980b57cec5SDimitry Andric const value_compare& __comp, 6990b57cec5SDimitry Andric container_type&& __c) 7000b57cec5SDimitry Andric : c(_VSTD::move(__c)), 7010b57cec5SDimitry Andric comp(__comp) 7020b57cec5SDimitry Andric{ 7030b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 7040b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7050b57cec5SDimitry Andric} 7060b57cec5SDimitry Andric 7070b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7080b57cec5SDimitry Andric 7090b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7100b57cec5SDimitry Andrictemplate <class _Alloc> 7110b57cec5SDimitry Andricinline 7120b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 713*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7140b57cec5SDimitry Andric : c(__a) 7150b57cec5SDimitry Andric{ 7160b57cec5SDimitry Andric} 7170b57cec5SDimitry Andric 7180b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7190b57cec5SDimitry Andrictemplate <class _Alloc> 7200b57cec5SDimitry Andricinline 7210b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7220b57cec5SDimitry Andric const _Alloc& __a, 723*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7240b57cec5SDimitry Andric : c(__a), 7250b57cec5SDimitry Andric comp(__comp) 7260b57cec5SDimitry Andric{ 7270b57cec5SDimitry Andric} 7280b57cec5SDimitry Andric 7290b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7300b57cec5SDimitry Andrictemplate <class _Alloc> 7310b57cec5SDimitry Andricinline 7320b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7330b57cec5SDimitry Andric const container_type& __c, 7340b57cec5SDimitry Andric const _Alloc& __a, 735*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7360b57cec5SDimitry Andric : c(__c, __a), 7370b57cec5SDimitry Andric comp(__comp) 7380b57cec5SDimitry Andric{ 7390b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7400b57cec5SDimitry Andric} 7410b57cec5SDimitry Andric 7420b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7430b57cec5SDimitry Andrictemplate <class _Alloc> 7440b57cec5SDimitry Andricinline 7450b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7460b57cec5SDimitry Andric const _Alloc& __a, 747*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7480b57cec5SDimitry Andric : c(__q.c, __a), 7490b57cec5SDimitry Andric comp(__q.comp) 7500b57cec5SDimitry Andric{ 7510b57cec5SDimitry Andric} 7520b57cec5SDimitry Andric 7530b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7540b57cec5SDimitry Andric 7550b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7560b57cec5SDimitry Andrictemplate <class _Alloc> 7570b57cec5SDimitry Andricinline 7580b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7590b57cec5SDimitry Andric container_type&& __c, 7600b57cec5SDimitry Andric const _Alloc& __a, 761*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7620b57cec5SDimitry Andric : c(_VSTD::move(__c), __a), 7630b57cec5SDimitry Andric comp(__comp) 7640b57cec5SDimitry Andric{ 7650b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7660b57cec5SDimitry Andric} 7670b57cec5SDimitry Andric 7680b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 7690b57cec5SDimitry Andrictemplate <class _Alloc> 7700b57cec5SDimitry Andricinline 7710b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 7720b57cec5SDimitry Andric const _Alloc& __a, 773*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 7740b57cec5SDimitry Andric : c(_VSTD::move(__q.c), __a), 7750b57cec5SDimitry Andric comp(_VSTD::move(__q.comp)) 7760b57cec5SDimitry Andric{ 777*349cc55cSDimitry Andric} 778*349cc55cSDimitry Andric 779*349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 780*349cc55cSDimitry Andric 781*349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 782*349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 783*349cc55cSDimitry Andricinline 784*349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 785*349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const _Alloc& __a, 786*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 787*349cc55cSDimitry Andric : c(__f, __l, __a), 788*349cc55cSDimitry Andric comp() 789*349cc55cSDimitry Andric{ 7900b57cec5SDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 7910b57cec5SDimitry Andric} 7920b57cec5SDimitry Andric 793*349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 794*349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 795*349cc55cSDimitry Andricinline 796*349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 797*349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 798*349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 799*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 800*349cc55cSDimitry Andric : c(__f, __l, __a), 801*349cc55cSDimitry Andric comp(__comp) 802*349cc55cSDimitry Andric{ 803*349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 804*349cc55cSDimitry Andric} 805*349cc55cSDimitry Andric 806*349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 807*349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 808*349cc55cSDimitry Andricinline 809*349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 810*349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 811*349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 812*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 813*349cc55cSDimitry Andric : c(__c, __a), 814*349cc55cSDimitry Andric comp(__comp) 815*349cc55cSDimitry Andric{ 816*349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 817*349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 818*349cc55cSDimitry Andric} 819*349cc55cSDimitry Andric 820*349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 821*349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 822*349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 823*349cc55cSDimitry Andricinline 824*349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 825*349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, 826*349cc55cSDimitry Andric container_type&& __c, const _Alloc& __a, 827*349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 828*349cc55cSDimitry Andric : c(_VSTD::move(__c), __a), 829*349cc55cSDimitry Andric comp(__comp) 830*349cc55cSDimitry Andric{ 831*349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 832*349cc55cSDimitry Andric _VSTD::make_heap(c.begin(), c.end(), comp); 833*349cc55cSDimitry Andric} 8340b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8350b57cec5SDimitry Andric 8360b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8370b57cec5SDimitry Andricinline 8380b57cec5SDimitry Andricvoid 8390b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8400b57cec5SDimitry Andric{ 8410b57cec5SDimitry Andric c.push_back(__v); 8420b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 8430b57cec5SDimitry Andric} 8440b57cec5SDimitry Andric 8450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8460b57cec5SDimitry Andric 8470b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8480b57cec5SDimitry Andricinline 8490b57cec5SDimitry Andricvoid 8500b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 8510b57cec5SDimitry Andric{ 8520b57cec5SDimitry Andric c.push_back(_VSTD::move(__v)); 8530b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 8540b57cec5SDimitry Andric} 8550b57cec5SDimitry Andric 8560b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8570b57cec5SDimitry Andrictemplate <class... _Args> 8580b57cec5SDimitry Andricinline 8590b57cec5SDimitry Andricvoid 8600b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 8610b57cec5SDimitry Andric{ 8620b57cec5SDimitry Andric c.emplace_back(_VSTD::forward<_Args>(__args)...); 8630b57cec5SDimitry Andric _VSTD::push_heap(c.begin(), c.end(), comp); 8640b57cec5SDimitry Andric} 8650b57cec5SDimitry Andric 8660b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8670b57cec5SDimitry Andric 8680b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8690b57cec5SDimitry Andricinline 8700b57cec5SDimitry Andricvoid 8710b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop() 8720b57cec5SDimitry Andric{ 8730b57cec5SDimitry Andric _VSTD::pop_heap(c.begin(), c.end(), comp); 8740b57cec5SDimitry Andric c.pop_back(); 8750b57cec5SDimitry Andric} 8760b57cec5SDimitry Andric 8770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8780b57cec5SDimitry Andricinline 8790b57cec5SDimitry Andricvoid 8800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 8810b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 8820b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value) 8830b57cec5SDimitry Andric{ 8840b57cec5SDimitry Andric using _VSTD::swap; 8850b57cec5SDimitry Andric swap(c, __q.c); 8860b57cec5SDimitry Andric swap(comp, __q.comp); 8870b57cec5SDimitry Andric} 8880b57cec5SDimitry Andric 8890b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8900b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 891*349cc55cSDimitry Andric__enable_if_t< 892fe6060f1SDimitry Andric __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 8930b57cec5SDimitry Andric void 894fe6060f1SDimitry Andric> 8950b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, 8960b57cec5SDimitry Andric priority_queue<_Tp, _Container, _Compare>& __y) 8970b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 8980b57cec5SDimitry Andric{ 8990b57cec5SDimitry Andric __x.swap(__y); 9000b57cec5SDimitry Andric} 9010b57cec5SDimitry Andric 9020b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc> 9030b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9040b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 9050b57cec5SDimitry Andric{ 9060b57cec5SDimitry Andric}; 9070b57cec5SDimitry Andric 9080b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 9090b57cec5SDimitry Andric 9100b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE 911