Files
2025-10-25 03:02:53 +03:00

3.5 KiB

[transform.exclusive.scan]

26 Algorithms library [algorithms]

26.10 Generalized numeric operations [numeric.ops]

26.10.10 Transform exclusive scan [transform.exclusive.scan]

🔗

template<class InputIterator, class OutputIterator, class T, class BinaryOperation, class UnaryOperation> constexpr OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op, UnaryOperation unary_op); template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class T, class BinaryOperation, class UnaryOperation> ForwardIterator2 transform_exclusive_scan(ExecutionPolicy&& exec, ForwardIterator1 first, ForwardIterator1 last, ForwardIterator2 result, T init, BinaryOperation binary_op, UnaryOperation unary_op);

1

#

Mandates: All of

binary_op(init, init),

binary_op(init, unary_op(*first)), and

binary_op(unary_op(*first), unary_op(*first))

are convertible to T.

2

#

Preconditions:

  • (2.1)

    T meets the Cpp17MoveConstructible (Table 31) requirements.

  • (2.2)

    Neither unary_op nor binary_op invalidates iterators or subranges, nor modifies elements in the ranges [first, last] or [result, result + (last - first)].

3

#

Effects: For each integer K in [0, last - first) assigns through result + K the value of:GENERALIZED_NONCOMMUTATIVE_SUM( binary_op, init, unary_op((first + 0)), unary_op((first + 1)), …, unary_op(*(first + K - 1)))

4

#

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

5

#

Complexity: O(last - first) applications each of unary_op and binary_op.

6

#

Remarks: result may be equal to first.

7

#

[Note 1:

The difference between transform_exclusive_scan andtransform_inclusive_scan is that transform_exclusive_scan excludes the ith input element from the ith sum.

If binary_op is not mathematically associative, the behavior of transform_exclusive_scan can be nondeterministic.

transform_exclusive_scan does not apply unary_op to init.

— end note]