From 59fed130a210facb3357347b72a9b41febdde158 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 11 Jun 2019 09:17:08 -0700 Subject: [PATCH] P1718R2 Mandating the Standard Library: Clause 25 - Algorithms library --- source/algorithms.tex | 709 +++++++++++++++++++++++------------------- 1 file changed, 392 insertions(+), 317 deletions(-) diff --git a/source/algorithms.tex b/source/algorithms.tex index 471b1ec64f..669389a2d5 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -596,7 +596,7 @@ when the guarantee says ``at most \placeholder{expr}'' or ``exactly \placeholder{expr}'' and does not specify the number of assignments or swaps, and -\placeholder{expr} is not already expressed with \bigoh{} notation, +\placeholder{expr} is not already expressed with \bigoh{} notation, the complexity of the algorithm shall be \bigoh{\placeholder{expr}}. \pnum @@ -3018,8 +3018,8 @@ \begin{itemdescr} \pnum -\requires -\tcode{Function} shall meet +\expects +\tcode{Function} meets the \oldconcept{MoveConstructible} requirements (\tref{cpp17.moveconstructible}). \begin{note} \tcode{Function} need not meet the requirements of @@ -3059,8 +3059,8 @@ \begin{itemdescr} \pnum -\requires -\tcode{Function} shall meet the \oldconcept{CopyConstructible} requirements. +\expects +\tcode{Function} meets the \oldconcept{CopyConstructible} requirements. \pnum \effects @@ -3139,16 +3139,21 @@ \begin{itemdescr} \pnum -\requires -\tcode{Function} shall meet the \oldconcept{MoveConstructible} requirements. +\mandates +The type \tcode{Size} is convertible +to an integral type~(\ref{conv.integral}, \ref{class.conv}). + +\pnum +\expects +\tcode{Function} meets the \oldconcept{MoveConstructible} requirements. \begin{note} \tcode{Function} need not meet the requirements of \oldconcept{CopyConstructible}. \end{note} \pnum -\requires -\tcode{n >= 0}. +\expects +\tcode{n >= 0} is \tcode{true}. \pnum \effects @@ -3177,12 +3182,17 @@ \begin{itemdescr} \pnum -\requires -\tcode{Function} shall meet the \oldconcept{CopyConstructible} requirements. +\mandates +The type \tcode{Size} is convertible +to an integral type~(\ref{conv.integral}, \ref{class.conv}). + +\pnum +\expects +\tcode{Function} meets the \oldconcept{CopyConstructible} requirements. \pnum -\requires -\tcode{n >= 0}. +\expects +\tcode{n >= 0} is \tcode{true}. \pnum \effects @@ -3797,11 +3807,14 @@ \end{itemdecl} \begin{itemdescr} + +\pnum +\mandates +\tcode{ForwardIterator1} and \tcode{ForwardIterator2} have the same value type. + \pnum -\requires -\tcode{ForwardIterator1} and \tcode{ForwardIterator2} shall have -the same value type. -The comparison function shall be an equivalence relation. +\expects +The comparison function is an equivalence relation. \pnum \remarks @@ -3993,10 +4006,11 @@ \end{itemdecl} \begin{itemdescr} + \pnum -\requires +\mandates The type \tcode{Size} -shall be convertible to integral type~(\ref{conv.integral}, \ref{class.conv}). +is convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum \returns @@ -4083,8 +4097,8 @@ Let $N$ be \tcode{last - first}. \pnum -\requires -\tcode{result} shall not be in the range \range{first}{last}. +\expects +\tcode{result} is not in the range \range{first}{last}. \pnum \effects @@ -4118,9 +4132,9 @@ \begin{itemdescr} \pnum -\requires +\expects The ranges \range{first}{last} and \range{result}{result + (last - first)} -shall not overlap. +do not overlap. \pnum \effects @@ -4156,27 +4170,32 @@ \begin{itemdescr} \pnum -Let $M$ be $\max(\tcode{n}, 0)$. +Let $N$ be $\max(0, \tcode{n})$. + +\pnum +\mandates +The type \tcode{Size} is convertible +to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum \effects -For each non-negative integer $i < M$, +For each non-negative integer $i < N$, performs \tcode{*(result + i) = *(first + i)}. \pnum \returns \begin{itemize} \item - \tcode{result + $M$} + \tcode{result + $N$} for the overloads in namespace \tcode{std}, or \item - \tcode{\{first + $M$, result + $M$\}} + \tcode{\{first + $N$, result + $N$\}} for the overload in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -Exactly $M$ assignments. +Exactly $N$ assignments. \end{itemdescr} \indexlibraryglobal{copy_if}% @@ -4217,9 +4236,9 @@ for which the condition $E$ holds. \pnum -\requires +\expects The ranges \range{first}{last} and \range{result}{result + (last - first)} -shall not overlap. +do not overlap. \begin{note} For the overload with an \tcode{ExecutionPolicy}, there may be a performance cost @@ -4277,8 +4296,8 @@ Let $N$ be \tcode{last - first}. \pnum -\requires -\tcode{result} shall not be in the range \brange{first}{last}. +\expects +\tcode{result} is not in the range \brange{first}{last}. \pnum \effects @@ -4338,8 +4357,8 @@ Let $N$ be \tcode{last - first}. \pnum -\requires -\tcode{result} shall not be in the range \range{first}{last}. +\expects +\tcode{result} is not in the range \range{first}{last}. \pnum \effects @@ -4377,9 +4396,9 @@ Let $N$ be \tcode{last - first}. \pnum -\requires +\expects The ranges \range{first}{last} and \range{result}{result + $N$} -shall not overlap. +do not overlap. \pnum \effects @@ -4428,8 +4447,8 @@ Let $N$ be \tcode{last - first}. \pnum -\requires -\tcode{result} shall not be in the range \brange{first}{last}. +\expects +\tcode{result} is not in the range \brange{first}{last}. \pnum \effects @@ -4492,11 +4511,11 @@ \end{itemize} \pnum -\requires +\expects The two ranges \range{first1}{last1} and \range{first2}{last2} -shall not overlap. +do not overlap. For the overloads in namespace \tcode{std}, -\tcode{*(first1 + $n$)} shall be swappable with\iref{swappable.requirements} +\tcode{*(first1 + $n$)} is swappable with\iref{swappable.requirements} \tcode{*(first2 + $n$)}. \pnum @@ -4535,8 +4554,8 @@ \begin{itemdescr} \pnum -\requires -\tcode{a} and \tcode{b} shall be dereferenceable. \tcode{*a} shall be +\expects +\tcode{a} and \tcode{b} are dereferenceable. \tcode{*a} is swappable with\iref{swappable.requirements} \tcode{*b}. \pnum @@ -4632,8 +4651,8 @@ \end{itemize} \pnum -\requires -\tcode{op} and \tcode{binary_op} shall not invalidate iterators or subranges, nor +\expects +\tcode{op} and \tcode{binary_op} do not invalidate iterators or subranges, nor modify elements in the ranges \begin{itemize} \item \crange{first1}{first1 + $N$}, @@ -4724,9 +4743,10 @@ \item \tcode{bool(invoke(pred, invoke(proj, *i)))} for \tcode{ranges::replace_if}. \end{itemize} + \pnum -\requires -The expression \tcode{*first = new_value} shall be valid. +\mandates +\tcode{new_value} is writable\iref{iterator.requirements.general} to \tcode{first}. \pnum \effects @@ -4817,12 +4837,14 @@ \end{itemize} \pnum -\requires +\mandates The results of the expressions \tcode{*first} and \tcode{new_value} -shall be writable\iref{iterator.requirements.general} -to the \tcode{result} output iterator. +are writable\iref{iterator.requirements.general} to \tcode{result}. + +\pnum +\expects The ranges \range{first}{last} and \range{result}{result + (last - first)} -shall not overlap. +do not overlap. \pnum \effects @@ -4880,10 +4902,10 @@ \tcode{last - first} for the \tcode{fill} algorithms. \pnum -\requires +\mandates The expression \tcode{value} -shall be writable\iref{iterator.requirements.general} to the output iterator. -The type \tcode{Size} shall be convertible +is writable\iref{iterator.requirements.general} to the output iterator. +The type \tcode{Size} is convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum @@ -4936,8 +4958,8 @@ \tcode{last - first} for the \tcode{generate} algorithms. \pnum -\requires -\tcode{Size} shall be convertible +\mandates +\tcode{Size} is convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum @@ -5004,10 +5026,10 @@ \end{itemize} \pnum -\requires +\expects For the algorithms in namespace \tcode{std}, the type of \tcode{*first} -shall meet the \oldconcept{MoveAssignable} requirements (\tref{cpp17.moveassignable}). +meets the \oldconcept{MoveAssignable} requirements (\tref{cpp17.moveassignable}). \pnum \effects @@ -5104,9 +5126,13 @@ for which $E$ is \tcode{false}. \pnum -\requires +\mandates +\tcode{*first} is writable\iref{iterator.requirements.general} to \tcode{result}. + +\pnum +\expects The ranges \range{first}{last} and \range{result}{result + (last - first)} -shall not overlap. The expression \tcode{*result = *first} shall be valid. +do not overlap. \begin{note} For the overloads with an \tcode{ExecutionPolicy}, there may be a performance cost @@ -5180,10 +5206,10 @@ \end{itemize} \pnum -\requires +\expects For the overloads in namepace \tcode{std}, -\tcode{pred} shall be an equivalence relation and -the type of \tcode{*first} shall meet +\tcode{pred} is an equivalence relation and +the type of \tcode{*first} meets the \oldconcept{MoveAssignable} requirements (\tref{cpp17.moveassignable}). \pnum @@ -5266,18 +5292,20 @@ \end{itemize} \pnum -\requires +\mandates +\tcode{*first} is writable\iref{iterator.requirements.general} to \tcode{result}. + +\pnum +\expects \begin{itemize} \item The ranges \range{first}{last} and \range{result}{result+(last-first)} - shall not overlap. + do not overlap. \item For the overloads in namespace \tcode{std}: \begin{itemize} \item - The comparison function shall be an equivalence relation. - \item - The expression \tcode{*result = *first} shall be valid. + The comparison function is an equivalence relation. \item For the overloads with no \tcode{ExecutionPolicy}, let \tcode{T} be the value type of \tcode{InputIterator}. @@ -5287,9 +5315,9 @@ Otherwise, if \tcode{OutputIterator} meets the \oldconcept{ForwardIterator} requirements and its value type is the same as \tcode{T}, - then \tcode{T} shall meet + then \tcode{T} meets the \oldconcept{CopyAssignable} (\tref{cpp17.copyassignable}) requirements. - Otherwise, \tcode{T} shall meet both + Otherwise, \tcode{T} meets both the \oldconcept{CopyConstructible} (\tref{cpp17.copyconstructible}) and \oldconcept{CopyAssignable} requirements. \begin{note} @@ -5341,9 +5369,9 @@ \begin{itemdescr} \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet +\tcode{BidirectionalIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum @@ -5389,9 +5417,9 @@ Let $N$ be \tcode{last - first}. \pnum -\requires +\expects The ranges \range{first}{last} and \range{result}{result + $N$} -shall not overlap. +do not overlap. \pnum \effects @@ -5432,12 +5460,12 @@ \begin{itemdescr} \pnum -\requires -\range{first}{middle} and \range{middle}{last} shall be valid ranges. +\expects +\range{first}{middle} and \range{middle}{last} are valid ranges. For the overloads in namespace \tcode{std}, -\tcode{ForwardIterator} shall meet +\tcode{ForwardIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -5502,10 +5530,10 @@ Let $N$ be \tcode{last - first}. \pnum -\requires -\range{first}{middle} and \range{middle}{last} shall be valid ranges. +\expects +\range{first}{middle} and \range{middle}{last} are valid ranges. The ranges \range{first}{last} and \range{result}{result + $N$} -shall not overlap. +do not overlap. \pnum \effects @@ -5557,29 +5585,29 @@ \begin{itemdescr} \pnum -\requires +\mandates +\tcode{Distance} is an integer type. +\tcode{*first} is writable\iref{iterator.requirements.general} to \tcode{out}. + +\pnum +\expects \begin{itemize} \item - \tcode{PopulationIterator} shall meet + \tcode{PopulationIterator} meets the \oldconcept{InputIterator} requirements\iref{input.iterators}. \item - \tcode{SampleIterator} shall meet + \tcode{SampleIterator} meets the \oldconcept{OutputIterator} requirements\iref{output.iterators}. \item - \tcode{SampleIterator} shall meet + \tcode{SampleIterator} meets the \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators} unless \tcode{Pop\-ulat\-ion\-Iter\-ator} meets the \oldconcept{ForwardIterator} requirements\iref{forward.iterators}. \item - \tcode{PopulationIterator}'s value type shall be - writable\iref{iterator.requirements.general} to \tcode{out}. -\item - \tcode{Distance} shall be an integer type. -\item - \tcode{remove_reference_t} shall meet + \tcode{remove_reference_t} meets the requirements of a uniform random bit generator type\iref{rand.req.urng}. \item - \tcode{out} shall not be in the range \range{first}{last}. + \tcode{out} is not in the range \range{first}{last}. \end{itemize} \pnum @@ -5634,14 +5662,14 @@ \begin{itemdescr} \pnum -\requires +\expects For the overload in namespace \tcode{std}: \begin{itemize} \item - \tcode{RandomAccessIterator} shall meet + \tcode{RandomAccessIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. \item - The type \tcode{remove_reference_t} shall meet + The type \tcode{remove_reference_t} meets the uniform random bit generator\iref{rand.req.urng} requirements. \end{itemize} @@ -5682,8 +5710,8 @@ \begin{itemdescr} \pnum -\requires -The type of \tcode{*first} shall meet +\expects +The type of \tcode{*first} meets the \oldconcept{MoveAssignable} requirements. \pnum @@ -5721,10 +5749,10 @@ \begin{itemdescr} \pnum -\requires -The type of \tcode{*first} shall meet +\expects +The type of \tcode{*first} meets the \oldconcept{MoveAssignable} requirements. -\tcode{ForwardIterator} shall meet +\tcode{ForwardIterator} meets the \oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators} or the \oldconcept{ValueSwappable} requirements. @@ -5871,11 +5899,11 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -5929,11 +5957,11 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -5998,12 +6026,12 @@ for the overloads with no parameters by those names. \pnum -\requires -\range{first}{middle} and \range{middle}{last} shall be valid ranges. +\expects +\range{first}{middle} and \range{middle}{last} are valid ranges. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -6101,15 +6129,19 @@ for the overloads with no parameters by those names. \pnum -\requires +\mandates +For the overloads in namespace \tcode{std}, +the expression \tcode{*first} +is writable\iref{iterator.requirements.general} to \tcode{result_first}. + +\pnum +\expects For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}, -the type of \tcode{*result_first} shall meet +the type of \tcode{*result_first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and -\oldconcept{\-Move\-Assignable} (\tref{cpp17.moveassignable}) requirements, -and the expression \tcode{*first} -shall be writable\iref{iterator.requirements.general} to \tcode{result_first}. +\oldconcept{\-Move\-Assignable} (\tref{cpp17.moveassignable}) requirements. \pnum \expects @@ -6308,12 +6340,12 @@ for the overloads with no parameters by those names. \pnum -\requires -\range{first}{nth} and \range{nth}{last} shall be valid ranges. +\expects +\range{first}{nth} and \range{nth}{last} are valid ranges. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -6401,9 +6433,9 @@ for overloads with no parameters by those names. \pnum -\requires +\expects The elements \tcode{e} of \range{first}{last} -shall be partitioned with respect to the expression +are partitioned with respect to the expression \tcode{bool(invoke(comp, invoke(proj, e), value))}. \pnum @@ -6448,9 +6480,9 @@ for overloads with no parameters by those names. \pnum -\requires +\expects The elements \tcode{e} of \range{first}{last} -shall be partitioned with respect to the expression +are partitioned with respect to the expression \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. \pnum @@ -6497,13 +6529,13 @@ for overloads with no parameters by those names. \pnum -\requires +\expects The elements \tcode{e} of \range{first}{last} -shall be partitioned with respect to the expressions +are partitioned with respect to the expressions \tcode{bool(invoke(comp, invoke(proj, e), value))} and \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. Also, for all elements \tcode{e} of \tcode{[first, last)}, -\tcode{bool(comp(e, value))} shall imply \tcode{!bool(comp(\brk{}value, e))} +\tcode{bool(comp(e, value))} implies \tcode{!bool(comp(\brk{}value, e))} for the overloads in namespace \tcode{std}. \pnum @@ -6561,13 +6593,13 @@ for overloads with no parameters by those names. \pnum -\requires +\expects The elements \tcode{e} of \range{first}{last} -shall be partitioned with respect to the expressions +are partitioned with respect to the expressions \tcode{bool(invoke(comp, invoke(proj, e), value))} and \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. Also, for all elements \tcode{e} of \tcode{[first, last)}, -\tcode{bool(comp(e, value))} shall imply \tcode{!bool(comp(\brk{}value, e))} +\tcode{bool(comp(e, value))} implies \tcode{!bool(comp(\brk{}value, e))} for the overloads in namespace \tcode{std}. \pnum @@ -6646,9 +6678,9 @@ and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{ForwardIterator} shall meet +\tcode{ForwardIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. \pnum @@ -6714,11 +6746,11 @@ for the overloads with no parameter named \tcode{proj} and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet +\tcode{BidirectionalIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -6792,12 +6824,16 @@ let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum -\requires -The input range and output ranges shall not overlap. +\mandates For the overloads in namespace \tcode{std}, the expression \tcode{*first} -shall be writable\iref{iterator.requirements.general} +is writable\iref{iterator.requirements.general} to \tcode{out_true} and \tcode{out_false}. + +\pnum +\expects +The input range and output ranges do not overlap. + \begin{note} For the overload with an \tcode{ExecutionPolicy}, there may be a performance cost if \tcode{first}'s value type @@ -6848,9 +6884,9 @@ and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum -\requires +\expects The elements \tcode{e} of \range{first}{last} -shall be partitioned with respect to $E(\tcode{e})$. +are partitioned with respect to $E(\tcode{e})$. \pnum \returns @@ -6921,11 +6957,11 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects The ranges \range{first1}{last1} and \range{first2}{last2} -shall be sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, +are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. -The resulting range shall not overlap with either of the original ranges. +The resulting range does not overlap with either of the original ranges. \pnum \effects @@ -7001,13 +7037,13 @@ for the overloads with no parameters by those names. \pnum -\requires -\range{first}{middle} and \range{middle}{last} shall be valid ranges +\expects +\range{first}{middle} and \range{middle}{last} are valid ranges sorted with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet +\tcode{BidirectionalIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -7110,8 +7146,8 @@ for the overloads with no parameters by those names. \pnum -\requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +\expects +The ranges \range{first1}{last1} and \range{first2}{last2} are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. \pnum @@ -7184,10 +7220,10 @@ for the overloads with no parameters by those names. \pnum -\requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +\expects +The ranges \range{first1}{last1} and \range{first2}{last2} are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. -The resulting range shall not overlap with either of the original ranges. +The resulting range does not overlap with either of the original ranges. \pnum \effects @@ -7279,10 +7315,10 @@ for the overloads with no parameters by those names. \pnum -\requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +\expects +The ranges \range{first1}{last1} and \range{first2}{last2} are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. -The resulting range shall not overlap with either of the original ranges. +The resulting range does not overlap with either of the original ranges. \pnum \effects @@ -7372,10 +7408,10 @@ for the overloads with no parameters by those names. \pnum -\requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +\expects +The ranges \range{first1}{last1} and \range{first2}{last2} are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. -The resulting range shall not overlap with either of the original ranges. +The resulting range does not overlap with either of the original ranges. \pnum \effects @@ -7467,10 +7503,10 @@ for the overloads with no parameters by those names. \pnum -\requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +\expects +The ranges \range{first1}{last1} and \range{first2}{last2} are sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. -The resulting range shall not overlap with either of the original ranges. +The resulting range does not overlap with either of the original ranges. \pnum \effects @@ -7568,11 +7604,11 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects The range \range{first}{last - 1} -shall be a valid heap with respect to \tcode{comp} and \tcode{proj}. +is a valid heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} requirements (\tref{cpp17.moveconstructible}) and the \oldconcept{MoveAssignable} requirements (\tref{cpp17.moveassignable}). @@ -7619,13 +7655,13 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects The range \range{first}{last} -shall be a valid non-empty heap with respect to \tcode{comp} and \tcode{proj}. +is a valid non-empty heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -7677,9 +7713,9 @@ for the overloads with no parameters by those names. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{Move\-Constructible} (\tref{cpp17.moveconstructible}) and \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. @@ -7726,15 +7762,15 @@ for the overloads with no parameters by those names. \pnum -\requires -The range \range{first}{last} shall be +\expects +The range \range{first}{last} is a valid heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet +\tcode{RandomAccessIterator} meets the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet +the type of \tcode{*first} meets the \oldconcept{MoveConst\-ruct\-ible} (\tref{cpp17.moveconstructible}) and -\oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) requirements. +\oldconcept{Move\-Assign\-able} (\tref{cpp17.moveassignable}) requirements. \pnum \effects @@ -7891,9 +7927,9 @@ \begin{itemdescr} \pnum -\requires -For the first form, type \tcode{T} shall be -\oldconcept{LessThanComparable} (\tref{cpp17.lessthancomparable}). +\expects +For the first form, \tcode{T} meets the +\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -7930,11 +7966,12 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{ranges::distance(r) > 0}. For the overloads in namespace \tcode{std}, -\tcode{T} shall be \oldconcept{Copy\-Constructible}. -For the first form, type \tcode{T} shall be \oldconcept{LessThanComparable}. +\tcode{T} meets the \oldconcept{\-Copy\-Constructible} requirements. +For the first form, \tcode{T} meets the \oldconcept{LessThanComparable} +requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -7968,9 +8005,9 @@ \begin{itemdescr} \pnum -\requires -For the first form, type \tcode{T} shall be -\oldconcept{LessThanComparable} (\tref{cpp17.lessthancomparable}). +\expects +For the first form, \tcode{T} meets the +\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -8007,11 +8044,12 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{ranges::distance(r) > 0}. For the overloads in namespace \tcode{std}, -\tcode{T} shall be \oldconcept{Copy\-Constructible}. -For the first form, type \tcode{T} shall be \oldconcept{LessThanComparable}. +\tcode{T} meets the \oldconcept{\-Copy\-Constructible} requirements. +For the first form, \tcode{T} meets the \oldconcept{LessThanComparable} +requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -8047,9 +8085,9 @@ \begin{itemdescr} \pnum -\requires -For the first form, type \tcode{T} shall be -\oldconcept{LessThanComparable} (\tref{cpp17.lessthancomparable}). +\expects +For the first form, \tcode{T} meets the +\oldconcept{LessThanComparable} requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -8087,11 +8125,12 @@ \begin{itemdescr} \pnum -\requires +\expects \tcode{ranges::distance(r) > 0}. For the overloads in namespace \tcode{std}, -\tcode{T} shall be \oldconcept{Copy\-Constructible}. -For the first form, type \tcode{T} shall be \oldconcept{LessThanComparable}. +\tcode{T} meets the \oldconcept{\-Copy\-Constructible} requirements. +For the first form, type \tcode{T} meets the \oldconcept{LessThanComparable} +requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -8267,10 +8306,11 @@ \begin{itemdescr} \pnum -\requires -The value of \tcode{lo} shall be no greater than \tcode{hi}. +\expects +The value of \tcode{lo} is no greater than \tcode{hi}. For the first form, type \tcode{T} -shall be \oldconcept{LessThan\-Comparable} (\tref{cpp17.lessthancomparable}). +meets the \oldconcept{LessThan\-Comparable} +requirements (\tref{cpp17.lessthancomparable}). \pnum \returns @@ -8389,9 +8429,8 @@ \begin{itemdescr} \pnum -\requires -\tcode{Cmp} shall be a function object type -whose return type is a comparison category type. +\mandates +\tcode{decltype(comp(*b1, *b2))} is a comparison category type. \pnum \effects @@ -8456,9 +8495,9 @@ for overloads with no parameters by those names. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet +\tcode{BidirectionalIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum @@ -8515,9 +8554,9 @@ for overloads with no parameters by those names. \pnum -\requires +\expects For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet +\tcode{BidirectionalIterator} meets the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum @@ -8808,13 +8847,13 @@ \begin{itemdescr} \pnum -\requires -\tcode{T} shall meet +\expects +\tcode{T} meets the \oldconcept{CopyConstructible} (\tref{cpp17.copyconstructible}) and \oldconcept{CopyAssignable} (\tref{cpp17.copyassignable}) requirements. In the range \crange{first}{last}, -\tcode{binary_op} shall neither modify elements -nor invalidate iterators or subranges.% +\tcode{binary_op} neither modifies elements +nor invalidates iterators or subranges.% \footnote{The use of fully closed ranges is intentional.} \pnum @@ -8913,18 +8952,26 @@ \end{itemdecl} \begin{itemdescr} + \pnum -\requires +\mandates +All of +\begin{itemize} +\item \tcode{binary_op(init, *first)}, +\item \tcode{binary_op(*first, init)}, +\item \tcode{binary_op(init, init)}, and +\item \tcode{binary_op(*first, *first)} +\end{itemize} +are convertible to \tcode{T}. + +\pnum +\expects \begin{itemize} \item - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}). -\item - All of \tcode{binary_op(init, *first)}, \tcode{binary_op(*first, init)}, - \tcode{binary_op(init, init)}, and \tcode{binary_op(*first, *first)} - shall be convertible to \tcode{T}. + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements. \item - \tcode{binary_op} shall neither invalidate iterators or subranges, - nor modify elements in the range \crange{first}{last}. + \tcode{binary_op} neither invalidates iterators or subranges, + nor modifies elements in the range \crange{first}{last}. \end{itemize} \pnum @@ -8963,14 +9010,14 @@ \begin{itemdescr} \pnum -\requires -\tcode{T} shall meet +\expects +\tcode{T} meets the \oldconcept{CopyConstructible} (\tref{cpp17.copyconstructible}) and \oldconcept{CopyAssignable} (\tref{cpp17.copyassignable}) requirements. In the ranges \crange{first1}{last1} and \crange{first2}{first2 + (last1 - first1)} \tcode{binary_op1} and \tcode{binary_op2} -shall neither modify elements nor invalidate iterators or subranges.% +neither modifies elements nor invalidates iterators or subranges.% \footnote{The use of fully closed ranges is intentional.} \pnum @@ -9045,22 +9092,24 @@ \begin{itemdescr} \pnum -\requires -\begin{itemize} -\item - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}). -\item - All of +\mandates +All of \begin{itemize} \item \tcode{binary_op1(init, init)}, \item \tcode{binary_op1(init, binary_op2(*first1, *first2))}, \item \tcode{binary_op1(binary_op2(*first1, *first2), init)}, and \item \tcode{binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))} \end{itemize} - shall be convertible to \tcode{T}. + are convertible to \tcode{T}. + +\pnum +\expects +\begin{itemize} +\item + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements. \item Neither \tcode{binary_op1} nor \tcode{binary_op2} - shall invalidate subranges, nor modify elements in the ranges + invalidates subranges, nor modifies elements in the ranges \crange{first1}{last1} and \crange{first2}{first2 + (last1 - first1)}. \end{itemize} @@ -9093,11 +9142,7 @@ \begin{itemdescr} \pnum -\requires -\begin{itemize} -\item - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}). -\item +\mandates All of \begin{itemize} \item \tcode{binary_op(init, init)}, @@ -9105,10 +9150,16 @@ \item \tcode{binary_op(unary_op(*first), init)}, and \item \tcode{binary_op(unary_op(*first), unary_op(*first))} \end{itemize} - shall be convertible to \tcode{T}. + are convertible to \tcode{T}. + +\pnum +\expects +\begin{itemize} \item - Neither \tcode{unary_op} nor \tcode{binary_op} shall invalidate subranges, - nor modify elements in the range \crange{first}{last}. + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements. +\item + Neither \tcode{unary_op} nor \tcode{binary_op} invalidates subranges, + nor modifies elements in the range \crange{first}{last}. \end{itemize} \pnum @@ -9145,17 +9196,18 @@ \begin{itemdescr} \pnum -\requires -\tcode{InputIterator}'s value type shall be constructible -from the type of \tcode{*first}. +\mandates +\tcode{InputIterator}'s value type is constructible from \tcode{*first}. The result of the expression \tcode{std::move(acc) + *i} or \tcode{binary_op(std::move(acc), *i)} -shall be implicitly convertible to \tcode{InputIterator}'s value type. -\tcode{acc} shall be writable\iref{iterator.requirements.general} to -the \tcode{result} output iterator. +is implicitly convertible to \tcode{InputIt\-er\-a\-tor}'s value type. +\tcode{acc} is writable\iref{iterator.requirements.general} to \tcode{result}. + +\pnum +\expects In the ranges \crange{first}{last} and \crange{result}{result + (last - first)} -\tcode{binary_op} shall neither modify elements -nor invalidate iterators or subranges.% +\tcode{binary_op} neither modifies elements +nor invalidates iterators or subranges.% \footnote{The use of fully closed ranges is intentional.} \pnum @@ -9237,19 +9289,24 @@ \begin{itemdescr} \pnum -\requires +\mandates + All of + \begin{itemize} + \item \tcode{binary_op(init, init)}, + \item \tcode{binary_op(init, *first)}, and + \item \tcode{binary_op(*first, *first)} + \end{itemize} + are convertible to \tcode{T}. + + +\pnum +\expects \begin{itemize} \item - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}). + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements. \item - All of - \tcode{binary_op(init, init)}, - \tcode{binary_op(init, *first)}, - and \tcode{binary_op(*first, *first)} - shall be convertible to \tcode{T}. -\item - \tcode{binary_op} shall neither invalidate iterators or subranges, - nor modify elements in + \tcode{binary_op} neither invalidates iterators or subranges, + nor modifies elements in the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} @@ -9351,24 +9408,28 @@ Let \tcode{U} be the value type of \tcode{decltype(first)}. \pnum -\requires +\mandates +If \tcode{init} is provided, all of +\begin{itemize} +\item \tcode{binary_op(init, init)}, +\item \tcode{binary_op(init, *first)}, and +\item \tcode{binary_op(*first, *first)} +\end{itemize} +are convertible to \tcode{T}; +otherwise, \tcode{binary_op(*first, *first)} +is convertible to \tcode{U}. + +\pnum +\expects \begin{itemize} \item If \tcode{init} is provided, - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}); + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements; otherwise, \tcode{U} - shall be \oldconcept{MoveConstructible}. -\item - If \tcode{init} is provided, all of - \tcode{binary_op(init, init)}, - \tcode{binary_op(init, *first)}, and - \tcode{binary_op(*first, *first)} - shall be convertible to \tcode{T}; - otherwise, \tcode{binary_op(*first, *first)} - shall be convertible to \tcode{U}. -\item - \tcode{binary_op} shall neither invalidate iterators or subranges, - nor modify elements in + meets the \oldconcept{MoveConstructible} requirements. +\item + \tcode{binary_op} neither invalidates iterators or subranges, + nor modifies elements in the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} @@ -9429,21 +9490,23 @@ \begin{itemdescr} \pnum -\requires -\begin{itemize} -\item - \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}). -\item +\mandates All of \begin{itemize} \item \tcode{binary_op(init, init)}, \item \tcode{binary_op(init, unary_op(*first))}, and \item \tcode{binary_op(unary_op(*first), unary_op(*first))} \end{itemize} - shall be convertible to \tcode{T}. + are convertible to \tcode{T}. + +\pnum +\expects +\begin{itemize} \item - Neither \tcode{unary_op} nor \tcode{binary_op} shall - invalidate iterators or subranges, nor modify elements in + \tcode{T} meets the \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements. +\item + Neither \tcode{unary_op} nor \tcode{binary_op} + invalidates iterators or subranges, nor modifies elements in the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} @@ -9523,26 +9586,28 @@ Let \tcode{U} be the value type of \tcode{decltype(first)}. \pnum -\requires +\mandates +If \tcode{init} is provided, all of +\begin{itemize} +\item \tcode{binary_op(init, init)}, +\item \tcode{binary_op(init, unary_op(*first))}, and +\item \tcode{binary_op(unary_op(*first), unary_op(*first))} +\end{itemize} +are convertible to \tcode{T}; +otherwise, \tcode{binary_op(unary_op(*first), unary_op(*first))} +is convertible to \tcode{U}. + +\pnum +\expects \begin{itemize} \item - If \tcode{init} is provided, \tcode{T} shall be - \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}); - otherwise, \tcode{U} shall be - \oldconcept{MoveConstructible}. + If \tcode{init} is provided, \tcode{T} meets the + \oldconcept{MoveConstructible} (\tref{cpp17.moveconstructible}) requirements; + otherwise, \tcode{U} meets the + \oldconcept{MoveConstructible} requirements. \item - If \tcode{init} is provided, all of - \begin{itemize} - \item \tcode{binary_op(init, init)}, - \item \tcode{binary_op(init, unary_op(*first))}, and - \item \tcode{binary_op(unary_op(*first), unary_op(*first))} - \end{itemize} - shall be convertible to \tcode{T}; - otherwise, \tcode{binary_op(unary_op(*first), unary_op(*first))} - shall be convertible to \tcode{U}. -\item - Neither \tcode{unary_op} nor \tcode{binary_op} shall - invalidate iterators or subranges, nor modify elements in + Neither \tcode{unary_op} nor \tcode{binary_op} invalidates + iterators or subranges, nor modifies elements in the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} @@ -9617,29 +9682,38 @@ that denotes an object of type \tcode{minus<>}. \pnum -\requires +\mandates \begin{itemize} \item For the overloads with no \tcode{ExecutionPolicy}, - \tcode{T} shall be \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) and - shall be constructible from the type of \tcode{*first}. - \tcode{acc} (defined below) shall be + \tcode{T} is constructible from \tcode{*first}. + \tcode{acc} (defined below) is writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. The result of the expression \tcode{binary_op(val, std::move(acc))} - shall be writable to the \tcode{result} output iterator. + is writable to \tcode{result}. \item For the overloads with an \tcode{ExecutionPolicy}, the result of the expressions \tcode{binary_op(*first, *first)} and - \tcode{*first} shall be writable to \tcode{result}. + \tcode{*first} are writable to \tcode{result}. +\end{itemize} + +\pnum +\expects +\begin{itemize} +\item + For the overloads with no \tcode{ExecutionPolicy}, + \tcode{T} meets the \oldconcept{MoveAssignable} (\tref{cpp17.moveassignable}) + requirements. \item For all overloads, in the ranges \crange{first}{last} and \crange{result}{result + (last - first)}, - \tcode{binary_op} shall neither modify elements + \tcode{binary_op} neither modifies elements nor invalidate iterators or subranges.% \footnote{The use of fully closed ranges is intentional.} \end{itemize} + \pnum \effects For the overloads with no \tcode{ExecutionPolicy} and a non-empty range, @@ -9686,10 +9760,10 @@ \begin{itemdescr} \pnum -\requires -\tcode{T} shall be convertible to \tcode{ForwardIterator}'s value type. +\mandates +\tcode{T} is convertible to \tcode{ForwardIterator}'s value type. The expression \tcode{++val}, where \tcode{val} has type \tcode{T}, -shall be well-formed. +is well-formed. \pnum \effects @@ -9713,19 +9787,20 @@ \begin{itemdescr} \pnum -\requires +\mandates +\tcode{M} and \tcode{N} both are integer types and not +\cv{}~\tcode{bool}. + +\pnum +\expects $|\tcode{m}|$ and $|\tcode{n}|$ -shall be representable as a value of \tcode{common_type_t}. +are representable as a value of \tcode{common_type_t}. \begin{note} These requirements ensure, for example, that $\tcode{gcd(m, m)} = |\tcode{m}|$ is representable as a value of type \tcode{M}. \end{note} -\pnum -\remarks -If either \tcode{M} or \tcode{N} is not an integer type, or -if either is \cv{}~\tcode{bool}, the program is ill-formed. \pnum \returns @@ -9747,16 +9822,17 @@ \begin{itemdescr} \pnum -\requires +\mandates +\tcode{M} and \tcode{N} both are integer types and not +\cv{}~\tcode{bool}. + +\pnum +\expects $|\tcode{m}|$ and $|\tcode{n}|$ -shall be representable as a value of \tcode{common_type_t}. +are representable as a value of \tcode{common_type_t}. The least common multiple of $|\tcode{m}|$ and $|\tcode{n}|$ -shall be representable as a value of type \tcode{common_type_t}. +is representable as a value of type \tcode{common_type_t}. -\pnum -\remarks -If either \tcode{M} or \tcode{N} is not an integer type, or -if either is \cv{}~\tcode{bool} the program is ill-formed. \pnum \returns @@ -9846,9 +9922,8 @@ These functions have the semantics specified in the C standard library. \pnum -\remarks -The behavior is undefined -unless the objects in the array pointed to by \tcode{base} are of trivial type. +\expects +The objects in the array pointed to by \tcode{base} are of trivial type. \pnum \throws