Perhaps an example of this working? What are you passing in as the OutputIterator? If the algorithm isn’t writing to the OutputIterator while it’s finding elements, then when it finds a missing element, it would have to go back and copy the first how many ever elements that did match. But, the those are InputIterators: you may not be able to rewind those iterators back to the beginning. (Iterators on cin, for example)It also means that wherever the OutputIterator points at may never have been written to (consider output iterators on cout) in the case that the intersection is all elements of both sequences. The caller would have to compare the result with first1 and first2 to figure out if they got back an iterator to either of the inputs.On Sun, Sep 14, 2025 at 6:52 AM Peter Neiss via Std-Proposals <std-proposals@lists.isocpp.org> wrote:The std::set_intersection algorithm forbids overlap of the input ranges with the output range, but if first1 or first2 and result would be equal, the algorithm could still work(see cppreference for possible implementation).
This would allow inplace execution without memory allocation, which is a big plus.26.8.7.4 set_intersection (wording)
replace: The resulting range does not overlap with either of the original ranges.
with: result may be equal to first1 or first2, otherwise the resulting range does not overlap with either of the original ranges.
PS: I am quite sure my statement is correct and I am not making a fool out of myself. Still confirmation of my claim would be great.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals