[PATH 3/3] libstdc++: Add std::advance ostreambuf_iterator overload

François Dumont frs.dumont@gmail.com
Mon Sep 14 20:36:27 GMT 2020


On 10/09/20 5:19 pm, Jonathan Wakely wrote:
> On 09/09/20 22:12 +0200, François Dumont via Libstdc++ wrote:
>> libstdc++: Add std::advance overload for ostreambuf_iterator
>>
>> Implement std::advance overload for ostreambuf_iterator using 
>> basic_streambuf
>> pubseekof.
>>
>> libstdc++-v3/ChangeLog:
>>
>>         * include/bits/streambuf_iterator.h 
>> (ostreambuf_iterator): Add
>>         std::advance friend declaration.
>>         (advance(ostreambuf_iterator<>&, _Distance)): New.
>>         * 
>> testsuite/25_algorithms/advance/ostreambuf_iterator/char/1.cc:
>>         New test.
>>         * 
>> testsuite/25_algorithms/advance/ostreambuf_iterator/char/1_neg.cc:
>>         New test.
>>         * 
>> testsuite/25_algorithms/advance/ostreambuf_iterator/char/2.cc:
>>         New test.
>>         * 
>> testsuite/25_algorithms/advance/ostreambuf_iterator/char/2_neg.cc:
>>         New test.
>>
>> Tested under Linux x85_64.
>>
>> Ok to commit ?
>
> I think relying on seeking here is a bad idea for the same reason as
> in my previous email. We don't know what seek does for an arbitrary
> derived streambuf, or even if it is possible at all.
>
>
After having implementing it similarly to the overload on 
istreambuf_iterator I wrote a test to compare the std;;advance behavior 
with a manual increment. And so I realized that incrementing a 
ostreambuf_iterator is a no-op and so must be the std::advance unless 
you tell otherwise.

There was a reason for this overload to be missing.

Thanks for the review,

François



More information about the Libstdc++ mailing list