diff --git a/source/algorithms.tex b/source/algorithms.tex index ff4c3b38ed..0646819ef0 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -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 @@ -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}. @@ -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 @@ -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 @@ -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}. @@ -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 @@ -8882,6 +8894,11 @@ \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 @@ -8889,12 +8906,13 @@ \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 @@ -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}. @@ -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