public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Implement std::advance for istreambuf_iterator using pubseekoff
Date: Fri, 31 Mar 2023 22:03:23 +0100	[thread overview]
Message-ID: <CACb0b4ncUyM5hMw8PPU6Hh_Xf+MNLGpfUFO0cGAQEUNBXPjqyw@mail.gmail.com> (raw)
In-Reply-To: <00a8f27e-cc72-9852-45b3-1a1082d25ea2@gmail.com>

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	other threads:[~2023-03-31 21:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 20:13 François Dumont
2019-10-15 20:31 ` François Dumont
2023-03-31 21:03   ` Jonathan Wakely [this message]
2023-04-24 17:24     ` François Dumont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACb0b4ncUyM5hMw8PPU6Hh_Xf+MNLGpfUFO0cGAQEUNBXPjqyw@mail.gmail.com \
    --to=jwakely@redhat.com \
    --cc=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).