On Tue, 15 Oct 2019 at 21:20, François Dumont wrote:
>
> Here is an update to set _M_sbuf to null if the user advance too much.
>
> Note that in this case the streambuf remains un-modified which is
> different from the current implementation. I think it is another
> enhancement.
>
> I also change the Debug assertion message for something more dedicated
> to std::advance algo.
>
> François
>
> On 10/14/19 10:12 PM, François Dumont wrote:
> > The same way I proposed to review std::copy overload for
> > istreambuf_iterator we can implement std::advance using pubseekoff.
> >
> > It is both a cleaner implementation and avoids yet another friend
> > declaration.

Looks like I never sent my review of this one, it's been sitting in my
draft mails for years, sorry.

It looks like this will fail if the streambuf doesn't support seeking.
The default behaviour for seekoff is to return -1, in which case
you'll get -1 for both calls to pubseekoff, and new_pos - cur_pos will
be zero, which is not equal to n, so you set the istreambuf_iterator
to end-of-stream. That seems wrong, we could still advance using the
old code (or just call ++ in a loop!)



> >
> >     * include/std/streambuf
> >     (advance(istreambuf_iterator<>&, _Distance)): Remove friend
> > declaration.
> >     * include/bits/streambuf_iterator.h (__copy_move_a2): Re-implement
> > using
> >     streambuf pubseekoff.
> >
> > Tested under Linux x86_64.
> >
> > Ok to commit ?
> >
> > François
> >
>

Reply via email to