On 14/09/20 22:36 +0200, François Dumont via Libstdc++ wrote:
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.
OK, good to know.