Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-03-31 21:47:46


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk