From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 2602F3858025 for ; Fri, 31 Mar 2023 21:03:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2602F3858025 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680296617; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oxkdx0Z4lBYWbBLnH3tj2VhMGwq0HeKSBwgKK/oTDME=; b=jAHdRSkZ1splfCObrmv1HzBMY9RQ9AEjUru17r7p+jECpqXkRF2adNVggm4V4Kxr+arq2D zKdAOemffXSrd5F4og5dktMNUJmhAhvu5c+mNhYMJ90OywGNo4MIf2gw3wGqu/wXQhaNEn GpvPvprlo5+G0xm1zehUVf+Qe3/cG8k= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-O6VN0jsKN1em2aiD-n-9jg-1; Fri, 31 Mar 2023 17:03:36 -0400 X-MC-Unique: O6VN0jsKN1em2aiD-n-9jg-1 Received: by mail-lj1-f200.google.com with SMTP id s4-20020a05651c200400b002a623adbf16so710246ljo.20 for ; Fri, 31 Mar 2023 14:03:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680296615; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oxkdx0Z4lBYWbBLnH3tj2VhMGwq0HeKSBwgKK/oTDME=; b=tuEVRcYuIsdA0QzhJ4SYrWDQr3vINidbGCVuYXuDLM94gYfo6fFfXXAkBg/vtpVliZ uTefJeEYjyr4241oaxO1mI+2v6WbDRrIyjMeknHTXrCpZPFkIjpbYeIg9No7Vtcw2d7w JeoCVAVEwd8v7y/l97QusxXMd7DipRjxxBFJavIz5SPF+HC8v7GOOZdmEoRH/sGe2XBh d0buaPlaJrOmDqIjjSRLDCdHZNaNeuj5o4J+SSEqgkJcQJZ0zWCPIJPC9SzuyoPaPHIm v/+HsuCGab6jWsFskPFrbwYO0gdGPItNqrJRPt12uwdrN6sOFC24hvSPJZEB0Us/rm8k g+9g== X-Gm-Message-State: AAQBX9fp+pquTfCHDZecARlU4Pd8fazt/gJ8bUFb1h+xtwunom5PCxFS QX8NWLlVq8ZTd47EpB0gBNDwYx7D1Aums3jPJLQ7fYdd53PKxufVTF0iy4cElm9e1azQfI7MRg9 JNwlYZ3/ZyoE2QW/yiY/XoYAxtGJGRAGqsw== X-Received: by 2002:ac2:43d7:0:b0:4e8:3ef8:8b5c with SMTP id u23-20020ac243d7000000b004e83ef88b5cmr8421069lfl.8.1680296614885; Fri, 31 Mar 2023 14:03:34 -0700 (PDT) X-Google-Smtp-Source: AKy350aLqXmo0qxoyXX4J2273xFURxkHKJndGPGJMrHQ1rd3wu27rIhbt0kIEZeZPcvVZ/fOoQrdx5bVwqzotaBvdMU= X-Received: by 2002:ac2:43d7:0:b0:4e8:3ef8:8b5c with SMTP id u23-20020ac243d7000000b004e83ef88b5cmr8421063lfl.8.1680296614559; Fri, 31 Mar 2023 14:03:34 -0700 (PDT) MIME-Version: 1.0 References: <5531cf67-62b3-a4bc-c611-0fe026b75066@gmail.com> <00a8f27e-cc72-9852-45b3-1a1082d25ea2@gmail.com> In-Reply-To: <00a8f27e-cc72-9852-45b3-1a1082d25ea2@gmail.com> From: Jonathan Wakely Date: Fri, 31 Mar 2023 22:03:23 +0100 Message-ID: Subject: Re: [PATCH] Implement std::advance for istreambuf_iterator using pubseekoff To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++@gcc.gnu.org" , gcc-patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 15 Oct 2019 at 21:20, Fran=C3=A7ois 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=C3=A7ois > > On 10/14/19 10:12 PM, Fran=C3=A7ois 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=C3=A7ois > > >