Defined in header <numeric>
template< class InputIt, class OutputIt,
class BinaryOperation, class UnaryOperation >
OutputIt transform_inclusive_scan( InputIt (since C++17)
first, InputIt last, OutputIt d_first, (until C++20)
BinaryOperation binary_op, UnaryOperation
unary_op );
template< class InputIt, class OutputIt,
class BinaryOperation, class UnaryOperation >
constexpr OutputIt transform_inclusive_scan(
InputIt first, InputIt last, (since C++20)
OutputIt d_first,
BinaryOperation binary_op,
UnaryOperation unary_op );
template< class ExecutionPolicy, class
ForwardIt1, class ForwardIt2,
class BinaryOperation, class UnaryOperation >
ForwardIt2 transform_inclusive_scan(
ExecutionPolicy&& policy, (2) (since C++17)
ForwardIt1 first, ForwardIt1 last, ForwardIt2
d_first,
BinaryOperation binary_op, UnaryOperation
unary_op );
template< class InputIt, class OutputIt,
class BinaryOperation, class UnaryOperation, (1)
class T >
OutputIt transform_inclusive_scan( InputIt (since C++17)
first, InputIt last, OutputIt d_first, (until C++20)
BinaryOperation binary_op, UnaryOperation
unary_op,
T init );
template< class InputIt, class OutputIt,
class BinaryOperation, class UnaryOperation,
class T >
constexpr OutputIt transform_inclusive_scan(
InputIt first, InputIt last, (since C++20)
OutputIt d_first, (3)
BinaryOperation binary_op,
UnaryOperation unary_op,
T init );
template< class ExecutionPolicy, class
ForwardIt1, class ForwardIt2,
class BinaryOperation, class UnaryOperation,
class T >
ForwardIt2 transform_inclusive_scan(
ExecutionPolicy&& policy, (4) (since C++17)
ForwardIt1 first, ForwardIt1 last, ForwardIt2
d_first,
BinaryOperation binary_op, UnaryOperation
unary_op,
T init );
Transforms each element in the range [first, last) with unary_op, then
computes an
inclusive prefix sum operation using binary_op over the resulting range,
optionally
with init as the initial value, and writes the results to the range beginning
at
d_first. "inclusive" means that the i-th input element is included
in the i-th sum.
Formally, assigns through each iterator i in [d_first, d_first + (last -
first)) the
value of
* for overloads (1-2), the generalized noncommutative sum of unary_op(*j)...
for
every j in [first, first + (i - d_first + 1)) over binary_op,
* for overloads (3-4), the generalized noncommutative sum of init,
unary_op(*j)...
for every j in [first, first + (i - d_first + 1)) over binary_op,
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 binary_op is not associative.
Overloads (2, 4) are executed according to policy. These overloads do not
participate in overload resolution unless
std::is_execution_policy_v<std::decay_t<ExecutionPolicy>>
(until C++20)
std::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>>
(since C++20) is true.
unary_op and binary_op shall not invalidate iterators (including the end
iterators)
or subranges, nor modify elements in the ranges [first, last) or [d_first,
d_first +
(last - first)). Otherwise, the behavior is undefined.