Skip to content

Commit

Permalink
Merge 2021-06 LWG Motion 3
Browse files Browse the repository at this point in the history
P2385R0 C++ Standard Library Issues to be moved in Virtual Plenary, June 2021
  • Loading branch information
tkoeppe committed Jun 16, 2021
2 parents b8e9549 + c9a295b commit 865473b
Show file tree
Hide file tree
Showing 11 changed files with 841 additions and 253 deletions.
27 changes: 14 additions & 13 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8618,23 +8618,23 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let $N$ be $\min(\tcode{e1 - b1}, \tcode{e2 - b2})$.
Let $E(n)$ be \tcode{comp(*(b1 + $n$), *(b2 + $n$))}.

\pnum
\mandates
\tcode{decltype(comp(*b1, *b2))} is a comparison category type.

\pnum
\effects
Lexicographically compares two ranges and
produces a result of the strongest applicable comparison category type.
Equivalent to:
\begin{codeblock}
for ( ; b1 != e1 && b2 != e2; void(++b1), void(++b2) )
if (auto cmp = comp(*b1,*b2); cmp != 0)
return cmp;
return b1 != e1 ? strong_ordering::greater :
b2 != e2 ? strong_ordering::less :
strong_ordering::equal;
\end{codeblock}
\returns
$E(i)$, where $i$ is the smallest integer in \range{0}{$N$}
such that \tcode{$E(i)$ != 0} is \tcode{true}, or
\tcode{(e1 - b1) <=> (e2 - b2)} if no such integer exists.

\pnum
\complexity
At most $N$ applications of \tcode{comp}.
\end{itemdescr}

\indexlibraryglobal{lexicographical_compare_three_way}%
Expand Down Expand Up @@ -10831,7 +10831,8 @@
\begin{itemdescr}
\pnum
\expects
The objects in the array pointed to by \tcode{base} are of trivial type.
For \tcode{qsort}, the objects in the array pointed to by \tcode{base}
are of trivially copyable type.

\pnum
\effects
Expand Down
199 changes: 173 additions & 26 deletions source/containers.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4651,6 +4651,12 @@
arguments for a template parameter
named \tcode{Predicate} or \tcode{BinaryPredicate}
shall meet the corresponding requirements in \ref{algorithms.requirements}.
The semantics of \tcode{i + n},
where \tcode{i} is an iterator into the list and \tcode{n} is an integer,
are the same as those of \tcode{next(i, n)}.
The expression \tcode{i - n},
where \tcode{i} is an iterator into the list and \tcode{n} is an integer,
means an iterator \tcode{j} such that \tcode{j + n == i} is \tcode{true}.
For \tcode{merge} and \tcode{sort},
the definitions and requirements in \ref{alg.sorting} apply.

Expand Down Expand Up @@ -4784,16 +4790,24 @@
\indexlibrarymember{unique}{forward_list}%
\begin{itemdecl}
size_type unique();
template<class BinaryPredicate> size_type unique(BinaryPredicate pred);
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{binary_pred} be \tcode{equal_to<>\{\}} for the first overload.

\pnum
\expects
\tcode{binary_pred} is an equivalence relation.

\pnum
\effects
Erases all but the first element from every consecutive
group of equal elements referred to by the iterator \tcode{i} in the range \range{first +
1}{last} for which \tcode{*i == *(i-1)} (for the version with no arguments) or \tcode{pred(*i,
*(i - 1))} (for the version with a predicate argument) holds.
group of equivalent elements.
That is, for a nonempty list, erases all elements referred to
by the iterator \tcode{i} in the range \range{begin() + 1}{end()}
for which \tcode{binary_pred(*i, *(i - 1))} is \tcode{true}.
Invalidates only the iterators and references to the erased elements.

\pnum
Expand All @@ -4802,11 +4816,14 @@

\pnum
\throws
Nothing unless an exception is thrown by the equality comparison or the predicate.
Nothing unless an exception is thrown by the predicate.

\pnum
\complexity
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.
If \tcode{empty()} is \tcode{false},
exactly \tcode{distance(begin(), end()) - 1} applications of
the corresponding predicate,
otherwise no applications of the predicate.
\end{itemdescr}

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

Expand Down Expand Up @@ -5474,13 +5495,20 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{binary_pred} be \tcode{equal_to<>\{\}} for the first overload.

\pnum
\expects
\tcode{binary_pred} is an equivalence relation.

\pnum
\effects
Erases all but the first element from every
consecutive group of equal elements referred to by the iterator \tcode{i} in the range
\range{first + 1}{last} for which \tcode{*i == *(i-1)} (for the version of
\tcode{unique} with no arguments) or \tcode{binary_pred(*i, *(i - 1))} (for the version of
\tcode{unique} with a predicate argument) holds.
consecutive group of equivalent elements.
That is, for a nonempty list, erases all elements referred to
by the iterator \tcode{i} in the range \range{begin() + 1}{end()}
for which \tcode{binary_pred(*i, *(i - 1))} is \tcode{true}.
Invalidates only the iterators and references to the erased elements.

\pnum
Expand All @@ -5489,18 +5517,12 @@

\pnum
\throws
Nothing unless an exception is thrown by
\tcode{*i == *(i-1)}
or
\tcode{pred(*i, *(i - 1))}.
Nothing unless an exception is thrown by the predicate.

\pnum
\complexity
If the range
\tcode{[first, last)}
is not empty, exactly
\tcode{(last - first) - 1}
applications of the corresponding predicate,
If \tcode{empty()} is \tcode{false},
exactly \tcode{size() - 1} applications of the corresponding predicate,
otherwise no applications of the predicate.
\end{itemdescr}

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

\pnum
A constructor template of a container adaptor
shall not participate in overload resolution
if it has an \tcode{InputIterator} template parameter and
a type that does not qualify as an input iterator is deduced for that parameter.

\pnum
A deduction guide for a container adaptor shall not participate in overload resolution if any of the following are true:
\begin{itemize}
Expand All @@ -9705,6 +9733,11 @@
\item It has both \tcode{Container} and \tcode{Allocator} template parameters, and \tcode{uses_allocator_v<Container, Allocator>} is \tcode{false}.
\end{itemize}

\pnum
The exposition-only alias template \exposid{iter-value-type}
defined in \ref{sequences.general}
may appear in deduction guides for container adaptors.

\rSec2[queue.syn]{Header \tcode{<queue>} synopsis}

\indexheader{queue}
Expand Down Expand Up @@ -10087,18 +10120,29 @@
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
priority_queue(const Compare& x, const Container&);
priority_queue(const Compare& x, Container&&);
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last, const Compare& x,
const Container&);
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last,
const Compare& x = Compare(), Container&& = Container());
priority_queue(InputIterator first, InputIterator last, const Compare& x,
Container&&);
template<class Alloc> explicit priority_queue(const Alloc&);
template<class Alloc> priority_queue(const Compare&, const Alloc&);
template<class Alloc> priority_queue(const Compare&, const Container&, const Alloc&);
template<class Alloc> priority_queue(const Compare&, Container&&, const Alloc&);
template<class Alloc> priority_queue(const priority_queue&, const Alloc&);
template<class Alloc> priority_queue(priority_queue&&, const Alloc&);
template<class InputIterator, class Alloc>
priority_queue(InputIterator, InputIterator, const Alloc&);
template<class InputIterator, class Alloc>
priority_queue(InputIterator, InputIterator, const Compare&, const Alloc&);
template<class InputIterator, class Alloc>
priority_queue(InputIterator, InputIterator, const Compare&, const Container&,
const Alloc&);
template<class InputIterator, class Alloc>
priority_queue(InputIterator, InputIterator, const Compare&, Container&&, const Alloc&);

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

template<class InputIterator,
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
class Container = vector<typename iterator_traits<InputIterator>::value_type>>
class Compare = less<@\exposid{iter-value-type}@<InputIterator>>,
class Container = vector<@\exposid{iter-value-type}@<InputIterator>>>
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
-> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>;
-> priority_queue<@\exposid{iter-value-type}@<InputIterator>, Container, 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<@\exposid{iter-value-type}@<InputIterator>,
vector<@\exposid{iter-value-type}@<InputIterator>, Allocator>,
less<@\exposid{iter-value-type}@<InputIterator>>>;

template<class InputIterator, class Compare, class Allocator>
priority_queue(InputIterator, InputIterator, Compare, Allocator)
-> priority_queue<@\exposid{iter-value-type}@<InputIterator>,
vector<@\exposid{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>;

// no equality is provided

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

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
\end{itemdecl}

\begin{itemdescr}
\pnum
\expects
\tcode{x} defines a strict weak ordering\iref{alg.sorting}.

\pnum
\effects
Initializes \tcode{c} with
\tcode{first} as the first argument and
\tcode{last} as the second argument, and
initializes \tcode{comp} with \tcode{x};
then calls \tcode{make_heap(c.begin(), c.end(), comp)}.
\end{itemdescr}

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last, const Compare& x, const Container& y);
template<class InputIterator>
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare(),
Container&& y = Container());
priority_queue(InputIterator first, InputIterator last, const Compare& x, Container&& y);
\end{itemdecl}

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

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator, class Alloc>
priority_queue(InputIterator first, InputIterator last, const Alloc& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes \tcode{c} with
\tcode{first} as the first argument,
\tcode{last} as the second argument, and
\tcode{a} as the third argument, and
value-initializes \tcode{comp};
calls \tcode{make_heap(c.begin(), c.end(), comp)}.
\end{itemdescr}

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator, class Alloc>
priority_queue(InputIterator first, InputIterator last, const Compare& compare, const Alloc& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes \tcode{c} with
\tcode{first} as the first argument,
\tcode{last} as the second argument, and
\tcode{a} as the third argument, and
initializes \tcode{comp} with \tcode{compare};
calls \tcode{make_heap(c.begin(), c.end(), comp)}.
\end{itemdescr}

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator, class Alloc>
priority_queue(InputIterator first, InputIterator last, const Compare& compare,
const Container& cont, const Alloc& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes \tcode{c} with
\tcode{cont} as the first argument and \tcode{a} as the second argument, and
initializes \tcode{comp} with \tcode{compare};
calls \tcode{c.insert(c.end(), first, last)}; and
finally calls \tcode{make_heap(c.begin(), c.end(), comp)}.
\end{itemdescr}

\indexlibraryctor{priority_queue}%
\begin{itemdecl}
template<class InputIterator, class Alloc>
priority_queue(InputIterator first, InputIterator last, const Compare& compare, Container&& cont,
const Alloc& a);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes \tcode{c} with
\tcode{std::move(cont)} as the first argument and
\tcode{a} as the second argument, and
initializes \tcode{comp} with \tcode{compare};
calls \tcode{c.insert(c.end(), first, last)}; and
finally calls \tcode{make_heap(c.begin(), c.end(), comp)}.
\end{itemdescr}

\rSec3[priqueue.members]{Members}

\indexlibrarymember{push}{priority_queue}%
Expand Down

0 comments on commit 865473b

Please sign in to comment.