31 Mar
2021
31 Mar
'21
9:47 p.m.
Andrzej Krzemienski wrote:
So, you are saying the following:
std::transform(v1.begin(), v1.end(), v2.begin(), out.begin(), _2);
would mean select the second element? Yeah. This looks practical, and uniform with the rest of the library.
Yes. In this specific example this doesn't look very useful, but the ranges version std::ranges::transform( r1, r2, r2.begin(), _1 ); actually does something useful - it assigns the elements of r1 to r2, but if the sizes of r1 and r2 don't match, it doesn't overrun the destination.