This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

91
cppdraft/priqueue/cons.md Normal file
View File

@@ -0,0 +1,91 @@
[priqueue.cons]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#priqueue.cons)
### 23.6.4 Class template priority_queue [[priority.queue]](priority.queue#priqueue.cons)
#### 23.6.4.2 Constructors [priqueue.cons]
[🔗](#lib:priority_queue,constructor)
`constexpr priority_queue(const Compare& x, const Container& y);
constexpr priority_queue(const Compare& x, Container&& y);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16141)
*Preconditions*: x defines a strict weak ordering ([[alg.sorting]](alg.sorting "26.8Sorting and related operations"))[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16145)
*Effects*: Initializescomp withx andc withy (copy constructing or move constructing as appropriate);
callsmake_heap(c.begin(), c.end(), comp)[.](#2.sentence-1)
[🔗](#lib:priority_queue,constructor_)
`template<class InputIterator>
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16163)
*Preconditions*: x defines a strict weak ordering ([[alg.sorting]](alg.sorting "26.8Sorting and related operations"))[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16167)
*Effects*: Initializes c withfirst as the first argument andlast as the second argument, and
initializes comp with x;
then calls make_heap(c.begin(), c.end(), comp)[.](#4.sentence-1)
[🔗](#lib:priority_queue,constructor__)
`template<class InputIterator>
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
const Container& y);
template<class InputIterator>
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
Container&& y);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16187)
*Preconditions*: x defines a strict weak ordering ([[alg.sorting]](alg.sorting "26.8Sorting and related operations"))[.](#5.sentence-1)
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16191)
*Effects*: Initializescomp withx andc withy (copy constructing or move constructing as appropriate);
callsc.insert(c.end(), first, last);
and finally callsmake_heap(c.begin(), c.end(), comp)[.](#6.sentence-1)
[🔗](#lib:priority_queue,constructor___)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr priority_queue(from_range_t, R&& rg, const Compare& x = Compare());
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16211)
*Preconditions*: x defines a strict weak ordering ([[alg.sorting]](alg.sorting "26.8Sorting and related operations"))[.](#7.sentence-1)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16215)
*Effects*: Initializes comp with x andc with ranges::to<Container>(std::forward<R>(rg)) and
finally calls make_heap(c.begin(), c.end(), comp)[.](#8.sentence-1)

View File

@@ -0,0 +1,174 @@
[priqueue.cons.alloc]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#priqueue.cons.alloc)
### 23.6.4 Class template priority_queue [[priority.queue]](priority.queue#priqueue.cons.alloc)
#### 23.6.4.3 Constructors with allocators [priqueue.cons.alloc]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16224)
If uses_allocator_v<container_type, Alloc> is false the constructors in this subclause shall not participate in overload resolution[.](#1.sentence-1)
[🔗](#lib:priority_queue,constructor)
`template<class Alloc> constexpr explicit priority_queue(const Alloc& a);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16234)
*Effects*: Initializes c with a and value-initializes comp[.](#2.sentence-1)
[🔗](#lib:priority_queue,constructor_)
`template<class Alloc> constexpr priority_queue(const Compare& compare, const Alloc& a);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16245)
*Effects*: Initializes c with a and initializes comp with compare[.](#3.sentence-1)
[🔗](#lib:priority_queue,constructor__)
`template<class Alloc>
constexpr priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16257)
*Effects*: Initializes c with cont as the first argument and a as the second
argument, and initializes comp with compare;
calls make_heap(c.begin(), c.end(), comp)[.](#4.sentence-1)
[🔗](#lib:priority_queue,constructor___)
`template<class Alloc>
constexpr priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16271)
*Effects*: Initializes c with std::move(cont) as the first argument and a as the second argument, and initializes comp with compare;
calls make_heap(c.begin(), c.end(), comp)[.](#5.sentence-1)
[🔗](#lib:priority_queue,constructor____)
`template<class Alloc> constexpr priority_queue(const priority_queue& q, const Alloc& a);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16284)
*Effects*: Initializes c with q.c as the first argument and a as
the second argument, and initializes comp with q.comp[.](#6.sentence-1)
[🔗](#lib:priority_queue,constructor_____)
`template<class Alloc> constexpr priority_queue(priority_queue&& q, const Alloc& a);
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16296)
*Effects*: Initializes c with std::move(q.c) as the first argument and a as the second argument, and initializes comp with std::move(q.comp)[.](#7.sentence-1)
[🔗](#lib:priority_queue,constructor______)
`template<class InputIterator, class Alloc>
constexpr priority_queue(InputIterator first, InputIterator last, const Alloc& a);
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16309)
*Effects*: Initializes c withfirst as the first argument,last as the second argument, anda as the third argument, and
value-initializes comp;
calls make_heap(c.begin(), c.end(), comp)[.](#8.sentence-1)
[🔗](#lib:priority_queue,constructor_______)
`template<class InputIterator, class Alloc>
constexpr priority_queue(InputIterator first, InputIterator last,
const Compare& compare, const Alloc& a);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16327)
*Effects*: Initializes c withfirst as the first argument,last as the second argument, anda as the third argument, and
initializes comp with compare;
calls make_heap(c.begin(), c.end(), comp)[.](#9.sentence-1)
[🔗](#lib:priority_queue,constructor________)
`template<class InputIterator, class Alloc>
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& compare,
const Container& cont, const Alloc& a);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16345)
*Effects*: Initializes c withcont as the first argument and a as the second argument, and
initializes comp with compare;
calls c.insert(c.end(), first, last); and
finally calls make_heap(c.begin(), c.end(), comp)[.](#10.sentence-1)
[🔗](#lib:priority_queue,constructor_________)
`template<class InputIterator, class Alloc>
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& compare,
Container&& cont, const Alloc& a);
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16362)
*Effects*: Initializes c withstd::move(cont) as the first argument anda as the second argument, and
initializes comp with compare;
calls c.insert(c.end(), first, last); and
finally calls make_heap(c.begin(), c.end(), comp)[.](#11.sentence-1)
[🔗](#lib:priority_queue,constructor__________)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R, class Alloc>
constexpr priority_queue(from_range_t, R&& rg, const Compare& compare, const Alloc& a);
`
[12](#12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16379)
*Effects*: Initializes comp with compare andc with ranges::to<Container>(std::forward<R>(rg), a);
calls make_heap(c.begin(), c.end(), comp)[.](#12.sentence-1)
[🔗](#lib:priority_queue,constructor___________)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R, class Alloc>
constexpr priority_queue(from_range_t, R&& rg, const Alloc& a);
`
[13](#13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16393)
*Effects*: Initializesc with ranges::to<Container>(std::forward<R>(rg), a) and value-initializes comp;
calls make_heap(c.begin(), c.end(), comp)[.](#13.sentence-1)

View File

@@ -0,0 +1,77 @@
[priqueue.members]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#priqueue.members)
### 23.6.4 Class template priority_queue [[priority.queue]](priority.queue#priqueue.members)
#### 23.6.4.4 Members [priqueue.members]
[🔗](#lib:push,priority_queue)
`constexpr void push(const value_type& x);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16409)
*Effects*: As if by:c.push_back(x);
push_heap(c.begin(), c.end(), comp);
[🔗](#lib:push,priority_queue_)
`constexpr void push(value_type&& x);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16424)
*Effects*: As if by:c.push_back(std::move(x));
push_heap(c.begin(), c.end(), comp);
[🔗](#lib:push_range,priority_queue)
`template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>
constexpr void push_range(R&& rg);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16440)
*Effects*: Inserts all elements of rg in c viac.append_range(std::forward<R>(rg)) if that is a valid expression, orranges::copy(rg, back_inserter(c)) otherwise[.](#3.sentence-1)
Then restores the heap property as if bymake_heap(c.begin(), c.end(), comp)[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16448)
*Postconditions*: is_heap(c.begin(), c.end(), comp) is true[.](#4.sentence-1)
[🔗](#lib:emplace,priority_queue)
`template<class... Args> constexpr void emplace(Args&&... args);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16459)
*Effects*: As if by:c.emplace_back(std::forward<Args>(args)...);
push_heap(c.begin(), c.end(), comp);
[🔗](#lib:pop,priority_queue)
`constexpr void pop();
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16474)
*Effects*: As if by:pop_heap(c.begin(), c.end(), comp);
c.pop_back();

View File

@@ -0,0 +1,29 @@
[priqueue.overview]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#priqueue.overview)
### 23.6.4 Class template priority_queue [[priority.queue]](priority.queue#priqueue.overview)
#### 23.6.4.1 Overview [priqueue.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15993)
Any sequence container with random access iterator and supporting operationsfront(),push_back() andpop_back() can be used to instantiatepriority_queue[.](#1.sentence-1)
In particular,<vector> and<deque> can be used[.](#1.sentence-2)
Instantiatingpriority_queue also involves supplying a function or function object for making
priority comparisons; the library assumes that the function or function
object defines a [strict weak ordering](alg.sorting "26.8Sorting and related operations[alg.sorting]")[.](#1.sentence-3)
namespace std {template<class T, class Container = vector<T>, class Compare = less<typename Container::value_type>>class priority_queue {public:using value_type = typename Container::value_type; using reference = typename Container::reference; using const_reference = typename Container::const_reference; using size_type = typename Container::size_type; using container_type = Container; using value_compare = Compare; protected: Container c;
Compare comp; public:constexpr priority_queue() : priority_queue(Compare()) {}constexpr explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}constexpr priority_queue(const Compare& x, const Container&); constexpr priority_queue(const Compare& x, Container&&); template<class InputIterator>constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare()); template<class InputIterator>constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x, const Container&); template<class InputIterator>constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
Container&&); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); template<class Alloc> constexpr explicit priority_queue(const Alloc&); template<class Alloc> constexpr priority_queue(const Compare&, const Alloc&); template<class Alloc>constexpr priority_queue(const Compare&, const Container&, const Alloc&); template<class Alloc> constexpr priority_queue(const Compare&, Container&&, const Alloc&); template<class Alloc> constexpr priority_queue(const priority_queue&, const Alloc&); template<class Alloc> constexpr priority_queue(priority_queue&&, const Alloc&); template<class InputIterator, class Alloc>constexpr priority_queue(InputIterator, InputIterator, const Alloc&); template<class InputIterator, class Alloc>constexpr priority_queue(InputIterator, InputIterator, const Compare&, const Alloc&); template<class InputIterator, class Alloc>constexpr priority_queue(InputIterator, InputIterator, const Compare&, const Container&, const Alloc&); template<class InputIterator, class Alloc>constexpr priority_queue(InputIterator, InputIterator, const Compare&, Container&&, const Alloc&); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R, class Alloc>constexpr priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R, class Alloc>constexpr priority_queue(from_range_t, R&& rg, const Alloc&); constexpr bool empty() const { return c.empty(); }constexpr size_type size() const { return c.size(); }constexpr const_reference top() const { return c.front(); }constexpr void push(const value_type& x); constexpr void push(value_type&& x); template<[*container-compatible-range*](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R>constexpr void push_range(R&& rg); template<class... Args> constexpr void emplace(Args&&... args); constexpr void pop(); constexpr void swap(priority_queue& q)noexcept(is_nothrow_swappable_v<Container> && is_nothrow_swappable_v<Compare>){ using std::swap; swap(c, q.c); swap(comp, q.comp); }}; template<class Compare, class Container> priority_queue(Compare, Container)-> priority_queue<typename Container::value_type, Container, Compare>; template<class InputIterator, class Compare = less<*iter-value-type*<InputIterator>>, class Container = vector<*iter-value-type*<InputIterator>>> priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())-> priority_queue<*iter-value-type*<InputIterator>, Container, Compare>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R, class Compare = less<ranges::range_value_t<R>>> priority_queue(from_range_t, R&&, Compare = Compare())-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; template<class Compare, class Container, class Allocator> priority_queue(Compare, Container, Allocator)-> priority_queue<typename Container::value_type, Container, Compare>; template<class InputIterator, class Allocator> priority_queue(InputIterator, InputIterator, Allocator)-> priority_queue<*iter-value-type*<InputIterator>,
vector<*iter-value-type*<InputIterator>, Allocator>,
less<*iter-value-type*<InputIterator>>>; template<class InputIterator, class Compare, class Allocator> priority_queue(InputIterator, InputIterator, Compare, Allocator)-> priority_queue<*iter-value-type*<InputIterator>,
vector<*iter-value-type*<InputIterator>, Allocator>, Compare>; template<class InputIterator, class Compare, class Container, class Allocator> priority_queue(InputIterator, InputIterator, Compare, Container, Allocator)-> priority_queue<typename Container::value_type, Container, Compare>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R, class Compare, class Allocator> priority_queue(from_range_t, R&&, Compare, Allocator)-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
Compare>; template<ranges::[input_range](range.refinements#concept:input_range "25.4.6Other range refinements[range.refinements]") R, class Allocator> priority_queue(from_range_t, R&&, Allocator)-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // no equality is providedtemplate<class T, class Container, class Compare, class Alloc>struct uses_allocator<priority_queue<T, Container, Compare>, Alloc>: uses_allocator<Container, Alloc>::type { };}

View File

@@ -0,0 +1,28 @@
[priqueue.special]
# 23 Containers library [[containers]](./#containers)
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#priqueue.special)
### 23.6.4 Class template priority_queue [[priority.queue]](priority.queue#priqueue.special)
#### 23.6.4.5 Specialized algorithms [priqueue.special]
[🔗](#lib:swap,priority_queue)
`template<class T, class Container, class Compare>
constexpr void swap(priority_queue<T, Container, Compare>& x,
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16493)
*Constraints*: is_swappable_v<Container> is true andis_swappable_v<Compare> is true[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L16498)
*Effects*: As if by x.swap(y)[.](#2.sentence-1)