Mandates: All of
— binary_op(init, init),
— binary_op(init, unary_op(first)),
— binary_op(unary_op(first), init), and
— binary_op(unary_op(first), unary_op(first))
are convertible to T.
This was stated with "Requires:" in C++17, but in C++20 violating the requirement must be diagnosed.
Example:
include
include
int main() {
int a[]{ 1 };
auto r = std::transform_reduce(
std::execution::seq, a, a+1, 0,
[](int& a, int b) {
return a + b;
},
[](int i) { return i; });
}
This compiles without error using GCC's copy of the PSTL code.
Extended Description
For example:
Mandates: All of — binary_op(init, init), — binary_op(init, unary_op(first)), — binary_op(unary_op(first), init), and — binary_op(unary_op(first), unary_op(first)) are convertible to T.
This was stated with "Requires:" in C++17, but in C++20 violating the requirement must be diagnosed.
Example:
include
include
int main() { int a[]{ 1 };
auto r = std::transform_reduce( std::execution::seq, a, a+1, 0, [](int& a, int b) { return a + b; }, [](int i) { return i; }); }
This compiles without error using GCC's copy of the PSTL code.