<div dir="auto">And then there&#39;s a new requirement of iterator stability for that case? Sounds like a tricky sharp edge...</div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sun, 14 Sept 2025, 18:30 Peter Neiss via Std-Proposals, &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello Phil,<div>i disagree with the inplace_set_intersection solution. I read up on weak ordering. If the input ranges overlap, the intersection is part of this overlap which either does not change or is already read before overwritten in a good algorithm.</div><div>I think we can just improve the std::set_intersection preconditions and stuff that already works also becomes legal and is not arbitrarily illegal in the standard.</div><div>Regards,</div><div>Peter</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am So., 14. Sept. 2025 um 19:22 Uhr schrieb Phil Endecott via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank" rel="noreferrer">std-proposals@lists.isocpp.org</a>&gt;:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Peter Neiss wrote:<br>
&gt; The std::set_intersection algorithm forbids overlap of the input ranges<br>
&gt; with the output range, but if first1 or first2 and result would be equal,<br>
&gt; the algorithm could still work<br>
<br>
I suggest a new name and signature, rather than changing<br>
std::set_intersection:<br>
<br>
   template &lt;class It1, class It2&gt;<br>
   It1 inplace_set_intersection(It1 first1, It1 last1, It2 first2, It2 last2);<br>
<br>
Range first2...last2 is read from sequentially and not modified;<br>
I guess It2 is an InputItrator.<br>
<br>
Range first1...last1 is read from and modified; the result is the range<br>
from first1 to the returned iterator. Maybe It1 needs to be a<br>
ForwardIterator? Not sure.<br>
<br>
There are a couple of choices for how the range between the end<br>
of the result and last1 is left; the elements can either be moved<br>
or swapped. I guess this range should be left valid-but-undefined.<br>
<br>
I&#39;m not sure if this is worth having in the standard library; anyone<br>
could write it themselves in a few minutes. Maybe its value would<br>
be to prevent people from wrongly assuming that std::set_intersection<br>
can already be used in this way!<br>
<br>
<br>
Regards, Phil.<br>
<br>
<br>
<br>
<br>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank" rel="noreferrer">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank" rel="noreferrer">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</blockquote></div>

