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. > > >     * 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 >