[PATCH 1/2] libstdc++: Introduce notion of segmented iterators

Jonathan Wakely jwakely.gcc@gmail.com
Wed Jul 15 07:02:33 GMT 2026


On Tue, 14 Jul 2026, 15:56 Tomasz Kaminski, <tkaminsk@redhat.com> wrote:

>
>
>
>>
>> fold_right{, _last} could use backward iteration, but it can also be
>> implemented with reverse iterators.
>>
> Is there a big benefit from iterating over segments, versus the whole range
> for fold? And other algorithms that visit all elements. I was thinking
> mostly
> about cases like distance (where we can compare iterators), or copy
> (when we could `memcpy` the segment).
>


Right, there are certainly algorithms that iterate backwards (copy_backward
for an obvious example!) but I don't think they benefit from having
contiguous or random access iterators, rather than just bidirectional. So I
don't think optimising for segments matters.



>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260715/4cf65a92/attachment-0001.htm>


More information about the Libstdc++ mailing list