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 26BF63857C45 for ; Fri, 31 Mar 2023 21:03:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26BF63857C45 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-650-KPSqB8tiNgeP_KUQQnRUjQ-1; Fri, 31 Mar 2023 17:03:36 -0400 X-MC-Unique: KPSqB8tiNgeP_KUQQnRUjQ-1 Received: by mail-lj1-f200.google.com with SMTP id f12-20020a05651c02cc00b002a61d5315c7so1466457ljo.17 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=r35Tt0iACS5upFIuty3U1wrJ4pb5WiZJyA7h0AjoFFJ/1O9++2MwmTKEfeApbBh/OV 521YPivcFNwJm1NZcBlYKDHPYROhUL59GgtGwOpY5xJ6fOabFfLKdAQe7AGlK0ESGRYl FCgP7t5PcgV+OW/I5ARgll1c0b4GlDjXwW0/wbu4FvonuDCYbZUuohR9Q6wfIE3ZSSwM YelTMdgJtzNMl7XUOqNq7yPkcuOwLYYlZVyqD2gsUR/xGISKJqmkDkKWHxrvAvVgfqNd V13fmWe04sTdCxzBlo1OyHTVC4Svca1d5I9DBLptC3gOBatc4qzuztUI3f+13oj739eM jASg== X-Gm-Message-State: AAQBX9e2MJfiB17bpFh+fdx99Vtrh3pLtPskEDdv4PHLUtdQK8BAxLdZ lf2OPl2anLzMzx8zzNR2N2Fp7PFuTrl1iMHIP/LLf49wV0iXNZJt2VjPq3FmyksHH+sCiXAQHrg zW7bRu3OVD88ouzoooY9/3Z5ErEj1KBM= X-Received: by 2002:ac2:43d7:0:b0:4e8:3ef8:8b5c with SMTP id u23-20020ac243d7000000b004e83ef88b5cmr8421067lfl.8.1680296614858; 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 > > >