1

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.

2
  • 1
    In cppreference, for inclusive_scan "d_first - the beginning of the destination range; may be equal to first". Commented Aug 14, 2023 at 2:00
  • I would expect that the parallel versions would not be able to share an input and output range, but I haven't checked. Commented Dec 19, 2023 at 1:16

1 Answer 1

0

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.