cpp/algorithm/transform inclusive scan

Transforms each element in the range with, then computes an inclusive prefix sum operation using  over the resulting range, optionally with  as the initial value, and writes the results to the range beginning at. Inclusive means that the i$th$ input element is included in the i$th$ sum.

Formally, assigns through each iterator in  the value of
 * for overloads, the generalized noncommutative sum of for every  in  over ,
 * for overloads, the generalized noncommutative sum of for every  in  over ,

where generalized noncommutative sum $GNSUM(op, a 1, ..., a N)$ is defined as follows:
 * if $N = 1$, $a 1$
 * if $N > 1$, $op(GNSUM(op, a 1, ..., a K), GNSUM(op, a M, ..., a N))$ for any K where $1 < K + 1 = M ≤ N$.

In other words, the summation operations may be performed in arbitrary order, and the behavior is nondeterministic if is not associative.

Overloads are executed according to.

and shall not invalidate iterators (including the end iterators) or subranges, nor modify elements in the ranges  or. Otherwise, the behavior is undefined.

Return value
Iterator to the element past the last element written.

Complexity
$O(last - first)$ applications of each of and.