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 4606c3fb27SDimitry Andric template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23 470b57cec5SDimitry Andric template <class Alloc> 480b57cec5SDimitry Andric explicit queue(const Alloc& a); 490b57cec5SDimitry Andric template <class Alloc> 500b57cec5SDimitry Andric queue(const container_type& c, const Alloc& a); 510b57cec5SDimitry Andric template <class Alloc> 520b57cec5SDimitry Andric queue(container_type&& c, const Alloc& a); 530b57cec5SDimitry Andric template <class Alloc> 540b57cec5SDimitry Andric queue(const queue& q, const Alloc& a); 550b57cec5SDimitry Andric template <class Alloc> 560b57cec5SDimitry Andric queue(queue&& q, const Alloc& a); 5704eeddc0SDimitry Andric template <class InputIterator, class Alloc> 5804eeddc0SDimitry Andric queue(InputIterator first, InputIterator last, const Alloc&); // since C++23 5906c3fb27SDimitry Andric template<container-compatible-range<T> R, class Alloc> 6006c3fb27SDimitry Andric queue(from_range_t, R&& rg, const Alloc&); // since C++23 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric bool empty() const; 630b57cec5SDimitry Andric size_type size() const; 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric reference front(); 660b57cec5SDimitry Andric const_reference front() const; 670b57cec5SDimitry Andric reference back(); 680b57cec5SDimitry Andric const_reference back() const; 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric void push(const value_type& v); 710b57cec5SDimitry Andric void push(value_type&& v); 7206c3fb27SDimitry Andric template<container-compatible-range<T> R> 7306c3fb27SDimitry Andric void push_range(R&& rg); // C++23 740b57cec5SDimitry Andric template <class... Args> reference emplace(Args&&... args); // reference in C++17 750b57cec5SDimitry Andric void pop(); 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) 780b57cec5SDimitry Andric}; 790b57cec5SDimitry Andric 800b57cec5SDimitry Andrictemplate<class Container> 810b57cec5SDimitry Andric queue(Container) -> queue<typename Container::value_type, Container>; // C++17 820b57cec5SDimitry Andric 8304eeddc0SDimitry Andrictemplate<class InputIterator> 8404eeddc0SDimitry Andric queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 8504eeddc0SDimitry Andric 8606c3fb27SDimitry Andrictemplate<ranges::input_range R> 8706c3fb27SDimitry Andric queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23 8806c3fb27SDimitry Andric 890b57cec5SDimitry Andrictemplate<class Container, class Allocator> 900b57cec5SDimitry Andric queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 910b57cec5SDimitry Andric 9204eeddc0SDimitry Andrictemplate<class InputIterator, class Allocator> 9304eeddc0SDimitry Andric queue(InputIterator, InputIterator, Allocator) 9404eeddc0SDimitry Andric -> queue<iter-value-type<InputIterator>, 9504eeddc0SDimitry Andric deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 9604eeddc0SDimitry Andric 9706c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 9806c3fb27SDimitry Andric queue(from_range_t, R&&, Allocator) 9906c3fb27SDimitry Andric -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23 10006c3fb27SDimitry 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 bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andrictemplate <class T, class Container> 1110b57cec5SDimitry Andric bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); 1120b57cec5SDimitry Andric 1130b57cec5SDimitry Andrictemplate <class T, class Container> 1140b57cec5SDimitry Andric bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andrictemplate <class T, class Container> 1170b57cec5SDimitry Andric bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); 1180b57cec5SDimitry Andric 11906c3fb27SDimitry Andrictemplate<class T, three_way_comparable Container> 12006c3fb27SDimitry Andric compare_three_way_result_t<Container> 12106c3fb27SDimitry Andric operator<=>(const queue<T, Container>& x, const queue<T, Container>& y); // since C++20 12206c3fb27SDimitry Andric 1230b57cec5SDimitry Andrictemplate <class T, class Container> 1240b57cec5SDimitry Andric void swap(queue<T, Container>& x, queue<T, Container>& y) 1250b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andrictemplate <class T, class Container = vector<T>, 1280b57cec5SDimitry Andric class Compare = less<typename Container::value_type>> 1290b57cec5SDimitry Andricclass priority_queue 1300b57cec5SDimitry Andric{ 1310b57cec5SDimitry Andricpublic: 1320b57cec5SDimitry Andric typedef Container container_type; 1330b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 1340b57cec5SDimitry Andric typedef typename container_type::reference reference; 1350b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 1360b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 1370b57cec5SDimitry Andric 1380b57cec5SDimitry Andricprotected: 1390b57cec5SDimitry Andric container_type c; 1400b57cec5SDimitry Andric Compare comp; 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andricpublic: 143e8d8bef9SDimitry Andric priority_queue() : priority_queue(Compare()) {} // C++20 144e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} 145e8d8bef9SDimitry Andric priority_queue(const Compare& x, const Container&); 146e8d8bef9SDimitry Andric explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 147e8d8bef9SDimitry Andric priority_queue(const Compare& x, Container&&); // C++20 1480b57cec5SDimitry Andric template <class InputIterator> 1490b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 1500b57cec5SDimitry Andric const Compare& comp = Compare()); 1510b57cec5SDimitry Andric template <class InputIterator> 1520b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 153349cc55cSDimitry Andric const Compare& comp, const Container& c); 1540b57cec5SDimitry Andric template <class InputIterator> 1550b57cec5SDimitry Andric priority_queue(InputIterator first, InputIterator last, 156349cc55cSDimitry Andric const Compare& comp, Container&& c); 15706c3fb27SDimitry Andric template <container-compatible-range<T> R> 15806c3fb27SDimitry Andric priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23 1590b57cec5SDimitry Andric template <class Alloc> 1600b57cec5SDimitry Andric explicit priority_queue(const Alloc& a); 1610b57cec5SDimitry Andric template <class Alloc> 1620b57cec5SDimitry Andric priority_queue(const Compare& comp, const Alloc& a); 1630b57cec5SDimitry Andric template <class Alloc> 164349cc55cSDimitry Andric priority_queue(const Compare& comp, const Container& c, 1650b57cec5SDimitry Andric const Alloc& a); 1660b57cec5SDimitry Andric template <class Alloc> 167349cc55cSDimitry Andric priority_queue(const Compare& comp, Container&& c, 1680b57cec5SDimitry Andric const Alloc& a); 169349cc55cSDimitry Andric template <class InputIterator> 170349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 171349cc55cSDimitry Andric const Alloc& a); 172349cc55cSDimitry Andric template <class InputIterator> 173349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 174349cc55cSDimitry Andric const Compare& comp, const Alloc& a); 175349cc55cSDimitry Andric template <class InputIterator> 176349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 177349cc55cSDimitry Andric const Compare& comp, const Container& c, const Alloc& a); 178349cc55cSDimitry Andric template <class InputIterator> 179349cc55cSDimitry Andric priority_queue(InputIterator first, InputIterator last, 180349cc55cSDimitry Andric const Compare& comp, Container&& c, const Alloc& a); 18106c3fb27SDimitry Andric template <container-compatible-range<T> R, class Alloc> 18206c3fb27SDimitry Andric priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23 18306c3fb27SDimitry Andric template <container-compatible-range<T> R, class Alloc> 18406c3fb27SDimitry Andric priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23 1850b57cec5SDimitry Andric template <class Alloc> 1860b57cec5SDimitry Andric priority_queue(const priority_queue& q, const Alloc& a); 1870b57cec5SDimitry Andric template <class Alloc> 1880b57cec5SDimitry Andric priority_queue(priority_queue&& q, const Alloc& a); 1890b57cec5SDimitry Andric 1900b57cec5SDimitry Andric bool empty() const; 1910b57cec5SDimitry Andric size_type size() const; 1920b57cec5SDimitry Andric const_reference top() const; 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric void push(const value_type& v); 1950b57cec5SDimitry Andric void push(value_type&& v); 19606c3fb27SDimitry Andric template<container-compatible-range<T> R> 19706c3fb27SDimitry Andric void push_range(R&& rg); // C++23 1980b57cec5SDimitry Andric template <class... Args> void emplace(Args&&... args); 1990b57cec5SDimitry Andric void pop(); 2000b57cec5SDimitry Andric 2010b57cec5SDimitry Andric void swap(priority_queue& q) 2020b57cec5SDimitry Andric noexcept(is_nothrow_swappable_v<Container> && 2030b57cec5SDimitry Andric is_nothrow_swappable_v<Comp>) 2040b57cec5SDimitry Andric}; 2050b57cec5SDimitry Andric 2060b57cec5SDimitry Andrictemplate <class Compare, class Container> 2070b57cec5SDimitry Andricpriority_queue(Compare, Container) 2080b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andrictemplate<class InputIterator, 211349cc55cSDimitry Andric class Compare = less<iter-value-type<InputIterator>>, 212349cc55cSDimitry Andric class Container = vector<iter-value-type<InputIterator>>> 2130b57cec5SDimitry Andricpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) 214349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 2150b57cec5SDimitry Andric 21606c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>> 21706c3fb27SDimitry Andric priority_queue(from_range_t, R&&, Compare = Compare()) 21806c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23 21906c3fb27SDimitry Andric 2200b57cec5SDimitry Andrictemplate<class Compare, class Container, class Allocator> 2210b57cec5SDimitry Andricpriority_queue(Compare, Container, Allocator) 2220b57cec5SDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 2230b57cec5SDimitry Andric 224349cc55cSDimitry Andrictemplate<class InputIterator, class Allocator> 225349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Allocator) 226349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 227349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, 228349cc55cSDimitry Andric less<iter-value-type<InputIterator>>>; // C++17 229349cc55cSDimitry Andric 230349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Allocator> 231349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Allocator) 232349cc55cSDimitry Andric -> priority_queue<iter-value-type<InputIterator>, 233349cc55cSDimitry Andric vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 234349cc55cSDimitry Andric 235349cc55cSDimitry Andrictemplate<class InputIterator, class Compare, class Container, class Allocator> 236349cc55cSDimitry Andricpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator) 237349cc55cSDimitry Andric -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 238349cc55cSDimitry Andric 23906c3fb27SDimitry Andrictemplate<ranges::input_range R, class Compare, class Allocator> 24006c3fb27SDimitry Andric priority_queue(from_range_t, R&&, Compare, Allocator) 24106c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>, 24206c3fb27SDimitry Andric Compare>; // C++23 24306c3fb27SDimitry Andric 24406c3fb27SDimitry Andrictemplate<ranges::input_range R, class Allocator> 24506c3fb27SDimitry Andric priority_queue(from_range_t, R&&, Allocator) 24606c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23 24706c3fb27SDimitry Andric 2480b57cec5SDimitry Andrictemplate <class T, class Container, class Compare> 2490b57cec5SDimitry Andric void swap(priority_queue<T, Container, Compare>& x, 2500b57cec5SDimitry Andric priority_queue<T, Container, Compare>& y) 2510b57cec5SDimitry Andric noexcept(noexcept(x.swap(y))); 2520b57cec5SDimitry Andric 2530b57cec5SDimitry Andric} // std 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andric*/ 2560b57cec5SDimitry Andric 25781ad6265SDimitry Andric#include <__algorithm/make_heap.h> 25881ad6265SDimitry Andric#include <__algorithm/pop_heap.h> 25981ad6265SDimitry Andric#include <__algorithm/push_heap.h> 26006c3fb27SDimitry Andric#include <__algorithm/ranges_copy.h> 26181ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 2620b57cec5SDimitry Andric#include <__config> 26381ad6265SDimitry Andric#include <__functional/operations.h> 26406c3fb27SDimitry Andric#include <__iterator/back_insert_iterator.h> 26504eeddc0SDimitry Andric#include <__iterator/iterator_traits.h> 266fe6060f1SDimitry Andric#include <__memory/uses_allocator.h> 26706c3fb27SDimitry Andric#include <__ranges/access.h> 26806c3fb27SDimitry Andric#include <__ranges/concepts.h> 26906c3fb27SDimitry Andric#include <__ranges/container_compatible_range.h> 27006c3fb27SDimitry Andric#include <__ranges/from_range.h> 271fe6060f1SDimitry Andric#include <__utility/forward.h> 272fe6060f1SDimitry Andric#include <deque> 273fe6060f1SDimitry Andric#include <vector> 27404eeddc0SDimitry Andric#include <version> 2750b57cec5SDimitry Andric 27681ad6265SDimitry Andric// standard-mandated includes 277bdd1243dSDimitry Andric 278bdd1243dSDimitry Andric// [queue.syn] 27981ad6265SDimitry Andric#include <compare> 28081ad6265SDimitry Andric#include <initializer_list> 28181ad6265SDimitry Andric 2820b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2830b57cec5SDimitry Andric# pragma GCC system_header 2840b57cec5SDimitry Andric#endif 2850b57cec5SDimitry Andric 2860b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2870b57cec5SDimitry Andric 2880b57cec5SDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2890b57cec5SDimitry Andric 2900b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 291*5f757f3fSDimitry Andric_LIBCPP_HIDE_FROM_ABI 2920b57cec5SDimitry Andricbool 2930b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2940b57cec5SDimitry Andric 2950b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 296*5f757f3fSDimitry Andric_LIBCPP_HIDE_FROM_ABI 2970b57cec5SDimitry Andricbool 2980b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 3010b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue 3020b57cec5SDimitry Andric{ 3030b57cec5SDimitry Andricpublic: 3040b57cec5SDimitry Andric typedef _Container container_type; 3050b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 3060b57cec5SDimitry Andric typedef typename container_type::reference reference; 3070b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 3080b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 3090b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 3100b57cec5SDimitry Andric 3110b57cec5SDimitry Andricprotected: 3120b57cec5SDimitry Andric container_type c; 3130b57cec5SDimitry Andric 3140b57cec5SDimitry Andricpublic: 315*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3160b57cec5SDimitry Andric queue() 3170b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 3180b57cec5SDimitry Andric : c() {} 3190b57cec5SDimitry Andric 320*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3210b57cec5SDimitry Andric queue(const queue& __q) : c(__q.c) {} 3220b57cec5SDimitry Andric 32306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 32404eeddc0SDimitry Andric template <class _InputIterator, 32506c3fb27SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 32604eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 32704eeddc0SDimitry Andric queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 32804eeddc0SDimitry Andric 32906c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 33006c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 33106c3fb27SDimitry Andric queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {} 33206c3fb27SDimitry Andric 33304eeddc0SDimitry Andric template <class _InputIterator, 33404eeddc0SDimitry Andric class _Alloc, 33506c3fb27SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 33604eeddc0SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 33704eeddc0SDimitry Andric _LIBCPP_HIDE_FROM_ABI 33804eeddc0SDimitry Andric queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} 33906c3fb27SDimitry Andric 34006c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 34106c3fb27SDimitry Andric class _Alloc, 34206c3fb27SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 34306c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 34406c3fb27SDimitry Andric queue(from_range_t, _Range&& __range, const _Alloc& __alloc) 34506c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range), __alloc) {} 34606c3fb27SDimitry Andric 34704eeddc0SDimitry Andric#endif 34804eeddc0SDimitry Andric 349*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3500b57cec5SDimitry Andric queue& operator=(const queue& __q) {c = __q.c; return *this;} 3510b57cec5SDimitry Andric 3520b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 353*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3540b57cec5SDimitry Andric queue(queue&& __q) 3550b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 356*5f757f3fSDimitry Andric : c(std::move(__q.c)) {} 3570b57cec5SDimitry Andric 358*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3590b57cec5SDimitry Andric queue& operator=(queue&& __q) 3600b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 361*5f757f3fSDimitry Andric {c = std::move(__q.c); return *this;} 3620b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3630b57cec5SDimitry Andric 364*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3650b57cec5SDimitry Andric explicit queue(const container_type& __c) : c(__c) {} 3660b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 367*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 368*5f757f3fSDimitry Andric explicit queue(container_type&& __c) : c(std::move(__c)) {} 3690b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3700b57cec5SDimitry Andric template <class _Alloc> 371*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3720b57cec5SDimitry Andric explicit queue(const _Alloc& __a, 373349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3740b57cec5SDimitry Andric : c(__a) {} 3750b57cec5SDimitry Andric template <class _Alloc> 376*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3770b57cec5SDimitry Andric queue(const queue& __q, const _Alloc& __a, 378349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3790b57cec5SDimitry Andric : c(__q.c, __a) {} 3800b57cec5SDimitry Andric template <class _Alloc> 381*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3820b57cec5SDimitry Andric queue(const container_type& __c, const _Alloc& __a, 383349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3840b57cec5SDimitry Andric : c(__c, __a) {} 3850b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3860b57cec5SDimitry Andric template <class _Alloc> 387*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3880b57cec5SDimitry Andric queue(container_type&& __c, const _Alloc& __a, 389349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 390*5f757f3fSDimitry Andric : c(std::move(__c), __a) {} 3910b57cec5SDimitry Andric template <class _Alloc> 392*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 3930b57cec5SDimitry Andric queue(queue&& __q, const _Alloc& __a, 394349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 395*5f757f3fSDimitry Andric : c(std::move(__q.c), __a) {} 3960b57cec5SDimitry Andric 3970b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3980b57cec5SDimitry Andric 399*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 4000b57cec5SDimitry Andric bool empty() const {return c.empty();} 401*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4020b57cec5SDimitry Andric size_type size() const {return c.size();} 4030b57cec5SDimitry Andric 404*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4050b57cec5SDimitry Andric reference front() {return c.front();} 406*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4070b57cec5SDimitry Andric const_reference front() const {return c.front();} 408*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4090b57cec5SDimitry Andric reference back() {return c.back();} 410*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4110b57cec5SDimitry Andric const_reference back() const {return c.back();} 4120b57cec5SDimitry Andric 413*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4140b57cec5SDimitry Andric void push(const value_type& __v) {c.push_back(__v);} 4150b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 416*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 417*5f757f3fSDimitry Andric void push(value_type&& __v) {c.push_back(std::move(__v));} 41806c3fb27SDimitry Andric 41906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 42006c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 42106c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 42206c3fb27SDimitry Andric void push_range(_Range&& __range) { 42306c3fb27SDimitry Andric if constexpr (requires (container_type& __c) { 42406c3fb27SDimitry Andric __c.append_range(std::forward<_Range>(__range)); 42506c3fb27SDimitry Andric }) { 42606c3fb27SDimitry Andric c.append_range(std::forward<_Range>(__range)); 42706c3fb27SDimitry Andric } else { 42806c3fb27SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 42906c3fb27SDimitry Andric } 43006c3fb27SDimitry Andric } 43106c3fb27SDimitry Andric#endif 43206c3fb27SDimitry Andric 4330b57cec5SDimitry Andric template <class... _Args> 434*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 43506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 4360b57cec5SDimitry Andric decltype(auto) emplace(_Args&&... __args) 437*5f757f3fSDimitry Andric { return c.emplace_back(std::forward<_Args>(__args)...);} 4380b57cec5SDimitry Andric#else 4390b57cec5SDimitry Andric void emplace(_Args&&... __args) 440*5f757f3fSDimitry Andric { c.emplace_back(std::forward<_Args>(__args)...);} 4410b57cec5SDimitry Andric#endif 4420b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 443*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4440b57cec5SDimitry Andric void pop() {c.pop_front();} 4450b57cec5SDimitry Andric 446*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4470b57cec5SDimitry Andric void swap(queue& __q) 4480b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 4490b57cec5SDimitry Andric { 450*5f757f3fSDimitry Andric using std::swap; 4510b57cec5SDimitry Andric swap(c, __q.c); 4520b57cec5SDimitry Andric } 4530b57cec5SDimitry Andric 454bdd1243dSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 455bdd1243dSDimitry Andric 45606c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 4570b57cec5SDimitry Andric friend 458*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4590b57cec5SDimitry Andric bool 46006c3fb27SDimitry Andric operator==(const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y); 4610b57cec5SDimitry Andric 46206c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 4630b57cec5SDimitry Andric friend 464*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 4650b57cec5SDimitry Andric bool 46606c3fb27SDimitry Andric operator< (const queue<_T1, _OtherContainer>& __x,const queue<_T1, _OtherContainer>& __y); 4670b57cec5SDimitry Andric}; 4680b57cec5SDimitry Andric 46906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 4700b57cec5SDimitry Andrictemplate<class _Container, 471349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 4720b57cec5SDimitry Andric> 4730b57cec5SDimitry Andricqueue(_Container) 4740b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 4750b57cec5SDimitry Andric 4760b57cec5SDimitry Andrictemplate<class _Container, 4770b57cec5SDimitry Andric class _Alloc, 478349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 479349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 4800b57cec5SDimitry Andric> 4810b57cec5SDimitry Andricqueue(_Container, _Alloc) 4820b57cec5SDimitry Andric -> queue<typename _Container::value_type, _Container>; 4830b57cec5SDimitry Andric#endif 4840b57cec5SDimitry Andric 48506c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 48604eeddc0SDimitry Andrictemplate <class _InputIterator, 48706c3fb27SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 48804eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator) 48904eeddc0SDimitry Andric -> queue<__iter_value_type<_InputIterator>>; 49004eeddc0SDimitry Andric 49106c3fb27SDimitry Andrictemplate <ranges::input_range _Range> 49206c3fb27SDimitry Andricqueue(from_range_t, _Range&&) 49306c3fb27SDimitry Andric -> queue<ranges::range_value_t<_Range>>; 49406c3fb27SDimitry Andric 49504eeddc0SDimitry Andrictemplate <class _InputIterator, 49604eeddc0SDimitry Andric class _Alloc, 49706c3fb27SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 49804eeddc0SDimitry Andric class = __enable_if_t<__is_allocator<_Alloc>::value>> 49904eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc) 50004eeddc0SDimitry Andric -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 50106c3fb27SDimitry Andric 50206c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 50306c3fb27SDimitry Andric class _Alloc, 50406c3fb27SDimitry Andric class = __enable_if_t<__is_allocator<_Alloc>::value>> 50506c3fb27SDimitry Andricqueue(from_range_t, _Range&&, _Alloc) 50606c3fb27SDimitry Andric -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; 50704eeddc0SDimitry Andric#endif 50804eeddc0SDimitry Andric 5090b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 510*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5110b57cec5SDimitry Andricbool 5120b57cec5SDimitry Andricoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5130b57cec5SDimitry Andric{ 5140b57cec5SDimitry Andric return __x.c == __y.c; 5150b57cec5SDimitry Andric} 5160b57cec5SDimitry Andric 5170b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 518*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5190b57cec5SDimitry Andricbool 5200b57cec5SDimitry Andricoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5210b57cec5SDimitry Andric{ 5220b57cec5SDimitry Andric return __x.c < __y.c; 5230b57cec5SDimitry Andric} 5240b57cec5SDimitry Andric 5250b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 526*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5270b57cec5SDimitry Andricbool 5280b57cec5SDimitry Andricoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5290b57cec5SDimitry Andric{ 5300b57cec5SDimitry Andric return !(__x == __y); 5310b57cec5SDimitry Andric} 5320b57cec5SDimitry Andric 5330b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 534*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5350b57cec5SDimitry Andricbool 5360b57cec5SDimitry Andricoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5370b57cec5SDimitry Andric{ 5380b57cec5SDimitry Andric return __y < __x; 5390b57cec5SDimitry Andric} 5400b57cec5SDimitry Andric 5410b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 542*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5430b57cec5SDimitry Andricbool 5440b57cec5SDimitry Andricoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5450b57cec5SDimitry Andric{ 5460b57cec5SDimitry Andric return !(__x < __y); 5470b57cec5SDimitry Andric} 5480b57cec5SDimitry Andric 5490b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 550*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 5510b57cec5SDimitry Andricbool 5520b57cec5SDimitry Andricoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 5530b57cec5SDimitry Andric{ 5540b57cec5SDimitry Andric return !(__y < __x); 5550b57cec5SDimitry Andric} 5560b57cec5SDimitry Andric 55706c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 55806c3fb27SDimitry Andric 55906c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container> 56006c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> 56106c3fb27SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 56206c3fb27SDimitry Andric // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors 56306c3fb27SDimitry Andric return __x.__get_container() <=> __y.__get_container(); 56406c3fb27SDimitry Andric} 56506c3fb27SDimitry Andric 56606c3fb27SDimitry Andric#endif 56706c3fb27SDimitry Andric 568*5f757f3fSDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> 569*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 570*5f757f3fSDimitry Andricvoid 5710b57cec5SDimitry Andricswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 5720b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 5730b57cec5SDimitry Andric{ 5740b57cec5SDimitry Andric __x.swap(__y); 5750b57cec5SDimitry Andric} 5760b57cec5SDimitry Andric 5770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 5780b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 5790b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 5800b57cec5SDimitry Andric{ 5810b57cec5SDimitry Andric}; 5820b57cec5SDimitry Andric 5830b57cec5SDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, 5840b57cec5SDimitry Andric class _Compare = less<typename _Container::value_type> > 5850b57cec5SDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue 5860b57cec5SDimitry Andric{ 5870b57cec5SDimitry Andricpublic: 5880b57cec5SDimitry Andric typedef _Container container_type; 5890b57cec5SDimitry Andric typedef _Compare value_compare; 5900b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 5910b57cec5SDimitry Andric typedef typename container_type::reference reference; 5920b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 5930b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 5940b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), "" ); 5950b57cec5SDimitry Andric 5960b57cec5SDimitry Andricprotected: 5970b57cec5SDimitry Andric container_type c; 5980b57cec5SDimitry Andric value_compare comp; 5990b57cec5SDimitry Andric 6000b57cec5SDimitry Andricpublic: 601*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6020b57cec5SDimitry Andric priority_queue() 6030b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 6040b57cec5SDimitry Andric is_nothrow_default_constructible<value_compare>::value) 6050b57cec5SDimitry Andric : c(), comp() {} 6060b57cec5SDimitry Andric 607*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6080b57cec5SDimitry Andric priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 6090b57cec5SDimitry Andric 610*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6110b57cec5SDimitry Andric priority_queue& operator=(const priority_queue& __q) 6120b57cec5SDimitry Andric {c = __q.c; comp = __q.comp; return *this;} 6130b57cec5SDimitry Andric 6140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 615*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6160b57cec5SDimitry Andric priority_queue(priority_queue&& __q) 6170b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 6180b57cec5SDimitry Andric is_nothrow_move_constructible<value_compare>::value) 619*5f757f3fSDimitry Andric : c(std::move(__q.c)), comp(std::move(__q.comp)) {} 6200b57cec5SDimitry Andric 621*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6220b57cec5SDimitry Andric priority_queue& operator=(priority_queue&& __q) 6230b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 6240b57cec5SDimitry Andric is_nothrow_move_assignable<value_compare>::value) 625*5f757f3fSDimitry Andric {c = std::move(__q.c); comp = std::move(__q.comp); return *this;} 6260b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6270b57cec5SDimitry Andric 628*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6290b57cec5SDimitry Andric explicit priority_queue(const value_compare& __comp) 6300b57cec5SDimitry Andric : c(), comp(__comp) {} 631*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6320b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c); 6330b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 634*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 635e8d8bef9SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c); 6360b57cec5SDimitry Andric#endif 63706c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 638*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6390b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 6400b57cec5SDimitry Andric const value_compare& __comp = value_compare()); 64106c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 642*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6430b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 6440b57cec5SDimitry Andric const value_compare& __comp, const container_type& __c); 6450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 64606c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 647*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6480b57cec5SDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 6490b57cec5SDimitry Andric const value_compare& __comp, container_type&& __c); 6500b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 65106c3fb27SDimitry Andric 65206c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 65306c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 65406c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 65506c3fb27SDimitry Andric priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) 65606c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range)), 65706c3fb27SDimitry Andric comp(__comp) { 65806c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 65906c3fb27SDimitry Andric } 66006c3fb27SDimitry Andric#endif 66106c3fb27SDimitry Andric 6620b57cec5SDimitry Andric template <class _Alloc> 663*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6640b57cec5SDimitry Andric explicit priority_queue(const _Alloc& __a, 665349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6660b57cec5SDimitry Andric template <class _Alloc> 667*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6680b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const _Alloc& __a, 669349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6700b57cec5SDimitry Andric template <class _Alloc> 671*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6720b57cec5SDimitry Andric priority_queue(const value_compare& __comp, const container_type& __c, 6730b57cec5SDimitry Andric const _Alloc& __a, 674349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6750b57cec5SDimitry Andric template <class _Alloc> 676*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6770b57cec5SDimitry Andric priority_queue(const priority_queue& __q, const _Alloc& __a, 678349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6790b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6800b57cec5SDimitry Andric template <class _Alloc> 681*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6820b57cec5SDimitry Andric priority_queue(const value_compare& __comp, container_type&& __c, 6830b57cec5SDimitry Andric const _Alloc& __a, 684349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6850b57cec5SDimitry Andric template <class _Alloc> 686*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 6870b57cec5SDimitry Andric priority_queue(priority_queue&& __q, const _Alloc& __a, 688349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 689349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 690349cc55cSDimitry Andric 69106c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 692*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 693349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 694349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 695349cc55cSDimitry Andric 69606c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 697*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 698349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 699349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 700349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 701349cc55cSDimitry Andric 70206c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 703*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 704349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 705349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 706349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 707349cc55cSDimitry Andric 708349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 70906c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 710*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 711349cc55cSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, 712349cc55cSDimitry Andric const value_compare& __comp, container_type&& __c, const _Alloc& __a, 713349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 7140b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7150b57cec5SDimitry Andric 71606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 71706c3fb27SDimitry Andric 71806c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 71906c3fb27SDimitry Andric class _Alloc, 72006c3fb27SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 72106c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 72206c3fb27SDimitry Andric priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a) 72306c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), 72406c3fb27SDimitry Andric comp(__comp) { 72506c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 72606c3fb27SDimitry Andric } 72706c3fb27SDimitry Andric 72806c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 72906c3fb27SDimitry Andric class _Alloc, 73006c3fb27SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 73106c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 73206c3fb27SDimitry Andric priority_queue(from_range_t, _Range&& __range, const _Alloc& __a) 73306c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), 73406c3fb27SDimitry Andric comp() { 73506c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 73606c3fb27SDimitry Andric } 73706c3fb27SDimitry Andric 73806c3fb27SDimitry Andric#endif 73906c3fb27SDimitry Andric 740*5f757f3fSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI 7410b57cec5SDimitry Andric bool empty() const {return c.empty();} 742*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7430b57cec5SDimitry Andric size_type size() const {return c.size();} 744*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7450b57cec5SDimitry Andric const_reference top() const {return c.front();} 7460b57cec5SDimitry Andric 747*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7480b57cec5SDimitry Andric void push(const value_type& __v); 7490b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 750*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7510b57cec5SDimitry Andric void push(value_type&& __v); 75206c3fb27SDimitry Andric 75306c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 75406c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 75506c3fb27SDimitry Andric _LIBCPP_HIDE_FROM_ABI 75606c3fb27SDimitry Andric void push_range(_Range&& __range) { 75706c3fb27SDimitry Andric if constexpr (requires (container_type& __c) { 75806c3fb27SDimitry Andric __c.append_range(std::forward<_Range>(__range)); 75906c3fb27SDimitry Andric }) { 76006c3fb27SDimitry Andric c.append_range(std::forward<_Range>(__range)); 76106c3fb27SDimitry Andric } else { 76206c3fb27SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 76306c3fb27SDimitry Andric } 76406c3fb27SDimitry Andric 76506c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 76606c3fb27SDimitry Andric } 76706c3fb27SDimitry Andric#endif 76806c3fb27SDimitry Andric 7690b57cec5SDimitry Andric template <class... _Args> 770*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7710b57cec5SDimitry Andric void emplace(_Args&&... __args); 7720b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 773*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7740b57cec5SDimitry Andric void pop(); 7750b57cec5SDimitry Andric 776*5f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 7770b57cec5SDimitry Andric void swap(priority_queue& __q) 7780b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 7790b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value); 780bdd1243dSDimitry Andric 781bdd1243dSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 7820b57cec5SDimitry Andric}; 7830b57cec5SDimitry Andric 784349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 7850b57cec5SDimitry Andrictemplate <class _Compare, 7860b57cec5SDimitry Andric class _Container, 787349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 788349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 7890b57cec5SDimitry Andric> 7900b57cec5SDimitry Andricpriority_queue(_Compare, _Container) 7910b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 7920b57cec5SDimitry Andric 7930b57cec5SDimitry Andrictemplate<class _InputIterator, 794fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 795fe6060f1SDimitry Andric class _Container = vector<__iter_value_type<_InputIterator>>, 79606c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 797349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 798349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> 7990b57cec5SDimitry Andric> 8000b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 801fe6060f1SDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 8020b57cec5SDimitry Andric 8030b57cec5SDimitry Andrictemplate<class _Compare, 8040b57cec5SDimitry Andric class _Container, 8050b57cec5SDimitry Andric class _Alloc, 806349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 807349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 808349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 8090b57cec5SDimitry Andric> 8100b57cec5SDimitry Andricpriority_queue(_Compare, _Container, _Alloc) 8110b57cec5SDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 812349cc55cSDimitry Andric 813349cc55cSDimitry Andrictemplate<class _InputIterator, class _Allocator, 81406c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 815349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 816349cc55cSDimitry Andric> 817349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator) 818349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 819349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 820349cc55cSDimitry Andric less<__iter_value_type<_InputIterator>>>; 821349cc55cSDimitry Andric 822349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Allocator, 82306c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 824349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 825349cc55cSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> 826349cc55cSDimitry Andric> 827349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 828349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 829349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 830349cc55cSDimitry Andric 831349cc55cSDimitry Andrictemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 83206c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 833349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 834349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 835349cc55cSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 836349cc55cSDimitry Andric> 837349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 838349cc55cSDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 8390b57cec5SDimitry Andric#endif 8400b57cec5SDimitry Andric 84106c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 84206c3fb27SDimitry Andric 84306c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 84406c3fb27SDimitry Andric class _Compare = less<ranges::range_value_t<_Range>>, 84506c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>> 84606c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare()) 84706c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>; 84806c3fb27SDimitry Andric 84906c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 85006c3fb27SDimitry Andric class _Compare, 85106c3fb27SDimitry Andric class _Alloc, 85206c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 85306c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Alloc>::value>> 85406c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc) 85506c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, 85606c3fb27SDimitry Andric _Compare>; 85706c3fb27SDimitry Andric 85806c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 85906c3fb27SDimitry Andric class _Alloc, 86006c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Alloc>::value>> 86106c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc) 86206c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; 86306c3fb27SDimitry Andric 86406c3fb27SDimitry Andric#endif 86506c3fb27SDimitry Andric 8660b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8670b57cec5SDimitry Andricinline 8680b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 8690b57cec5SDimitry Andric const container_type& __c) 8700b57cec5SDimitry Andric : c(__c), 8710b57cec5SDimitry Andric comp(__comp) 8720b57cec5SDimitry Andric{ 873*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8740b57cec5SDimitry Andric} 8750b57cec5SDimitry Andric 8760b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8770b57cec5SDimitry Andric 8780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8790b57cec5SDimitry Andricinline 8800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 8810b57cec5SDimitry Andric container_type&& __c) 882*5f757f3fSDimitry Andric : c(std::move(__c)), 8830b57cec5SDimitry Andric comp(__comp) 8840b57cec5SDimitry Andric{ 885*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8860b57cec5SDimitry Andric} 8870b57cec5SDimitry Andric 8880b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8890b57cec5SDimitry Andric 8900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 891349cc55cSDimitry Andrictemplate <class _InputIter, class> 8920b57cec5SDimitry Andricinline 8930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 8940b57cec5SDimitry Andric const value_compare& __comp) 8950b57cec5SDimitry Andric : c(__f, __l), 8960b57cec5SDimitry Andric comp(__comp) 8970b57cec5SDimitry Andric{ 898*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8990b57cec5SDimitry Andric} 9000b57cec5SDimitry Andric 9010b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 902349cc55cSDimitry Andrictemplate <class _InputIter, class> 9030b57cec5SDimitry Andricinline 9040b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 9050b57cec5SDimitry Andric const value_compare& __comp, 9060b57cec5SDimitry Andric const container_type& __c) 9070b57cec5SDimitry Andric : c(__c), 9080b57cec5SDimitry Andric comp(__comp) 9090b57cec5SDimitry Andric{ 9100b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 911*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 9120b57cec5SDimitry Andric} 9130b57cec5SDimitry Andric 9140b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9150b57cec5SDimitry Andric 9160b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 917349cc55cSDimitry Andrictemplate <class _InputIter, class> 9180b57cec5SDimitry Andricinline 9190b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 9200b57cec5SDimitry Andric const value_compare& __comp, 9210b57cec5SDimitry Andric container_type&& __c) 922*5f757f3fSDimitry Andric : c(std::move(__c)), 9230b57cec5SDimitry Andric comp(__comp) 9240b57cec5SDimitry Andric{ 9250b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 926*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 9270b57cec5SDimitry Andric} 9280b57cec5SDimitry Andric 9290b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 9300b57cec5SDimitry Andric 9310b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9320b57cec5SDimitry Andrictemplate <class _Alloc> 9330b57cec5SDimitry Andricinline 9340b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 935349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 9360b57cec5SDimitry Andric : c(__a) 9370b57cec5SDimitry Andric{ 9380b57cec5SDimitry Andric} 9390b57cec5SDimitry Andric 9400b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9410b57cec5SDimitry Andrictemplate <class _Alloc> 9420b57cec5SDimitry Andricinline 9430b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 9440b57cec5SDimitry Andric const _Alloc& __a, 945349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 9460b57cec5SDimitry Andric : c(__a), 9470b57cec5SDimitry Andric comp(__comp) 9480b57cec5SDimitry Andric{ 9490b57cec5SDimitry Andric} 9500b57cec5SDimitry Andric 9510b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9520b57cec5SDimitry Andrictemplate <class _Alloc> 9530b57cec5SDimitry Andricinline 9540b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 9550b57cec5SDimitry Andric const container_type& __c, 9560b57cec5SDimitry Andric const _Alloc& __a, 957349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 9580b57cec5SDimitry Andric : c(__c, __a), 9590b57cec5SDimitry Andric comp(__comp) 9600b57cec5SDimitry Andric{ 961*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 9620b57cec5SDimitry Andric} 9630b57cec5SDimitry Andric 9640b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9650b57cec5SDimitry Andrictemplate <class _Alloc> 9660b57cec5SDimitry Andricinline 9670b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 9680b57cec5SDimitry Andric const _Alloc& __a, 969349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 9700b57cec5SDimitry Andric : c(__q.c, __a), 9710b57cec5SDimitry Andric comp(__q.comp) 9720b57cec5SDimitry Andric{ 9730b57cec5SDimitry Andric} 9740b57cec5SDimitry Andric 9750b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9760b57cec5SDimitry Andric 9770b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9780b57cec5SDimitry Andrictemplate <class _Alloc> 9790b57cec5SDimitry Andricinline 9800b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 9810b57cec5SDimitry Andric container_type&& __c, 9820b57cec5SDimitry Andric const _Alloc& __a, 983349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 984*5f757f3fSDimitry Andric : c(std::move(__c), __a), 9850b57cec5SDimitry Andric comp(__comp) 9860b57cec5SDimitry Andric{ 987*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 9880b57cec5SDimitry Andric} 9890b57cec5SDimitry Andric 9900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9910b57cec5SDimitry Andrictemplate <class _Alloc> 9920b57cec5SDimitry Andricinline 9930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 9940b57cec5SDimitry Andric const _Alloc& __a, 995349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 996*5f757f3fSDimitry Andric : c(std::move(__q.c), __a), 997*5f757f3fSDimitry Andric comp(std::move(__q.comp)) 9980b57cec5SDimitry Andric{ 999349cc55cSDimitry Andric} 1000349cc55cSDimitry Andric 1001349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 1002349cc55cSDimitry Andric 1003349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 1004349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 1005349cc55cSDimitry Andricinline 1006349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 1007349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const _Alloc& __a, 1008349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 1009349cc55cSDimitry Andric : c(__f, __l, __a), 1010349cc55cSDimitry Andric comp() 1011349cc55cSDimitry Andric{ 1012*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 10130b57cec5SDimitry Andric} 10140b57cec5SDimitry Andric 1015349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 1016349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 1017349cc55cSDimitry Andricinline 1018349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 1019349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 1020349cc55cSDimitry Andric const value_compare& __comp, const _Alloc& __a, 1021349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 1022349cc55cSDimitry Andric : c(__f, __l, __a), 1023349cc55cSDimitry Andric comp(__comp) 1024349cc55cSDimitry Andric{ 1025*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 1026349cc55cSDimitry Andric} 1027349cc55cSDimitry Andric 1028349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 1029349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 1030349cc55cSDimitry Andricinline 1031349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 1032349cc55cSDimitry Andric _InputIter __f, _InputIter __l, 1033349cc55cSDimitry Andric const value_compare& __comp, const container_type& __c, const _Alloc& __a, 1034349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 1035349cc55cSDimitry Andric : c(__c, __a), 1036349cc55cSDimitry Andric comp(__comp) 1037349cc55cSDimitry Andric{ 1038349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 1039*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 1040349cc55cSDimitry Andric} 1041349cc55cSDimitry Andric 1042349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1043349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 1044349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 1045349cc55cSDimitry Andricinline 1046349cc55cSDimitry Andricpriority_queue<_Tp, _Container, _Compare>::priority_queue( 1047349cc55cSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, 1048349cc55cSDimitry Andric container_type&& __c, const _Alloc& __a, 1049349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 1050*5f757f3fSDimitry Andric : c(std::move(__c), __a), 1051349cc55cSDimitry Andric comp(__comp) 1052349cc55cSDimitry Andric{ 1053349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 1054*5f757f3fSDimitry Andric std::make_heap(c.begin(), c.end(), comp); 1055349cc55cSDimitry Andric} 10560b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 10570b57cec5SDimitry Andric 10580b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 10590b57cec5SDimitry Andricinline 10600b57cec5SDimitry Andricvoid 10610b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 10620b57cec5SDimitry Andric{ 10630b57cec5SDimitry Andric c.push_back(__v); 1064*5f757f3fSDimitry Andric std::push_heap(c.begin(), c.end(), comp); 10650b57cec5SDimitry Andric} 10660b57cec5SDimitry Andric 10670b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10680b57cec5SDimitry Andric 10690b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 10700b57cec5SDimitry Andricinline 10710b57cec5SDimitry Andricvoid 10720b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 10730b57cec5SDimitry Andric{ 1074*5f757f3fSDimitry Andric c.push_back(std::move(__v)); 1075*5f757f3fSDimitry Andric std::push_heap(c.begin(), c.end(), comp); 10760b57cec5SDimitry Andric} 10770b57cec5SDimitry Andric 10780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 10790b57cec5SDimitry Andrictemplate <class... _Args> 10800b57cec5SDimitry Andricinline 10810b57cec5SDimitry Andricvoid 10820b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 10830b57cec5SDimitry Andric{ 1084*5f757f3fSDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 1085*5f757f3fSDimitry Andric std::push_heap(c.begin(), c.end(), comp); 10860b57cec5SDimitry Andric} 10870b57cec5SDimitry Andric 10880b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 10890b57cec5SDimitry Andric 10900b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 10910b57cec5SDimitry Andricinline 10920b57cec5SDimitry Andricvoid 10930b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::pop() 10940b57cec5SDimitry Andric{ 1095*5f757f3fSDimitry Andric std::pop_heap(c.begin(), c.end(), comp); 10960b57cec5SDimitry Andric c.pop_back(); 10970b57cec5SDimitry Andric} 10980b57cec5SDimitry Andric 10990b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 11000b57cec5SDimitry Andricinline 11010b57cec5SDimitry Andricvoid 11020b57cec5SDimitry Andricpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 11030b57cec5SDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 11040b57cec5SDimitry Andric __is_nothrow_swappable<value_compare>::value) 11050b57cec5SDimitry Andric{ 1106*5f757f3fSDimitry Andric using std::swap; 11070b57cec5SDimitry Andric swap(c, __q.c); 11080b57cec5SDimitry Andric swap(comp, __q.comp); 11090b57cec5SDimitry Andric} 11100b57cec5SDimitry Andric 1111*5f757f3fSDimitry Andrictemplate <class _Tp, class _Container, class _Compare, 1112*5f757f3fSDimitry Andric __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0> 1113*5f757f3fSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI 11140b57cec5SDimitry Andricvoid 11150b57cec5SDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, 11160b57cec5SDimitry Andric priority_queue<_Tp, _Container, _Compare>& __y) 11170b57cec5SDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 11180b57cec5SDimitry Andric{ 11190b57cec5SDimitry Andric __x.swap(__y); 11200b57cec5SDimitry Andric} 11210b57cec5SDimitry Andric 11220b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc> 11230b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 11240b57cec5SDimitry Andric : public uses_allocator<_Container, _Alloc> 11250b57cec5SDimitry Andric{ 11260b57cec5SDimitry Andric}; 11270b57cec5SDimitry Andric 11280b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 11290b57cec5SDimitry Andric 1130bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 1131bdd1243dSDimitry Andric# include <concepts> 113206c3fb27SDimitry Andric# include <cstdlib> 1133bdd1243dSDimitry Andric# include <functional> 113406c3fb27SDimitry Andric# include <type_traits> 1135bdd1243dSDimitry Andric#endif 1136bdd1243dSDimitry Andric 11370b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE 1138