Cppreference has this example code for std::transform:
std::vector ordinals;
std::transform(s.begin(), s.end(), std::back_inserter(ordinals),
So the thing I missed is that the parallel versions take LegacyForwardIterators, not LegacyOutputIterator
. A LegacyForwardIterator
can be incremented without invalidating copies of it, so it is easy to use this to implement an out-of-order parallel std::transform
.
I think the non-parallel versions of std::transform
must be executed in-order. Either cppreference is wrong about it, or possibly the standard just leaves this requirement implicit because there is no other way to implement it. (Shotgun not wading through the standard to find out!)