std::transform_reduce
Defined in header <numeric>
|
||
template< class InputIt1, class InputIt2, class T > T transform_reduce( InputIt1 first1, InputIt1 last1, |
(1) | (since C++17) (constexpr since C++20) |
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T > |
(2) | (since C++17) |
template< class InputIt1, class InputIt2, class T, class BinaryOp1, class BinaryOp2 > |
(3) | (since C++17) (constexpr since C++20) |
template< class ExecutionPolicy, class ForwardIt1, class ForwardIt2, class T, |
(4) | (since C++17) |
template< class InputIt, class T, class BinaryOp, class UnaryOp > |
(5) | (since C++17) (constexpr since C++20) |
template< class ExecutionPolicy, class ForwardIt, class T, |
(6) | (since C++17) |
std::plus<>(), std::multiplies<>()), effectively parallelized version of the default std::inner_product.
[
first1,
last1)
and the range of std::distance(first1, last1) elements starting from first2 and reduces the results (possibly permuted and aggregated in unspecified manner) along with the initial value init over reduce.T
, the program is ill-formed:
- reduce(init, init)
- reduce(init, transform(*first1, *first2))
- reduce(transform(*first1, *first2), init)
- reduce(transform(*first1, *first2), transform(*first1, *first2))
-
T
is not MoveConstructible. - transform or reduce modifies any element of
[
first1,
last1)
or[
first2,
last2)
. - transform or reduce invalidates any iterator or subrange of
[
first1,
last1]
or[
first2,
last2]
.
[
first,
last)
and reduces the results (possibly permuted and aggregated in unspecified manner) along with the initial value init over reduce.T
, the program is ill-formed:
- reduce(init, init)
- reduce(init, transform(*first))
- reduce(transform(*first), init)
- reduce(transform(*first), transform(*first))
-
T
is not MoveConstructible. - transform or reduce modifies any element of
[
first,
last)
. - transform or reduce invalidates any iterator or subrange of
[
first,
last]
.
std::is_execution_policy_v<std::decay_t<ExecutionPolicy>> is true. |
(until C++20) |
std::is_execution_policy_v<std::remove_cvref_t<ExecutionPolicy>> is true. |
(since C++20) |
Contents |
[edit] Parameters
first1, last1 | - | the pair of iterators defining the range of elements to be taken as the left operand of transform |
first2 | - | the start of range of elements to be taken as the right operand of transform |
first, last | - | the pair of iterators defining the range of elements to be taken as the operand of transform |
init | - | the initial value of the generalized sum |
policy | - | the execution policy to use |
reduce | - | binary FunctionObject that will be applied in unspecified order to the results of transform, the results of other reduce and init. |
transform | - | unary or binary FunctionObject that will be applied to each element of the input range(s). The return type must be acceptable as input to reduce. |
Type requirements | ||
-InputIt1, InputIt2, InputIt must meet the requirements of |