26 Numerics library [numerics]

26.8 Generalized numeric operations [numeric.ops]

26.8.7 Exclusive scan [exclusive.scan]

template<class InputIterator, class OutputIterator, class T> OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init);

Effects: Equivalent to:

return exclusive_scan(first, last, result, init, plus<>());

template<class ExecutionPolicy, class InputIterator, class OutputIterator, class T> OutputIterator exclusive_scan(ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result, T init);

Effects: Equivalent to:

return exclusive_scan(std::forward<ExecutionPolicy>(exec), first, last, result, init, plus<>());

template<class InputIterator, class OutputIterator, class T, class BinaryOperation> OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op); template<class ExecutionPolicy, class InputIterator, class OutputIterator, class T, class BinaryOperation> OutputIterator exclusive_scan(ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op);

Requires: binary_op shall neither invalidate iterators or subranges, nor modify elements in the ranges [first, last) or [result, result + (last - first)).

Effects: Assigns through each iterator i in [result, result + (last - first)) the value of GENERALIZED_NONCOMMUTATIVE_SUM(binary_op, init, *j, ...) for every j in [first, first + (i - result)).

Returns: The end of the resulting range beginning at result.

Complexity: Ο(last - first) applications of binary_op.

Remarks: result may be equal to first.

Notes: The difference between exclusive_scan and inclusive_scan is that exclusive_scan excludes the ith input element from the ith sum. If binary_op is not mathematically associative, the behavior of exclusive_scan may be nondeterministic.