Skip to content

[alg.min.max] Reword min/max/minmax in modern style #6776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 58 additions & 31 deletions source/algorithms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -8724,19 +8724,20 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
For the first form, \tcode{T} meets the
\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}).

\pnum
\returns
The smaller value.
Returns the first argument when the arguments are equivalent.

\pnum
\complexity
Exactly one comparison and two applications of the projection, if any.
\effects
Equivalent to:
\tcode{return invoke(comp, invoke(proj, b), invoke(proj, a)) ? b : a;}

\pnum
\remarks
Expand All @@ -8763,6 +8764,11 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
\tcode{ranges::distance(r) > 0}.
Expand All @@ -8773,14 +8779,14 @@

\pnum
\returns
The smallest value in the input range.
Returns a copy of the leftmost element
when several elements are equivalent to the smallest.
Returns a copy of the leftmost element \tcode{e} in the input range \tcode{r}
for which \tcode{bool(invoke(comp, invoke(proj, x), invoke(proj, e)))}
is \tcode{false} for all elements \tcode{x} in \tcode{r}.

\pnum
\complexity
Exactly \tcode{ranges::distance(r) - 1} comparisons
and twice as many applications of the projection, if any.
and twice as many applications of the projection.

\pnum
\remarks
Expand All @@ -8802,19 +8808,20 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
For the first form, \tcode{T} meets the
\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}).

\pnum
\returns
The larger value.
Returns the first argument when the arguments are equivalent.

\pnum
\complexity
Exactly one comparison and two applications of the projection, if any.
\effects
Equivalent to:
\tcode{return invoke(comp, invoke(proj, a), invoke(proj, b)) ? b : a;}

\pnum
\remarks
Expand All @@ -8841,6 +8848,11 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
\tcode{ranges::distance(r) > 0}.
Expand All @@ -8851,14 +8863,14 @@

\pnum
\returns
The largest value in the input range.
Returns a copy of the leftmost element
when several elements are equivalent to the largest.
Returns a copy of the leftmost element \tcode{e} in the input range \tcode{r}
for which \tcode{bool(invoke(comp, invoke(proj, e), invoke(proj, x)))}
is \tcode{false} for all elements \tcode{x} in \tcode{r}.

\pnum
\complexity
Exactly \tcode{ranges::distance(r) - 1} comparisons
and twice as many applications of the projection, if any.
and twice as many applications of the projection.

\pnum
\remarks
Expand All @@ -8882,19 +8894,25 @@


\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
For the first form, \tcode{T} meets the
\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}).

\pnum
\returns
\tcode{\{b, a\}} if \tcode{b} is smaller than \tcode{a}, and
\tcode{\{a, b\}} otherwise.
\tcode{\{b, a\}} if
\tcode{bool(invoke(comp, invoke(proj, b), invoke(proj, a)))} is \tcode{true},
and \tcode{\{a, b\}} otherwise.

\pnum
\complexity
Exactly one comparison and two applications of the projection, if any.
Exactly one comparison and two applications of the projection.

\pnum
\remarks
Expand Down Expand Up @@ -8922,6 +8940,11 @@
\end{itemdecl}

\begin{itemdescr}
\pnum
Let \tcode{comp} be \tcode{less\{\}}
and \tcode{proj} be \tcode{identity\{\}}
for the overloads with no parameters by those names.

\pnum
\expects
\tcode{ranges::distance(r) > 0}.
Expand All @@ -8934,15 +8957,19 @@
\returns
Let \tcode{X} be the return type.
Returns \tcode{X\{x, y\}},
where \tcode{x} is a copy of the leftmost element with the smallest value and
\tcode{y} a copy of the rightmost element with the largest value
in the input range.
where \tcode{x} is a copy of
the leftmost element in the input range \tcode{r} for which
\tcode{bool(invoke(comp, invoke(proj, e), invoke(proj, x)))}
is \tcode{false} for all elements \tcode{e} in \tcode{r}
and \tcode{y} is a copy of
the rightmost element in \tcode{r} for which
\tcode{bool(invoke(comp, invoke(proj, y), invoke(proj, e)))}
is \tcode{false} for all elements \tcode{e} in \tcode{r}.

\pnum
\complexity
At most $(3/2)\tcode{ranges::distance(r)}$ applications
of the corresponding predicate
and twice as many applications of the projection, if any.
At most $(3/2)\tcode{ranges::distance(r)}$ comparisons
and twice as many applications of the projection.

\pnum
\remarks
Expand Down