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 286b3edf446SDimitry Andric_LIBCPP_PUSH_MACROS 287b3edf446SDimitry Andric#include <__undef_macros> 288b3edf446SDimitry Andric 2890b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 2900b57cec5SDimitry Andric 291cb14a3feSDimitry Andrictemplate <class _Tp, class _Container = deque<_Tp> > 292cb14a3feSDimitry Andricclass _LIBCPP_TEMPLATE_VIS queue; 2930b57cec5SDimitry Andric 2940b57cec5SDimitry Andrictemplate <class _Tp, class _Container> 295cb14a3feSDimitry 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> 298cb14a3feSDimitry 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>*/> 301cb14a3feSDimitry 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: 314cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue() _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) : c() {} 3150b57cec5SDimitry Andric 316cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} 3170b57cec5SDimitry Andric 31806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 319cb14a3feSDimitry Andric template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 320cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} 32104eeddc0SDimitry Andric 32206c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 323cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {} 32406c3fb27SDimitry Andric 32504eeddc0SDimitry Andric template <class _InputIterator, 32604eeddc0SDimitry Andric class _Alloc, 32706c3fb27SDimitry Andric class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 32804eeddc0SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 329cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) 330cb14a3feSDimitry Andric : c(__first, __second, __alloc) {} 33106c3fb27SDimitry Andric 33206c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 33306c3fb27SDimitry Andric class _Alloc, 33406c3fb27SDimitry Andric class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> 335cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) 33606c3fb27SDimitry Andric : c(from_range, std::forward<_Range>(__range), __alloc) {} 33706c3fb27SDimitry Andric 33804eeddc0SDimitry Andric#endif 33904eeddc0SDimitry Andric 340cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) { 341cb14a3feSDimitry Andric c = __q.c; 342cb14a3feSDimitry Andric return *this; 343cb14a3feSDimitry Andric } 3440b57cec5SDimitry Andric 3450b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 346cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 3475f757f3fSDimitry Andric : c(std::move(__q.c)) {} 3480b57cec5SDimitry Andric 349cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) { 350cb14a3feSDimitry Andric c = std::move(__q.c); 351cb14a3feSDimitry Andric return *this; 352cb14a3feSDimitry Andric } 3530b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3540b57cec5SDimitry Andric 355cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {} 3560b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 357cb14a3feSDimitry 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> 360cb14a3feSDimitry 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> 3645f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 365cb14a3feSDimitry 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> 3685f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 369cb14a3feSDimitry 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> 3735f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 374cb14a3feSDimitry Andric queue(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3755f757f3fSDimitry Andric : c(std::move(__c), __a) {} 3760b57cec5SDimitry Andric template <class _Alloc> 3775f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 378cb14a3feSDimitry Andric queue(queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) 3795f757f3fSDimitry Andric : c(std::move(__q.c), __a) {} 3800b57cec5SDimitry Andric 3810b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3820b57cec5SDimitry Andric 383cb14a3feSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } 384cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } 3850b57cec5SDimitry Andric 386cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } 387cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); } 388cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); } 389cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } 3900b57cec5SDimitry Andric 391cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } 3920b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 393cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } 39406c3fb27SDimitry Andric 39506c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 23 39606c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 397cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { 398cb14a3feSDimitry Andric if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { 39906c3fb27SDimitry Andric c.append_range(std::forward<_Range>(__range)); 40006c3fb27SDimitry Andric } else { 40106c3fb27SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 40206c3fb27SDimitry Andric } 40306c3fb27SDimitry Andric } 40406c3fb27SDimitry Andric# endif 40506c3fb27SDimitry Andric 4060b57cec5SDimitry Andric template <class... _Args> 4075f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 40806c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 17 409cb14a3feSDimitry Andric decltype(auto) 410cb14a3feSDimitry Andric emplace(_Args&&... __args) { 411cb14a3feSDimitry Andric return c.emplace_back(std::forward<_Args>(__args)...); 412cb14a3feSDimitry Andric } 4130b57cec5SDimitry Andric# else 414cb14a3feSDimitry Andric void 415cb14a3feSDimitry Andric emplace(_Args&&... __args) { 416cb14a3feSDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 417cb14a3feSDimitry Andric } 4180b57cec5SDimitry Andric# endif 4190b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 420cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } 4210b57cec5SDimitry Andric 422cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) { 4235f757f3fSDimitry 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 42906c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 430cb14a3feSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 43106c3fb27SDimitry Andric operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); 4320b57cec5SDimitry Andric 43306c3fb27SDimitry Andric template <class _T1, class _OtherContainer> 434cb14a3feSDimitry Andric friend _LIBCPP_HIDE_FROM_ABI bool 43506c3fb27SDimitry Andric operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); 4360b57cec5SDimitry Andric}; 4370b57cec5SDimitry Andric 43806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 17 439cb14a3feSDimitry Andrictemplate <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > 440cb14a3feSDimitry 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>, 445cb14a3feSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 446cb14a3feSDimitry Andricqueue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; 4470b57cec5SDimitry Andric#endif 4480b57cec5SDimitry Andric 44906c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 450cb14a3feSDimitry Andrictemplate <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>> 451cb14a3feSDimitry Andricqueue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; 45204eeddc0SDimitry Andric 45306c3fb27SDimitry Andrictemplate <ranges::input_range _Range> 454cb14a3feSDimitry Andricqueue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>; 45506c3fb27SDimitry Andric 45604eeddc0SDimitry Andrictemplate <class _InputIterator, 45704eeddc0SDimitry Andric class _Alloc, 45806c3fb27SDimitry 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>>; 46206c3fb27SDimitry Andric 463cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>> 46406c3fb27SDimitry Andricqueue(from_range_t, _Range&&, _Alloc) 46506c3fb27SDimitry 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> 469cb14a3feSDimitry 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> 474cb14a3feSDimitry 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> 479cb14a3feSDimitry 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> 484cb14a3feSDimitry 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> 489cb14a3feSDimitry 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> 494cb14a3feSDimitry 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 49806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 20 49906c3fb27SDimitry Andric 50006c3fb27SDimitry Andrictemplate <class _Tp, three_way_comparable _Container> 50106c3fb27SDimitry Andric_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> 50206c3fb27SDimitry Andricoperator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { 50306c3fb27SDimitry Andric // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors 50406c3fb27SDimitry Andric return __x.__get_container() <=> __y.__get_container(); 50506c3fb27SDimitry Andric} 50606c3fb27SDimitry Andric 50706c3fb27SDimitry Andric#endif 50806c3fb27SDimitry Andric 5095f757f3fSDimitry Andrictemplate <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> 510cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 511cb14a3feSDimitry Andric _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { 5120b57cec5SDimitry Andric __x.swap(__y); 5130b57cec5SDimitry Andric} 5140b57cec5SDimitry Andric 5150b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Alloc> 516cb14a3feSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { 5170b57cec5SDimitry Andric}; 5180b57cec5SDimitry Andric 519cb14a3feSDimitry Andrictemplate <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > 520cb14a3feSDimitry 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: 535cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_( 536cb14a3feSDimitry Andric is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value) 5370b57cec5SDimitry Andric : c(), comp() {} 5380b57cec5SDimitry Andric 539cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 5400b57cec5SDimitry Andric 541cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) { 542cb14a3feSDimitry Andric c = __q.c; 543cb14a3feSDimitry Andric comp = __q.comp; 544cb14a3feSDimitry Andric return *this; 545cb14a3feSDimitry Andric } 5460b57cec5SDimitry Andric 5470b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 548cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_( 549cb14a3feSDimitry Andric is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value) 5505f757f3fSDimitry Andric : c(std::move(__q.c)), comp(std::move(__q.comp)) {} 5510b57cec5SDimitry Andric 552cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) 553cb14a3feSDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) { 554cb14a3feSDimitry Andric c = std::move(__q.c); 555cb14a3feSDimitry Andric comp = std::move(__q.comp); 556cb14a3feSDimitry Andric return *this; 557cb14a3feSDimitry Andric } 5580b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 5590b57cec5SDimitry Andric 560cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} 561cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); 5620b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 563cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); 5640b57cec5SDimitry Andric#endif 56506c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 566cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); 56706c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 5685f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 569cb14a3feSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); 5700b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 57106c3fb27SDimitry Andric template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 5725f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 573cb14a3feSDimitry Andric priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); 5740b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 57506c3fb27SDimitry Andric 57606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 57706c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 578cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) 579cb14a3feSDimitry Andric : c(from_range, std::forward<_Range>(__range)), comp(__comp) { 58006c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 58106c3fb27SDimitry Andric } 58206c3fb27SDimitry Andric#endif 58306c3fb27SDimitry Andric 5840b57cec5SDimitry Andric template <class _Alloc> 585cb14a3feSDimitry 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> 5885f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 589cb14a3feSDimitry 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> 5935f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 594cb14a3feSDimitry Andric priority_queue(const value_compare& __comp, 595cb14a3feSDimitry Andric const container_type& __c, 596cb14a3feSDimitry Andric const _Alloc& __a, 597349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 598cb14a3feSDimitry Andric template <class _Alloc> 599cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 600cb14a3feSDimitry 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> 6035f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 604cb14a3feSDimitry Andric priority_queue(const value_compare& __comp, 605cb14a3feSDimitry 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> 609cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 610cb14a3feSDimitry 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 61306c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 6145f757f3fSDimitry Andric _LIBCPP_HIDE_FROM_ABI 615cb14a3feSDimitry Andric priority_queue(_InputIter __f, 616cb14a3feSDimitry Andric _InputIter __l, 617cb14a3feSDimitry Andric const _Alloc& __a, 618349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 619349cc55cSDimitry Andric 62006c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 621cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 622cb14a3feSDimitry Andric _InputIter __f, 623cb14a3feSDimitry Andric _InputIter __l, 624cb14a3feSDimitry Andric const value_compare& __comp, 625cb14a3feSDimitry Andric const _Alloc& __a, 626349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 627349cc55cSDimitry Andric 62806c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 629cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 630cb14a3feSDimitry Andric _InputIter __f, 631cb14a3feSDimitry Andric _InputIter __l, 632cb14a3feSDimitry Andric const value_compare& __comp, 633cb14a3feSDimitry Andric const container_type& __c, 634cb14a3feSDimitry Andric const _Alloc& __a, 635349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 636349cc55cSDimitry Andric 637349cc55cSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 63806c3fb27SDimitry Andric template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> > 639cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue( 640cb14a3feSDimitry Andric _InputIter __f, 641cb14a3feSDimitry Andric _InputIter __l, 642cb14a3feSDimitry Andric const value_compare& __comp, 643cb14a3feSDimitry Andric container_type&& __c, 644cb14a3feSDimitry Andric const _Alloc& __a, 645349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); 6460b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 6470b57cec5SDimitry Andric 64806c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 64906c3fb27SDimitry Andric 65006c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 65106c3fb27SDimitry Andric class _Alloc, 65206c3fb27SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 653cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a) 654cb14a3feSDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) { 65506c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 65606c3fb27SDimitry Andric } 65706c3fb27SDimitry Andric 65806c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range, 65906c3fb27SDimitry Andric class _Alloc, 66006c3fb27SDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value>> 661cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a) 662cb14a3feSDimitry Andric : c(from_range, std::forward<_Range>(__range), __a), comp() { 66306c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 66406c3fb27SDimitry Andric } 66506c3fb27SDimitry Andric 66606c3fb27SDimitry Andric#endif 66706c3fb27SDimitry Andric 668cb14a3feSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } 669cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } 670cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } 6710b57cec5SDimitry Andric 672cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); 6730b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 674cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); 67506c3fb27SDimitry Andric 67606c3fb27SDimitry Andric# if _LIBCPP_STD_VER >= 23 67706c3fb27SDimitry Andric template <_ContainerCompatibleRange<_Tp> _Range> 678cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { 679cb14a3feSDimitry Andric if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { 68006c3fb27SDimitry Andric c.append_range(std::forward<_Range>(__range)); 68106c3fb27SDimitry Andric } else { 68206c3fb27SDimitry Andric ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); 68306c3fb27SDimitry Andric } 68406c3fb27SDimitry Andric 68506c3fb27SDimitry Andric std::make_heap(c.begin(), c.end(), comp); 68606c3fb27SDimitry Andric } 68706c3fb27SDimitry Andric# endif 68806c3fb27SDimitry Andric 6890b57cec5SDimitry Andric template <class... _Args> 690cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); 6910b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 692cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void pop(); 6930b57cec5SDimitry Andric 694cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) 695cb14a3feSDimitry 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>, 704cb14a3feSDimitry Andric class = enable_if_t<!__is_allocator<_Container>::value> > 705cb14a3feSDimitry 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>>, 71006c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 711349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 712cb14a3feSDimitry 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>, 721cb14a3feSDimitry Andric class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > 722cb14a3feSDimitry Andricpriority_queue(_Compare, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Compare>; 723349cc55cSDimitry Andric 724cb14a3feSDimitry Andrictemplate <class _InputIterator, 725cb14a3feSDimitry Andric class _Allocator, 72606c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 727cb14a3feSDimitry 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 733cb14a3feSDimitry Andrictemplate <class _InputIterator, 734cb14a3feSDimitry Andric class _Compare, 735cb14a3feSDimitry Andric class _Allocator, 73606c3fb27SDimitry Andric class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, 737349cc55cSDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 738cb14a3feSDimitry Andric class = enable_if_t<__is_allocator<_Allocator>::value> > 739349cc55cSDimitry Andricpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 740349cc55cSDimitry Andric -> priority_queue<__iter_value_type<_InputIterator>, 741cb14a3feSDimitry Andric vector<__iter_value_type<_InputIterator>, _Allocator>, 742cb14a3feSDimitry Andric _Compare>; 743349cc55cSDimitry Andric 744cb14a3feSDimitry Andrictemplate <class _InputIterator, 745cb14a3feSDimitry Andric class _Compare, 746cb14a3feSDimitry Andric class _Container, 747cb14a3feSDimitry Andric class _Alloc, 74806c3fb27SDimitry 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>, 751cb14a3feSDimitry 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 75606c3fb27SDimitry Andric#if _LIBCPP_STD_VER >= 23 75706c3fb27SDimitry Andric 75806c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 75906c3fb27SDimitry Andric class _Compare = less<ranges::range_value_t<_Range>>, 76006c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>> 76106c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare = _Compare()) 76206c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>; 76306c3fb27SDimitry Andric 76406c3fb27SDimitry Andrictemplate <ranges::input_range _Range, 76506c3fb27SDimitry Andric class _Compare, 76606c3fb27SDimitry Andric class _Alloc, 76706c3fb27SDimitry Andric class = enable_if_t<!__is_allocator<_Compare>::value>, 76806c3fb27SDimitry Andric class = enable_if_t<__is_allocator<_Alloc>::value>> 76906c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Compare, _Alloc) 770cb14a3feSDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>, _Compare>; 77106c3fb27SDimitry Andric 772cb14a3feSDimitry Andrictemplate <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_allocator<_Alloc>::value>> 77306c3fb27SDimitry Andricpriority_queue(from_range_t, _Range&&, _Alloc) 77406c3fb27SDimitry Andric -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; 77506c3fb27SDimitry Andric 77606c3fb27SDimitry Andric#endif 77706c3fb27SDimitry Andric 7780b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 779cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) 780cb14a3feSDimitry Andric : c(__c), comp(__comp) { 7815f757f3fSDimitry 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> 787cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c) 788cb14a3feSDimitry Andric : c(std::move(__c)), comp(__comp) { 7895f757f3fSDimitry 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> 796cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 797cb14a3feSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp) 798cb14a3feSDimitry Andric : c(__f, __l), comp(__comp) { 7995f757f3fSDimitry 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> 804cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 805cb14a3feSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) 806cb14a3feSDimitry Andric : c(__c), comp(__comp) { 8070b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 8085f757f3fSDimitry 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> 815cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 816cb14a3feSDimitry Andric _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c) 817cb14a3feSDimitry Andric : c(std::move(__c)), comp(__comp) { 8180b57cec5SDimitry Andric c.insert(c.end(), __f, __l); 8195f757f3fSDimitry 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> 826cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 827cb14a3feSDimitry Andric const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 828cb14a3feSDimitry Andric : c(__a) {} 8290b57cec5SDimitry Andric 8300b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8310b57cec5SDimitry Andrictemplate <class _Alloc> 832cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 833cb14a3feSDimitry Andric const value_compare& __comp, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 834cb14a3feSDimitry Andric : c(__a), comp(__comp) {} 8350b57cec5SDimitry Andric 8360b57cec5SDimitry Andrictemplate <class _Tp, class _Container, class _Compare> 8370b57cec5SDimitry Andrictemplate <class _Alloc> 838cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 839cb14a3feSDimitry 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>*) 843cb14a3feSDimitry Andric : c(__c, __a), comp(__comp) { 8445f757f3fSDimitry 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> 849cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 850cb14a3feSDimitry Andric const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 851cb14a3feSDimitry 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> 857cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 858cb14a3feSDimitry 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>*) 862cb14a3feSDimitry Andric : c(std::move(__c), __a), comp(__comp) { 8635f757f3fSDimitry 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> 868cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 869cb14a3feSDimitry Andric priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 870cb14a3feSDimitry 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> 876cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 877cb14a3feSDimitry Andric _InputIter __f, _InputIter __l, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 878cb14a3feSDimitry Andric : c(__f, __l, __a), comp() { 8795f757f3fSDimitry 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> 884cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 885cb14a3feSDimitry Andric _InputIter __f, 886cb14a3feSDimitry Andric _InputIter __l, 887cb14a3feSDimitry Andric const value_compare& __comp, 888cb14a3feSDimitry Andric const _Alloc& __a, 889349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 890cb14a3feSDimitry Andric : c(__f, __l, __a), comp(__comp) { 8915f757f3fSDimitry 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> 896cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 897cb14a3feSDimitry Andric _InputIter __f, 898cb14a3feSDimitry Andric _InputIter __l, 899cb14a3feSDimitry Andric const value_compare& __comp, 900cb14a3feSDimitry Andric const container_type& __c, 901cb14a3feSDimitry Andric const _Alloc& __a, 902349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 903cb14a3feSDimitry Andric : c(__c, __a), comp(__comp) { 904349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 9055f757f3fSDimitry 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> 911cb14a3feSDimitry Andricinline priority_queue<_Tp, _Container, _Compare>::priority_queue( 912cb14a3feSDimitry Andric _InputIter __f, 913cb14a3feSDimitry Andric _InputIter __l, 914cb14a3feSDimitry Andric const value_compare& __comp, 915cb14a3feSDimitry Andric container_type&& __c, 916cb14a3feSDimitry Andric const _Alloc& __a, 917349cc55cSDimitry Andric __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) 918cb14a3feSDimitry Andric : c(std::move(__c), __a), comp(__comp) { 919349cc55cSDimitry Andric c.insert(c.end(), __f, __l); 9205f757f3fSDimitry 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> 925cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { 9260b57cec5SDimitry Andric c.push_back(__v); 9275f757f3fSDimitry 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> 933cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { 9345f757f3fSDimitry Andric c.push_back(std::move(__v)); 9355f757f3fSDimitry 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> 940cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) { 9415f757f3fSDimitry Andric c.emplace_back(std::forward<_Args>(__args)...); 9425f757f3fSDimitry 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> 948cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::pop() { 9495f757f3fSDimitry 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> 954cb14a3feSDimitry Andricinline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 955cb14a3feSDimitry Andric _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) { 9565f757f3fSDimitry Andric using std::swap; 9570b57cec5SDimitry Andric swap(c, __q.c); 9580b57cec5SDimitry Andric swap(comp, __q.comp); 9590b57cec5SDimitry Andric} 9600b57cec5SDimitry Andric 961cb14a3feSDimitry Andrictemplate <class _Tp, 962cb14a3feSDimitry Andric class _Container, 963cb14a3feSDimitry Andric class _Compare, 9645f757f3fSDimitry Andric __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0> 965cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void 966cb14a3feSDimitry Andricswap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) 967cb14a3feSDimitry 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> 973cb14a3feSDimitry Andric : public uses_allocator<_Container, _Alloc> {}; 9740b57cec5SDimitry Andric 9750b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 9760b57cec5SDimitry Andric 977b3edf446SDimitry Andric_LIBCPP_POP_MACROS 978b3edf446SDimitry Andric 979bdd1243dSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 980bdd1243dSDimitry Andric# include <concepts> 98106c3fb27SDimitry Andric# include <cstdlib> 982bdd1243dSDimitry Andric# include <functional> 98306c3fb27SDimitry Andric# include <type_traits> 984bdd1243dSDimitry Andric#endif 985bdd1243dSDimitry Andric 9860b57cec5SDimitry Andric#endif // _LIBCPP_QUEUE 987