Can output range of algorithms in <numeric> in C++ overlap with the input range?

68 Views Asked by At

There are six algorithms that will output a range(which is denoted by an output iterator) in <numeric>: adjacent_difference, partial_sum, inclusive_scan, exclusive_scan, transform_inclusive_scan and transform_exclusive_scan. Can their input ranges overlap with output ranges? What about their parallel version?

I've tried to find some hints in the C++ standard with no luck.

1

There are 1 best solutions below

0
Marshall Clow On BEST ANSWER

See the remarks at https://eel.is/c++draft/numeric.ops.

Search for 'Remarks: result may be equal to first'

All of the algorithms that you asked about except adjacent_difference have that remark.

So the output range can be the same as the input range. That's more restrictive than what you asked about (can they overlap).