Skip to content

Commit 865473b

Browse files
authored
Merge 2021-06 LWG Motion 3
P2385R0 C++ Standard Library Issues to be moved in Virtual Plenary, June 2021
2 parents b8e9549 + c9a295b commit 865473b

File tree

11 files changed

+841
-253
lines changed

11 files changed

+841
-253
lines changed

source/algorithms.tex

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8618,23 +8618,23 @@
86188618
\end{itemdecl}
86198619

86208620
\begin{itemdescr}
8621+
\pnum
8622+
Let $N$ be $\min(\tcode{e1 - b1}, \tcode{e2 - b2})$.
8623+
Let $E(n)$ be \tcode{comp(*(b1 + $n$), *(b2 + $n$))}.
8624+
86218625
\pnum
86228626
\mandates
86238627
\tcode{decltype(comp(*b1, *b2))} is a comparison category type.
86248628

86258629
\pnum
8626-
\effects
8627-
Lexicographically compares two ranges and
8628-
produces a result of the strongest applicable comparison category type.
8629-
Equivalent to:
8630-
\begin{codeblock}
8631-
for ( ; b1 != e1 && b2 != e2; void(++b1), void(++b2) )
8632-
if (auto cmp = comp(*b1,*b2); cmp != 0)
8633-
return cmp;
8634-
return b1 != e1 ? strong_ordering::greater :
8635-
b2 != e2 ? strong_ordering::less :
8636-
strong_ordering::equal;
8637-
\end{codeblock}
8630+
\returns
8631+
$E(i)$, where $i$ is the smallest integer in \range{0}{$N$}
8632+
such that \tcode{$E(i)$ != 0} is \tcode{true}, or
8633+
\tcode{(e1 - b1) <=> (e2 - b2)} if no such integer exists.
8634+
8635+
\pnum
8636+
\complexity
8637+
At most $N$ applications of \tcode{comp}.
86388638
\end{itemdescr}
86398639

86408640
\indexlibraryglobal{lexicographical_compare_three_way}%
@@ -10831,7 +10831,8 @@
1083110831
\begin{itemdescr}
1083210832
\pnum
1083310833
\expects
10834-
The objects in the array pointed to by \tcode{base} are of trivial type.
10834+
For \tcode{qsort}, the objects in the array pointed to by \tcode{base}
10835+
are of trivially copyable type.
1083510836

1083610837
\pnum
1083710838
\effects

source/containers.tex

Lines changed: 173 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4651,6 +4651,12 @@
46514651
arguments for a template parameter
46524652
named \tcode{Predicate} or \tcode{BinaryPredicate}
46534653
shall meet the corresponding requirements in \ref{algorithms.requirements}.
4654+
The semantics of \tcode{i + n},
4655+
where \tcode{i} is an iterator into the list and \tcode{n} is an integer,
4656+
are the same as those of \tcode{next(i, n)}.
4657+
The expression \tcode{i - n},
4658+
where \tcode{i} is an iterator into the list and \tcode{n} is an integer,
4659+
means an iterator \tcode{j} such that \tcode{j + n == i} is \tcode{true}.
46544660
For \tcode{merge} and \tcode{sort},
46554661
the definitions and requirements in \ref{alg.sorting} apply.
46564662

@@ -4784,16 +4790,24 @@
47844790
\indexlibrarymember{unique}{forward_list}%
47854791
\begin{itemdecl}
47864792
size_type unique();
4787-
template<class BinaryPredicate> size_type unique(BinaryPredicate pred);
4793+
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
47884794
\end{itemdecl}
47894795

47904796
\begin{itemdescr}
4797+
\pnum
4798+
Let \tcode{binary_pred} be \tcode{equal_to<>\{\}} for the first overload.
4799+
4800+
\pnum
4801+
\expects
4802+
\tcode{binary_pred} is an equivalence relation.
4803+
47914804
\pnum
47924805
\effects
47934806
Erases all but the first element from every consecutive
4794-
group of equal elements referred to by the iterator \tcode{i} in the range \range{first +
4795-
1}{last} for which \tcode{*i == *(i-1)} (for the version with no arguments) or \tcode{pred(*i,
4796-
*(i - 1))} (for the version with a predicate argument) holds.
4807+
group of equivalent elements.
4808+
That is, for a nonempty list, erases all elements referred to
4809+
by the iterator \tcode{i} in the range \range{begin() + 1}{end()}
4810+
for which \tcode{binary_pred(*i, *(i - 1))} is \tcode{true}.
47974811
Invalidates only the iterators and references to the erased elements.
47984812

47994813
\pnum
@@ -4802,11 +4816,14 @@
48024816

48034817
\pnum
48044818
\throws
4805-
Nothing unless an exception is thrown by the equality comparison or the predicate.
4819+
Nothing unless an exception is thrown by the predicate.
48064820

48074821
\pnum
48084822
\complexity
4809-
If the range \range{first}{last} is not empty, exactly \tcode{(last - first) - 1} applications of the corresponding predicate, otherwise no applications of the predicate.
4823+
If \tcode{empty()} is \tcode{false},
4824+
exactly \tcode{distance(begin(), end()) - 1} applications of
4825+
the corresponding predicate,
4826+
otherwise no applications of the predicate.
48104827
\end{itemdescr}
48114828

48124829
\indexlibrarymember{merge}{forward_list}%
@@ -5296,6 +5313,10 @@
52965313
arguments for a template parameter
52975314
named \tcode{Predicate} or \tcode{BinaryPredicate}
52985315
shall meet the corresponding requirements in \ref{algorithms.requirements}.
5316+
The semantics of \tcode{i + n} and \tcode{i - n},
5317+
where \tcode{i} is an iterator into the list and \tcode{n} is an integer,
5318+
are the same as those of \tcode{next(i, n)} and \tcode{prev(i, n)},
5319+
respectively.
52995320
For \tcode{merge} and \tcode{sort},
53005321
the definitions and requirements in \ref{alg.sorting} apply.
53015322

@@ -5474,13 +5495,20 @@
54745495
\end{itemdecl}
54755496

54765497
\begin{itemdescr}
5498+
\pnum
5499+
Let \tcode{binary_pred} be \tcode{equal_to<>\{\}} for the first overload.
5500+
5501+
\pnum
5502+
\expects
5503+
\tcode{binary_pred} is an equivalence relation.
5504+
54775505
\pnum
54785506
\effects
54795507
Erases all but the first element from every
5480-
consecutive group of equal elements referred to by the iterator \tcode{i} in the range
5481-
\range{first + 1}{last} for which \tcode{*i == *(i-1)} (for the version of
5482-
\tcode{unique} with no arguments) or \tcode{binary_pred(*i, *(i - 1))} (for the version of
5483-
\tcode{unique} with a predicate argument) holds.
5508+
consecutive group of equivalent elements.
5509+
That is, for a nonempty list, erases all elements referred to
5510+
by the iterator \tcode{i} in the range \range{begin() + 1}{end()}
5511+
for which \tcode{binary_pred(*i, *(i - 1))} is \tcode{true}.
54845512
Invalidates only the iterators and references to the erased elements.
54855513

54865514
\pnum
@@ -5489,18 +5517,12 @@
54895517

54905518
\pnum
54915519
\throws
5492-
Nothing unless an exception is thrown by
5493-
\tcode{*i == *(i-1)}
5494-
or
5495-
\tcode{pred(*i, *(i - 1))}.
5520+
Nothing unless an exception is thrown by the predicate.
54965521

54975522
\pnum
54985523
\complexity
5499-
If the range
5500-
\tcode{[first, last)}
5501-
is not empty, exactly
5502-
\tcode{(last - first) - 1}
5503-
applications of the corresponding predicate,
5524+
If \tcode{empty()} is \tcode{false},
5525+
exactly \tcode{size() - 1} applications of the corresponding predicate,
55045526
otherwise no applications of the predicate.
55055527
\end{itemdescr}
55065528

@@ -9695,6 +9717,12 @@
96959717
exception is thrown by the swap of the adaptor's \tcode{Container} or
96969718
\tcode{Compare} object (if any).
96979719

9720+
\pnum
9721+
A constructor template of a container adaptor
9722+
shall not participate in overload resolution
9723+
if it has an \tcode{InputIterator} template parameter and
9724+
a type that does not qualify as an input iterator is deduced for that parameter.
9725+
96989726
\pnum
96999727
A deduction guide for a container adaptor shall not participate in overload resolution if any of the following are true:
97009728
\begin{itemize}
@@ -9705,6 +9733,11 @@
97059733
\item It has both \tcode{Container} and \tcode{Allocator} template parameters, and \tcode{uses_allocator_v<Container, Allocator>} is \tcode{false}.
97069734
\end{itemize}
97079735

9736+
\pnum
9737+
The exposition-only alias template \exposid{iter-value-type}
9738+
defined in \ref{sequences.general}
9739+
may appear in deduction guides for container adaptors.
9740+
97089741
\rSec2[queue.syn]{Header \tcode{<queue>} synopsis}
97099742

97109743
\indexheader{queue}
@@ -10087,18 +10120,29 @@
1008710120
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
1008810121
priority_queue(const Compare& x, const Container&);
1008910122
priority_queue(const Compare& x, Container&&);
10123+
template<class InputIterator>
10124+
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
1009010125
template<class InputIterator>
1009110126
priority_queue(InputIterator first, InputIterator last, const Compare& x,
1009210127
const Container&);
1009310128
template<class InputIterator>
10094-
priority_queue(InputIterator first, InputIterator last,
10095-
const Compare& x = Compare(), Container&& = Container());
10129+
priority_queue(InputIterator first, InputIterator last, const Compare& x,
10130+
Container&&);
1009610131
template<class Alloc> explicit priority_queue(const Alloc&);
1009710132
template<class Alloc> priority_queue(const Compare&, const Alloc&);
1009810133
template<class Alloc> priority_queue(const Compare&, const Container&, const Alloc&);
1009910134
template<class Alloc> priority_queue(const Compare&, Container&&, const Alloc&);
1010010135
template<class Alloc> priority_queue(const priority_queue&, const Alloc&);
1010110136
template<class Alloc> priority_queue(priority_queue&&, const Alloc&);
10137+
template<class InputIterator, class Alloc>
10138+
priority_queue(InputIterator, InputIterator, const Alloc&);
10139+
template<class InputIterator, class Alloc>
10140+
priority_queue(InputIterator, InputIterator, const Compare&, const Alloc&);
10141+
template<class InputIterator, class Alloc>
10142+
priority_queue(InputIterator, InputIterator, const Compare&, const Container&,
10143+
const Alloc&);
10144+
template<class InputIterator, class Alloc>
10145+
priority_queue(InputIterator, InputIterator, const Compare&, Container&&, const Alloc&);
1010210146

1010310147
[[nodiscard]] bool empty() const { return c.empty(); }
1010410148
size_type size() const { return c.size(); }
@@ -10117,15 +10161,30 @@
1011710161
-> priority_queue<typename Container::value_type, Container, Compare>;
1011810162

1011910163
template<class InputIterator,
10120-
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
10121-
class Container = vector<typename iterator_traits<InputIterator>::value_type>>
10164+
class Compare = less<@\exposid{iter-value-type}@<InputIterator>>,
10165+
class Container = vector<@\exposid{iter-value-type}@<InputIterator>>>
1012210166
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
10123-
-> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>;
10167+
-> priority_queue<@\exposid{iter-value-type}@<InputIterator>, Container, Compare>;
1012410168

1012510169
template<class Compare, class Container, class Allocator>
1012610170
priority_queue(Compare, Container, Allocator)
1012710171
-> priority_queue<typename Container::value_type, Container, Compare>;
1012810172

10173+
template<class InputIterator, class Allocator>
10174+
priority_queue(InputIterator, InputIterator, Allocator)
10175+
-> priority_queue<@\exposid{iter-value-type}@<InputIterator>,
10176+
vector<@\exposid{iter-value-type}@<InputIterator>, Allocator>,
10177+
less<@\exposid{iter-value-type}@<InputIterator>>>;
10178+
10179+
template<class InputIterator, class Compare, class Allocator>
10180+
priority_queue(InputIterator, InputIterator, Compare, Allocator)
10181+
-> priority_queue<@\exposid{iter-value-type}@<InputIterator>,
10182+
vector<@\exposid{iter-value-type}@<InputIterator>, Allocator>, Compare>;
10183+
10184+
template<class InputIterator, class Compare, class Container, class Allocator>
10185+
priority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
10186+
-> priority_queue<typename Container::value_type, Container, Compare>;
10187+
1012910188
// no equality is provided
1013010189

1013110190
template<class T, class Container, class Compare, class Alloc>
@@ -10158,13 +10217,32 @@
1015810217
\tcode{make_heap(c.begin(), c.end(), comp)}.
1015910218
\end{itemdescr}
1016010219

10220+
\indexlibraryctor{priority_queue}%
10221+
\begin{itemdecl}
10222+
template<class InputIterator>
10223+
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
10224+
\end{itemdecl}
10225+
10226+
\begin{itemdescr}
10227+
\pnum
10228+
\expects
10229+
\tcode{x} defines a strict weak ordering\iref{alg.sorting}.
10230+
10231+
\pnum
10232+
\effects
10233+
Initializes \tcode{c} with
10234+
\tcode{first} as the first argument and
10235+
\tcode{last} as the second argument, and
10236+
initializes \tcode{comp} with \tcode{x};
10237+
then calls \tcode{make_heap(c.begin(), c.end(), comp)}.
10238+
\end{itemdescr}
10239+
1016110240
\indexlibraryctor{priority_queue}%
1016210241
\begin{itemdecl}
1016310242
template<class InputIterator>
1016410243
priority_queue(InputIterator first, InputIterator last, const Compare& x, const Container& y);
1016510244
template<class InputIterator>
10166-
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare(),
10167-
Container&& y = Container());
10245+
priority_queue(InputIterator first, InputIterator last, const Compare& x, Container&& y);
1016810246
\end{itemdecl}
1016910247

1017010248
\begin{itemdescr}
@@ -10265,6 +10343,75 @@
1026510343
as the second argument, and initializes \tcode{comp} with \tcode{std::move(q.comp)}.
1026610344
\end{itemdescr}
1026710345

10346+
\indexlibraryctor{priority_queue}%
10347+
\begin{itemdecl}
10348+
template<class InputIterator, class Alloc>
10349+
priority_queue(InputIterator first, InputIterator last, const Alloc& a);
10350+
\end{itemdecl}
10351+
10352+
\begin{itemdescr}
10353+
\pnum
10354+
\effects
10355+
Initializes \tcode{c} with
10356+
\tcode{first} as the first argument,
10357+
\tcode{last} as the second argument, and
10358+
\tcode{a} as the third argument, and
10359+
value-initializes \tcode{comp};
10360+
calls \tcode{make_heap(c.begin(), c.end(), comp)}.
10361+
\end{itemdescr}
10362+
10363+
\indexlibraryctor{priority_queue}%
10364+
\begin{itemdecl}
10365+
template<class InputIterator, class Alloc>
10366+
priority_queue(InputIterator first, InputIterator last, const Compare& compare, const Alloc& a);
10367+
\end{itemdecl}
10368+
10369+
\begin{itemdescr}
10370+
\pnum
10371+
\effects
10372+
Initializes \tcode{c} with
10373+
\tcode{first} as the first argument,
10374+
\tcode{last} as the second argument, and
10375+
\tcode{a} as the third argument, and
10376+
initializes \tcode{comp} with \tcode{compare};
10377+
calls \tcode{make_heap(c.begin(), c.end(), comp)}.
10378+
\end{itemdescr}
10379+
10380+
\indexlibraryctor{priority_queue}%
10381+
\begin{itemdecl}
10382+
template<class InputIterator, class Alloc>
10383+
priority_queue(InputIterator first, InputIterator last, const Compare& compare,
10384+
const Container& cont, const Alloc& a);
10385+
\end{itemdecl}
10386+
10387+
\begin{itemdescr}
10388+
\pnum
10389+
\effects
10390+
Initializes \tcode{c} with
10391+
\tcode{cont} as the first argument and \tcode{a} as the second argument, and
10392+
initializes \tcode{comp} with \tcode{compare};
10393+
calls \tcode{c.insert(c.end(), first, last)}; and
10394+
finally calls \tcode{make_heap(c.begin(), c.end(), comp)}.
10395+
\end{itemdescr}
10396+
10397+
\indexlibraryctor{priority_queue}%
10398+
\begin{itemdecl}
10399+
template<class InputIterator, class Alloc>
10400+
priority_queue(InputIterator first, InputIterator last, const Compare& compare, Container&& cont,
10401+
const Alloc& a);
10402+
\end{itemdecl}
10403+
10404+
\begin{itemdescr}
10405+
\pnum
10406+
\effects
10407+
Initializes \tcode{c} with
10408+
\tcode{std::move(cont)} as the first argument and
10409+
\tcode{a} as the second argument, and
10410+
initializes \tcode{comp} with \tcode{compare};
10411+
calls \tcode{c.insert(c.end(), first, last)}; and
10412+
finally calls \tcode{make_heap(c.begin(), c.end(), comp)}.
10413+
\end{itemdescr}
10414+
1026810415
\rSec3[priqueue.members]{Members}
1026910416

1027010417
\indexlibrarymember{push}{priority_queue}%

0 commit comments

Comments
 (0)