Skip to content

Commit 7649c82

Browse files
tkoeppezygoloid
authored andcommitted
P0616R0 Depessimize numeric algorithms with std::move
The wording changes have been applied to the intended place in the current working paper, with LWG approval, despite having been given relative to an older draft in P0616R0.
1 parent 99e5d25 commit 7649c82

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

source/numerics.tex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8807,9 +8807,9 @@
88078807
with the initial value
88088808
\tcode{init}
88098809
and then modifies it with
8810-
\tcode{acc = acc + *i}
8810+
\tcode{acc = std::move(acc) + *i}
88118811
or
8812-
\tcode{acc = binary_op(acc, *i)}
8812+
\tcode{acc = binary_op(std::move(acc), *i)}
88138813
for every iterator
88148814
\tcode{i}
88158815
in the range \range{first}{last}
@@ -8961,9 +8961,9 @@
89618961
with the initial value
89628962
\tcode{init}
89638963
and then modifying it with
8964-
\tcode{acc = acc + (*i1) * (*i2)}
8964+
\tcode{acc = std::move(acc) + (*i1) * (*i2)}
89658965
or
8966-
\tcode{acc = binary_op1(acc, binary_op2(*i1, *i2))}
8966+
\tcode{acc = binary_op1(std::move(acc), binary_op2(*i1, *i2))}
89678967
for every iterator
89688968
\tcode{i1}
89698969
in the range \range{first1}{last1}
@@ -9114,7 +9114,7 @@
91149114
\pnum
91159115
\requires
91169116
\tcode{InputIterator}'s value type shall be constructible from the type of \tcode{*first}.
9117-
The result of the expression \tcode{acc + *i} or \tcode{binary_op(acc, *i)} shall be
9117+
The result of the expression \tcode{std::move(acc) + *i} or \tcode{binary_op(std::move(acc), *i)} shall be
91189118
implicitly convertible to \tcode{InputIterator}'s value type. \tcode{acc}
91199119
shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator.
91209120
In the ranges
@@ -9130,7 +9130,7 @@
91309130
the function creates an accumulator \tcode{acc} whose type is \tcode{InputIterator}'s
91319131
value type, initializes it with \tcode{*first},
91329132
and assigns the result to \tcode{*result}. For every iterator \tcode{i} in \range{first + 1}{last}
9133-
in order, \tcode{acc} is then modified by \tcode{acc = acc + *i} or \tcode{acc = binary_op(acc, *i)}
9133+
in order, \tcode{acc} is then modified by \tcode{acc = std::move(acc) + *i} or \tcode{acc = binary_op(std::move(acc), *i)}
91349134
and the result is assigned to \tcode{*(result + (i - first))}.
91359135

91369136
\pnum
@@ -9540,8 +9540,8 @@
95409540
type shall be \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}) and shall
95419541
be constructible from the type of \tcode{*first}. \tcode{acc} (defined below)
95429542
shall be writable\iref{iterator.requirements.general} to the \tcode{result}
9543-
output iterator. The result of the expression \tcode{val - acc} or
9544-
\tcode{binary_op(val, acc)} shall be writable to the \tcode{result} output iterator.
9543+
output iterator. The result of the expression \tcode{val - std::move(acc)} or
9544+
\tcode{binary_op(val, std::move(acc))} shall be writable to the \tcode{result} output iterator.
95459545

95469546
\item
95479547
For the overloads with an \tcode{ExecutionPolicy}, the value type of
@@ -9567,7 +9567,7 @@
95679567
value type, initializes it with \tcode{*first},
95689568
and assigns the result to \tcode{*result}. For every iterator \tcode{i} in \range{first + 1}{last}
95699569
in order, creates an object \tcode{val} whose type is \tcode{InputIterator}'s value type, initializes it
9570-
with \tcode{*i}, computes \tcode{val - acc} or \tcode{binary_op(val, acc)}, assigns the result
9570+
with \tcode{*i}, computes \tcode{val - std::move(acc)} or \tcode{binary_op(val, std::move(acc))}, assigns the result
95719571
to \tcode{*(result + (i - first))}, and move assigns from \tcode{val} to \tcode{acc}.
95729572

95739573
\pnum

0 commit comments

Comments
 (0)