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 46fe013be4SDimitry 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 59fe013be4SDimitry Andric template<container-compatible-range<T> R, class Alloc> 60fe013be4SDimitry 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); 72fe013be4SDimitry Andric template<container-compatible-range<T> R> 73fe013be4SDimitry 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 86fe013be4SDimitry Andrictemplate<ranges::input_range R> 87fe013be4SDimitry Andric queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23 88fe013be4SDimitry 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 97fe013be4SDimitry Andrictemplate<ranges::input_range R, class Allocator> 98fe013be4SDimitry Andric queue(from_range_t, R&&, Allocator) 99fe013be4SDimitry Andric -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23 100fe013be4SDimitry 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 119fe013be4SDimitry Andrictemplate<class T, three_way_comparable Container> 120fe013be4SDimitry Andric compare_three_way_result_t<Container> 121fe013be4SDimitry Andric operator<=>(const queue<T, Container>& x, const queue<T, Container>& y); // since C++20 122fe013be4SDimitry 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); 157fe013be4SDimitry Andric template <container-compatible-range<T> R> 158fe013be4SDimitry 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); 181fe013be4SDimitry Andric template <container-compatible-range<T> R, class Alloc> 182fe013be4SDimitry Andric priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23 183fe013be4SDimitry Andric template <container-compatible-range<T> R, class Alloc> 184fe013be4SDimitry 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); 196fe013be4SDimitry Andric template<container-compatible-range<T> R> 197fe013be4SDimitry 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 216fe013be4SDimitry Andrictemplate<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>> 217fe013be4SDimitry Andric priority_queue(from_range_t, R&&, Compare = Compare()) 218fe013be4SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23 219fe013be4SDimitry 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 239fe013be4SDimitry Andrictemplate<ranges::input_range R, class Compare, class Allocator> 240fe013be4SDimitry Andric priority_queue(from_range_t, R&&, Compare, Allocator) 241fe013be4SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>, 242fe013be4SDimitry Andric Compare>; // C++23 243fe013be4SDimitry Andric 244fe013be4SDimitry Andrictemplate<ranges::input_range R, class Allocator> 245fe013be4SDimitry Andric priority_queue(from_range_t, R&&, Allocator) 246fe013be4SDimitry Andric -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23 247fe013be4SDimitry 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> 260fe013be4SDimitry 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> 264fe013be4SDimitry Andric#include <__iterator/back_insert_iterator.h> 26504eeddc0SDimitry Andric#include <__iterator/iterator_traits.h> 266fe6060f1SDimitry Andric#include <__memory/uses_allocator.h> 267fe013be4SDimitry Andric#include <__ranges/access.h> 268fe013be4SDimitry Andric#include <__ranges/concepts.h> 269fe013be4SDimitry Andric#include <__ranges/container_compatible_range.h> 270fe013be4SDimitry 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 286*b9d9368bSDimitry Andric_LIBCPP_PUSH_MACROS 287*b9d9368bSDimitry Andric#include <__undef_macros> 288*b9d9368bSDimitry Andric 2890b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2900b57cec5SDimitry Andric 291e710425bSDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > 292e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue; 2930b57cec5SDimitry Andric 2940b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 295e710425bSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); 2960b57cec5SDimitry Andric 2970b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 298e710425bSDimitry Andric_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); 2990b57cec5SDimitry Andric 3000b57cec5SDimitry Andrictemplate <class _Tp, class _Container /*= deque<_Tp>*/> 301e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue { 3020b57cec5SDimitry Andricpublic: 3030b57cec5SDimitry Andric typedef _Container container_type; 3040b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 3050b57cec5SDimitry Andric typedef typename container_type::reference reference; 3060b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 3070b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 3080b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), ""); 3090b57cec5SDimitry Andric 3100b57cec5SDimitry Andricprotected: 3110b57cec5SDimitry Andric container_type c; 3120b57cec5SDimitry Andric 3130b57cec5SDimitry Andricpublic: 314e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {} 3150b57cec5SDimitry Andric 316e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} 3170b57cec5SDimitry Andric 318fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 23 319e710425bSDimitry Andric template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 320e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 32104eeddc0SDimitry Andric 322fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 323e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {} 324fe013be4SDimitry Andric 32504eeddc0SDimitry Andric template <class _InputIterator, 32604eeddc0SDimitry Andric class _Alloc, 327fe013be4SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 32804eeddc0SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 329e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) 330e710425bSDimitry Andric : c(__first, __second, __alloc) {} 331fe013be4SDimitry Andric 332fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 333fe013be4SDimitry Andric class _Alloc, 334fe013be4SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 335e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) 336fe013be4SDimitry Andric : c(from_range, std::forward<_Range>(__range), __alloc) {} 337fe013be4SDimitry Andric 33804eeddc0SDimitry Andric#endif 33904eeddc0SDimitry Andric 340e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) { 341e710425bSDimitry Andric c = __q.c; 342e710425bSDimitry Andric return *this; 343e710425bSDimitry Andric } 3440b57cec5SDimitry Andric 3450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 346e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 347c9157d92SDimitry Andric : c(std::move(__q.c)) {} 3480b57cec5SDimitry Andric 349e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) { 350e710425bSDimitry Andric c = std::move(__q.c); 351e710425bSDimitry Andric return *this; 352e710425bSDimitry Andric } 3530b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3540b57cec5SDimitry Andric 355e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {} 3560b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 357e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {} 3580b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3590b57cec5SDimitry Andric template <class _Alloc> 360e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a, 361349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3620b57cec5SDimitry Andric : c(__a) {} 3630b57cec5SDimitry Andric template <class _Alloc> 364c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 365e710425bSDimitry Andric queue(const queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3660b57cec5SDimitry Andric : c(__q.c, __a) {} 3670b57cec5SDimitry Andric template <class _Alloc> 368c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 369e710425bSDimitry Andric queue(const container_type& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3700b57cec5SDimitry Andric : c(__c, __a) {} 3710b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3720b57cec5SDimitry Andric template <class _Alloc> 373c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 374e710425bSDimitry Andric queue(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 375c9157d92SDimitry Andric : c(std::move(__c), __a) {} 3760b57cec5SDimitry Andric template <class _Alloc> 377c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 378e710425bSDimitry Andric queue(queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 379c9157d92SDimitry Andric : c(std::move(__q.c), __a) {} 3800b57cec5SDimitry Andric 3810b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3820b57cec5SDimitry Andric 383e710425bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } 384e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } 3850b57cec5SDimitry Andric 386e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } 387e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); } 388e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); } 389e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } 3900b57cec5SDimitry Andric 391e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } 3920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 393e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } 394fe013be4SDimitry Andric 395fe013be4SDimitry Andric# if _LIBCPP_STD_VER >= 23 396fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 397e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { 398e710425bSDimitry Andric if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { 399fe013be4SDimitry Andric c.append_range(std::forward<_Range>(__range)); 400fe013be4SDimitry Andric } else { 401fe013be4SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 402fe013be4SDimitry Andric } 403fe013be4SDimitry Andric } 404fe013be4SDimitry Andric# endif 405fe013be4SDimitry Andric 4060b57cec5SDimitry Andric template <class... _Args> 407c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 408fe013be4SDimitry Andric# if _LIBCPP_STD_VER >= 17 409e710425bSDimitry Andric decltype(auto) 410e710425bSDimitry Andric emplace(_Args&&... __args) { 411e710425bSDimitry Andric return c.emplace_back(std::forward<_Args>(__args)...); 412e710425bSDimitry Andric } 4130b57cec5SDimitry Andric# else 414e710425bSDimitry Andric void 415e710425bSDimitry Andric emplace(_Args&&... __args) { 416e710425bSDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 417e710425bSDimitry Andric } 4180b57cec5SDimitry Andric# endif 4190b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 420e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } 4210b57cec5SDimitry Andric 422e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) { 423c9157d92SDimitry Andric using std::swap; 4240b57cec5SDimitry Andric swap(c, __q.c); 4250b57cec5SDimitry Andric } 4260b57cec5SDimitry Andric 427bdd1243dSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 428bdd1243dSDimitry Andric 429fe013be4SDimitry Andric template <class _T1, class _OtherContainer> 430e710425bSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 431fe013be4SDimitry Andric operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); 4320b57cec5SDimitry Andric 433fe013be4SDimitry Andric template <class _T1, class _OtherContainer> 434e710425bSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 435fe013be4SDimitry Andric operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); 4360b57cec5SDimitry Andric}; 4370b57cec5SDimitry Andric 438fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 17 439e710425bSDimitry Andrictemplate <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > 440e710425bSDimitry Andricqueue(_Container) -> queue<typename _Container::value_type, _Container>; 4410b57cec5SDimitry Andric 4420b57cec5SDimitry Andrictemplate <class _Container, 4430b57cec5SDimitry Andric class _Alloc, 444349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 445e710425bSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 446e710425bSDimitry Andricqueue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; 4470b57cec5SDimitry Andric#endif 4480b57cec5SDimitry Andric 449fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 23 450e710425bSDimitry Andrictemplate <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 451e710425bSDimitry Andricqueue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; 45204eeddc0SDimitry Andric 453fe013be4SDimitry Andrictemplate <ranges::input_range _Range> 454e710425bSDimitry Andricqueue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; 455fe013be4SDimitry Andric 45604eeddc0SDimitry Andrictemplate <class _InputIterator, 45704eeddc0SDimitry Andric class _Alloc, 458fe013be4SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 45904eeddc0SDimitry Andric class = __enable_if_t<__is_allocator<_Alloc>::value>> 46004eeddc0SDimitry Andricqueue(_InputIterator, _InputIterator, _Alloc) 46104eeddc0SDimitry Andric -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; 462fe013be4SDimitry Andric 463e710425bSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>> 464fe013be4SDimitry Andricqueue(from_range_t, _Range&&, _Alloc) 465fe013be4SDimitry Andric -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; 46604eeddc0SDimitry Andric#endif 46704eeddc0SDimitry Andric 4680b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 469e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4700b57cec5SDimitry Andric return __x.c == __y.c; 4710b57cec5SDimitry Andric} 4720b57cec5SDimitry Andric 4730b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 474e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4750b57cec5SDimitry Andric return __x.c < __y.c; 4760b57cec5SDimitry Andric} 4770b57cec5SDimitry Andric 4780b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 479e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4800b57cec5SDimitry Andric return !(__x == __y); 4810b57cec5SDimitry Andric} 4820b57cec5SDimitry Andric 4830b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 484e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4850b57cec5SDimitry Andric return __y < __x; 4860b57cec5SDimitry Andric} 4870b57cec5SDimitry Andric 4880b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 489e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4900b57cec5SDimitry Andric return !(__x < __y); 4910b57cec5SDimitry Andric} 4920b57cec5SDimitry Andric 4930b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 494e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 4950b57cec5SDimitry Andric return !(__y < __x); 4960b57cec5SDimitry Andric} 4970b57cec5SDimitry Andric 498fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 20 499fe013be4SDimitry Andric 500fe013be4SDimitry Andrictemplate <class _Tp, three_way_comparable _Container> 501fe013be4SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> 502fe013be4SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 503fe013be4SDimitry Andric // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors 504fe013be4SDimitry Andric return __x.__get_container() <=> __y.__get_container(); 505fe013be4SDimitry Andric} 506fe013be4SDimitry Andric 507fe013be4SDimitry Andric#endif 508fe013be4SDimitry Andric 509c9157d92SDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> 510e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 511e710425bSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { 5120b57cec5SDimitry Andric __x.swap(__y); 5130b57cec5SDimitry Andric} 5140b57cec5SDimitry Andric 5150b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 516e710425bSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { 5170b57cec5SDimitry Andric}; 5180b57cec5SDimitry Andric 519e710425bSDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > 520e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS priority_queue { 5210b57cec5SDimitry Andricpublic: 5220b57cec5SDimitry Andric typedef _Container container_type; 5230b57cec5SDimitry Andric typedef _Compare value_compare; 5240b57cec5SDimitry Andric typedef typename container_type::value_type value_type; 5250b57cec5SDimitry Andric typedef typename container_type::reference reference; 5260b57cec5SDimitry Andric typedef typename container_type::const_reference const_reference; 5270b57cec5SDimitry Andric typedef typename container_type::size_type size_type; 5280b57cec5SDimitry Andric static_assert((is_same<_Tp, value_type>::value), ""); 5290b57cec5SDimitry Andric 5300b57cec5SDimitry Andricprotected: 5310b57cec5SDimitry Andric container_type c; 5320b57cec5SDimitry Andric value_compare comp; 5330b57cec5SDimitry Andric 5340b57cec5SDimitry Andricpublic: 535e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_( 536e710425bSDimitry Andric is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value) 5370b57cec5SDimitry Andric : c(), comp() {} 5380b57cec5SDimitry Andric 539e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5400b57cec5SDimitry Andric 541e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) { 542e710425bSDimitry Andric c = __q.c; 543e710425bSDimitry Andric comp = __q.comp; 544e710425bSDimitry Andric return *this; 545e710425bSDimitry Andric } 5460b57cec5SDimitry Andric 5470b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 548e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_( 549e710425bSDimitry Andric is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value) 550c9157d92SDimitry Andric : c(std::move(__q.c)), comp(std::move(__q.comp)) {} 5510b57cec5SDimitry Andric 552e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) 553e710425bSDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) { 554e710425bSDimitry Andric c = std::move(__q.c); 555e710425bSDimitry Andric comp = std::move(__q.comp); 556e710425bSDimitry Andric return *this; 557e710425bSDimitry Andric } 5580b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5590b57cec5SDimitry Andric 560e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} 561e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); 5620b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 563e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); 5640b57cec5SDimitry Andric#endif 565fe013be4SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 566e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); 567fe013be4SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 568c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 569e710425bSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); 5700b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 571fe013be4SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 572c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 573e710425bSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); 5740b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 575fe013be4SDimitry Andric 576fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 23 577fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 578e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) 579e710425bSDimitry Andric : c(from_range, std::forward<_Range>(__range)), comp(__comp) { 580fe013be4SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 581fe013be4SDimitry Andric } 582fe013be4SDimitry Andric#endif 583fe013be4SDimitry Andric 5840b57cec5SDimitry Andric template <class _Alloc> 585e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a, 586349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5870b57cec5SDimitry Andric template <class _Alloc> 588c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 589e710425bSDimitry Andric priority_queue(const value_compare& __comp, 5900b57cec5SDimitry Andric const _Alloc& __a, 591349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 5920b57cec5SDimitry Andric template <class _Alloc> 593c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 594e710425bSDimitry Andric priority_queue(const value_compare& __comp, 595e710425bSDimitry Andric const container_type& __c, 596e710425bSDimitry Andric const _Alloc& __a, 597349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 598e710425bSDimitry Andric template <class _Alloc> 599e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 600e710425bSDimitry Andric const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6010b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6020b57cec5SDimitry Andric template <class _Alloc> 603c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 604e710425bSDimitry Andric priority_queue(const value_compare& __comp, 605e710425bSDimitry Andric container_type&& __c, 6060b57cec5SDimitry Andric const _Alloc& __a, 607349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6080b57cec5SDimitry Andric template <class _Alloc> 609e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 610e710425bSDimitry Andric priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 611349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 612349cc55cSDimitry Andric 613fe013be4SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 614c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI 615e710425bSDimitry Andric priority_queue(_InputIter __f, 616e710425bSDimitry Andric _InputIter __l, 617e710425bSDimitry Andric const _Alloc& __a, 618349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 619349cc55cSDimitry Andric 620fe013be4SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 621e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 622e710425bSDimitry Andric _InputIter __f, 623e710425bSDimitry Andric _InputIter __l, 624e710425bSDimitry Andric const value_compare& __comp, 625e710425bSDimitry Andric const _Alloc& __a, 626349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 627349cc55cSDimitry Andric 628fe013be4SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 629e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 630e710425bSDimitry Andric _InputIter __f, 631e710425bSDimitry Andric _InputIter __l, 632e710425bSDimitry Andric const value_compare& __comp, 633e710425bSDimitry Andric const container_type& __c, 634e710425bSDimitry Andric const _Alloc& __a, 635349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 636349cc55cSDimitry Andric 637349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 638fe013be4SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 639e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 640e710425bSDimitry Andric _InputIter __f, 641e710425bSDimitry Andric _InputIter __l, 642e710425bSDimitry Andric const value_compare& __comp, 643e710425bSDimitry Andric container_type&& __c, 644e710425bSDimitry Andric const _Alloc& __a, 645349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6460b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6470b57cec5SDimitry Andric 648fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 23 649fe013be4SDimitry Andric 650fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 651fe013be4SDimitry Andric class _Alloc, 652fe013be4SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 653e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a) 654e710425bSDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) { 655fe013be4SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 656fe013be4SDimitry Andric } 657fe013be4SDimitry Andric 658fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 659fe013be4SDimitry Andric class _Alloc, 660fe013be4SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 661e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a) 662e710425bSDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), comp() { 663fe013be4SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 664fe013be4SDimitry Andric } 665fe013be4SDimitry Andric 666fe013be4SDimitry Andric#endif 667fe013be4SDimitry Andric 668e710425bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } 669e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } 670e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } 6710b57cec5SDimitry Andric 672e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); 6730b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 674e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); 675fe013be4SDimitry Andric 676fe013be4SDimitry Andric# if _LIBCPP_STD_VER >= 23 677fe013be4SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 678e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { 679e710425bSDimitry Andric if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { 680fe013be4SDimitry Andric c.append_range(std::forward<_Range>(__range)); 681fe013be4SDimitry Andric } else { 682fe013be4SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 683fe013be4SDimitry Andric } 684fe013be4SDimitry Andric 685fe013be4SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 686fe013be4SDimitry Andric } 687fe013be4SDimitry Andric# endif 688fe013be4SDimitry Andric 6890b57cec5SDimitry Andric template <class... _Args> 690e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); 6910b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 692e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void pop(); 6930b57cec5SDimitry Andric 694e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) 695e710425bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value); 696bdd1243dSDimitry Andric 697bdd1243dSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } 6980b57cec5SDimitry Andric}; 6990b57cec5SDimitry Andric 700349cc55cSDimitry Andric#if _LIBCPP_STD_VER >= 17 7010b57cec5SDimitry Andrictemplate <class _Compare, 7020b57cec5SDimitry Andric class _Container, 703349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 704e710425bSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> > 705e710425bSDimitry Andricpriority_queue(_Compare, _Container) -> priority_queue<typename _Container::value_type, _Container, _Compare>; 7060b57cec5SDimitry Andric 7070b57cec5SDimitry Andrictemplate <class _InputIterator, 708fe6060f1SDimitry Andric class _Compare = less<__iter_value_type<_InputIterator>>, 709fe6060f1SDimitry Andric class _Container = vector<__iter_value_type<_InputIterator>>, 710fe013be4SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 711349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 712e710425bSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> > 7130b57cec5SDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 714fe6060f1SDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 7150b57cec5SDimitry Andric 7160b57cec5SDimitry Andrictemplate <class _Compare, 7170b57cec5SDimitry Andric class _Container, 7180b57cec5SDimitry Andric class _Alloc, 719349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 720349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 721e710425bSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 722e710425bSDimitry Andricpriority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>; 723349cc55cSDimitry Andric 724e710425bSDimitry Andrictemplate <class _InputIterator, 725e710425bSDimitry Andric class _Allocator, 726fe013be4SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 727e710425bSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> > 728349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Allocator) 729349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 730349cc55cSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 731349cc55cSDimitry Andric less<__iter_value_type<_InputIterator>>>; 732349cc55cSDimitry Andric 733e710425bSDimitry Andrictemplate <class _InputIterator, 734e710425bSDimitry Andric class _Compare, 735e710425bSDimitry Andric class _Allocator, 736fe013be4SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 737349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 738e710425bSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> > 739349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 740349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 741e710425bSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 742e710425bSDimitry Andric _Compare>; 743349cc55cSDimitry Andric 744e710425bSDimitry Andrictemplate <class _InputIterator, 745e710425bSDimitry Andric class _Compare, 746e710425bSDimitry Andric class _Container, 747e710425bSDimitry Andric class _Alloc, 748fe013be4SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 749349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 750349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value>, 751e710425bSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 752349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 753349cc55cSDimitry Andric -> priority_queue<typename _Container::value_type, _Container, _Compare>; 7540b57cec5SDimitry Andric#endif 7550b57cec5SDimitry Andric 756fe013be4SDimitry Andric#if _LIBCPP_STD_VER >= 23 757fe013be4SDimitry Andric 758fe013be4SDimitry Andrictemplate <ranges::input_range _Range, 759fe013be4SDimitry Andric class _Compare = less<ranges::range_value_t<_Range>>, 760fe013be4SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>> 761fe013be4SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare()) 762fe013be4SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>; 763fe013be4SDimitry Andric 764fe013be4SDimitry Andrictemplate <ranges::input_range _Range, 765fe013be4SDimitry Andric class _Compare, 766fe013be4SDimitry Andric class _Alloc, 767fe013be4SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 768fe013be4SDimitry Andric class = enable_if_t<__is_allocator<_Alloc>::value>> 769fe013be4SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc) 770e710425bSDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>; 771fe013be4SDimitry Andric 772e710425bSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>> 773fe013be4SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc) 774fe013be4SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; 775fe013be4SDimitry Andric 776fe013be4SDimitry Andric#endif 777fe013be4SDimitry Andric 7780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 779e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) 780e710425bSDimitry Andric : c(__c), comp(__comp) { 781c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 7820b57cec5SDimitry Andric} 7830b57cec5SDimitry Andric 7840b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 7850b57cec5SDimitry Andric 7860b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 787e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c) 788e710425bSDimitry Andric : c(std::move(__c)), comp(__comp) { 789c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 7900b57cec5SDimitry Andric} 7910b57cec5SDimitry Andric 7920b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 7930b57cec5SDimitry Andric 7940b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 795349cc55cSDimitry Andrictemplate <class _InputIter, class> 796e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 797e710425bSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp) 798e710425bSDimitry Andric : c(__f, __l), comp(__comp) { 799c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8000b57cec5SDimitry Andric} 8010b57cec5SDimitry Andric 8020b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 803349cc55cSDimitry Andrictemplate <class _InputIter, class> 804e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 805e710425bSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) 806e710425bSDimitry Andric : c(__c), comp(__comp) { 8070b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 808c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8090b57cec5SDimitry Andric} 8100b57cec5SDimitry Andric 8110b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8120b57cec5SDimitry Andric 8130b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 814349cc55cSDimitry Andrictemplate <class _InputIter, class> 815e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 816e710425bSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) 817e710425bSDimitry Andric : c(std::move(__c)), comp(__comp) { 8180b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 819c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8200b57cec5SDimitry Andric} 8210b57cec5SDimitry Andric 8220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 8230b57cec5SDimitry Andric 8240b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8250b57cec5SDimitry Andrictemplate <class _Alloc> 826e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 827e710425bSDimitry Andric const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 828e710425bSDimitry Andric : c(__a) {} 8290b57cec5SDimitry Andric 8300b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8310b57cec5SDimitry Andrictemplate <class _Alloc> 832e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 833e710425bSDimitry Andric const value_compare& __comp, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 834e710425bSDimitry Andric : c(__a), comp(__comp) {} 8350b57cec5SDimitry Andric 8360b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8370b57cec5SDimitry Andrictemplate <class _Alloc> 838e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 839e710425bSDimitry Andric const value_compare& __comp, 8400b57cec5SDimitry Andric const container_type& __c, 8410b57cec5SDimitry Andric const _Alloc& __a, 842349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 843e710425bSDimitry Andric : c(__c, __a), comp(__comp) { 844c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8450b57cec5SDimitry Andric} 8460b57cec5SDimitry Andric 8470b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8480b57cec5SDimitry Andrictemplate <class _Alloc> 849e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 850e710425bSDimitry Andric const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 851e710425bSDimitry Andric : c(__q.c, __a), comp(__q.comp) {} 8520b57cec5SDimitry Andric 8530b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8540b57cec5SDimitry Andric 8550b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8560b57cec5SDimitry Andrictemplate <class _Alloc> 857e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 858e710425bSDimitry Andric const value_compare& __comp, 8590b57cec5SDimitry Andric container_type&& __c, 8600b57cec5SDimitry Andric const _Alloc& __a, 861349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 862e710425bSDimitry Andric : c(std::move(__c), __a), comp(__comp) { 863c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8640b57cec5SDimitry Andric} 8650b57cec5SDimitry Andric 8660b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8670b57cec5SDimitry Andrictemplate <class _Alloc> 868e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 869e710425bSDimitry Andric priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 870e710425bSDimitry Andric : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} 871349cc55cSDimitry Andric 872349cc55cSDimitry Andric#endif // _LIBCPP_CXX03_LANG 873349cc55cSDimitry Andric 874349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 875349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 876e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 877e710425bSDimitry Andric _InputIter __f, _InputIter __l, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 878e710425bSDimitry Andric : c(__f, __l, __a), comp() { 879c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 8800b57cec5SDimitry Andric} 8810b57cec5SDimitry Andric 882349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 883349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 884e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 885e710425bSDimitry Andric _InputIter __f, 886e710425bSDimitry Andric _InputIter __l, 887e710425bSDimitry Andric const value_compare& __comp, 888e710425bSDimitry Andric const _Alloc& __a, 889349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 890e710425bSDimitry Andric : c(__f, __l, __a), comp(__comp) { 891c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 892349cc55cSDimitry Andric} 893349cc55cSDimitry Andric 894349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 895349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 896e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 897e710425bSDimitry Andric _InputIter __f, 898e710425bSDimitry Andric _InputIter __l, 899e710425bSDimitry Andric const value_compare& __comp, 900e710425bSDimitry Andric const container_type& __c, 901e710425bSDimitry Andric const _Alloc& __a, 902349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 903e710425bSDimitry Andric : c(__c, __a), comp(__comp) { 904349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 905c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 906349cc55cSDimitry Andric} 907349cc55cSDimitry Andric 908349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 909349cc55cSDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 910349cc55cSDimitry Andrictemplate <class _InputIter, class _Alloc, class> 911e710425bSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 912e710425bSDimitry Andric _InputIter __f, 913e710425bSDimitry Andric _InputIter __l, 914e710425bSDimitry Andric const value_compare& __comp, 915e710425bSDimitry Andric container_type&& __c, 916e710425bSDimitry Andric const _Alloc& __a, 917349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 918e710425bSDimitry Andric : c(std::move(__c), __a), comp(__comp) { 919349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 920c9157d92SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 921349cc55cSDimitry Andric} 9220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 9230b57cec5SDimitry Andric 9240b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 925e710425bSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { 9260b57cec5SDimitry Andric c.push_back(__v); 927c9157d92SDimitry Andric std::push_heap(c.begin(), c.end(), comp); 9280b57cec5SDimitry Andric} 9290b57cec5SDimitry Andric 9300b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9310b57cec5SDimitry Andric 9320b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 933e710425bSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { 934c9157d92SDimitry Andric c.push_back(std::move(__v)); 935c9157d92SDimitry Andric std::push_heap(c.begin(), c.end(), comp); 9360b57cec5SDimitry Andric} 9370b57cec5SDimitry Andric 9380b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 9390b57cec5SDimitry Andrictemplate <class... _Args> 940e710425bSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) { 941c9157d92SDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 942c9157d92SDimitry Andric std::push_heap(c.begin(), c.end(), comp); 9430b57cec5SDimitry Andric} 9440b57cec5SDimitry Andric 9450b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 9460b57cec5SDimitry Andric 9470b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 948e710425bSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::pop() { 949c9157d92SDimitry Andric std::pop_heap(c.begin(), c.end(), comp); 9500b57cec5SDimitry Andric c.pop_back(); 9510b57cec5SDimitry Andric} 9520b57cec5SDimitry Andric 9530b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 954e710425bSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 955e710425bSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) { 956c9157d92SDimitry Andric using std::swap; 9570b57cec5SDimitry Andric swap(c, __q.c); 9580b57cec5SDimitry Andric swap(comp, __q.comp); 9590b57cec5SDimitry Andric} 9600b57cec5SDimitry Andric 961e710425bSDimitry Andrictemplate <class _Tp, 962e710425bSDimitry Andric class _Container, 963e710425bSDimitry Andric class _Compare, 964c9157d92SDimitry Andric __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0> 965e710425bSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 966e710425bSDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) 967e710425bSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { 9680b57cec5SDimitry Andric __x.swap(__y); 9690b57cec5SDimitry Andric} 9700b57cec5SDimitry Andric 9710b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare, class _Alloc> 9720b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 973e710425bSDimitry Andric : public uses_allocator<_Container, _Alloc> {}; 9740b57cec5SDimitry Andric 9750b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 9760b57cec5SDimitry Andric 977*b9d9368bSDimitry Andric_LIBCPP_POP_MACROS 978*b9d9368bSDimitry Andric 979bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 980bdd1243dSDimitry Andric# include <concepts> 981fe013be4SDimitry Andric# include <cstdlib> 982bdd1243dSDimitry Andric# include <functional> 983fe013be4SDimitry Andric# include <type_traits> 984bdd1243dSDimitry Andric#endif 985bdd1243dSDimitry Andric 9860b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE 987