From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 38F953858423; Sat, 2 Oct 2021 17:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 38F953858423 Received: by mail-wr1-x42c.google.com with SMTP id r7so5511698wrc.10; Sat, 02 Oct 2021 10:27:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=B89goCubBanSZNOeVV6BNUGgF0hqjONuPN93Y299RNo=; b=vM3olEhAFNJKPDVnNcbbdjL6MaXQWtge3+mpA7kSBLr8uxQCGCYTFi4U9tXAHoetcA CufwlclVxf00V0xGEmBEt81s8tr1o66c3BUhbGUPbJNxToCxCpFQozV6T4exMD6xibtl dPQWJ9XKTyaoQ6cWeuVfPfxpGiWzFMnydfSfcozZ0vwWdnkkt9MVODufwYX+eK2sAlRt Stgj6HA90E2CDBKM5Xq9T8v+lD/Ajoy7NMCfXFP5vN2gspJJtpQ1NW3dqlE+TyjOgUOi Ad7fg6+9Q7w6OuV8vSFSg+bTdtpoZoI3OiBzZJZXHtrlVoTxyfMWdD0mATAZa6jsdkeD a/tw== X-Gm-Message-State: AOAM531aRAeikgNQy7g5xlhSepUlGGbZHylH5vw8dMBxC/WDtoNie0Lx ZRkzgdxI5iUtURG/E8Z12n3RYCKStCg= X-Google-Smtp-Source: ABdhPJz5fyWU06jn2Vwe4VNIhW0FEfViNGhd9I/XnTVUaMeRKjDtEV/nI3cShPBzbiHEJqHbz3WGSg== X-Received: by 2002:adf:bb09:: with SMTP id r9mr4341013wrg.238.1633195656826; Sat, 02 Oct 2021 10:27:36 -0700 (PDT) Received: from ?IPv6:2a01:e0a:1dc:b1c0:7c71:369b:f357:f2d4? ([2a01:e0a:1dc:b1c0:7c71:369b:f357:f2d4]) by smtp.googlemail.com with ESMTPSA id f8sm9011790wrx.15.2021.10.02.10.27.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Oct 2021 10:27:35 -0700 (PDT) Subject: Re: [committed] libstdc++: Specialize std::pointer_traits<__normal_iterator> To: Jonathan Wakely Cc: libstdc++ , gcc-patches References: From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Message-ID: <57b54891-59ba-394d-3d53-218f5061b8ef@gmail.com> Date: Sat, 2 Oct 2021 19:27:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------5D5DEFB1BBA43B618F1A67A1" Content-Language: fr X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Oct 2021 17:27:40 -0000 This is a multi-part message in MIME format. --------------5D5DEFB1BBA43B618F1A67A1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit I would like to propose this alternative approach. In this patch I make __normal_iterator and random iterator _Safe_iterator compatible for pointer_traits primary template. Regarding pointer_traits I wonder if it shouldn't check for the to_pointer method availability and use per default: return { std::addressof(__e) }; otherwise. This way we wouldn't have to provide a pointer_to method on __normal_iterator. François On 02/10/21 12:29 am, Jonathan Wakely wrote: > On Thu, 30 Sept 2021 at 21:27, François Dumont via Libstdc++ > wrote: >> Here is the _Safe_iterator one. >> >> Doing so I noticed that pointer_traits rebind for __normal_iterator was >> wrong and added tests on it. > Oops, thanks! > >> For _Safe_iterator maybe I should specialize only when instantiated with >> __normal_iterator ? Or maybe limit to random_access_iterator_tag ? > Yes, I think that's a good idea, maybe only for __normal_iterator C>. I think that should cover all the cases we actually need to > support. > > And could you change the existing pointer_traits<__normal_iterator C>> partial specialization to only be valid for > __normal_iterator as well? i.e. only for __normal_iterator that > wraps a pointer (which is true for string::iterator, vector::iterator > etc.) > >> Whatever the pointer_to implementation is problematic, we can only >> produce singular iterator as I did ifor now. > Hmm, yes. I think that's OK, because I don't think anybody is actually > going to use that function. What matters is that it works with > std::__to_address for C++17 mode, and that doesn't depend on > pointer_to, so it's OK if it doesn't work usefully. > > Thanks! > --------------5D5DEFB1BBA43B618F1A67A1 Content-Type: text/plain; charset=UTF-8; name="ptr_traits.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="ptr_traits.txt" ZGlmZiAtLWdpdCBhL2xpYnN0ZGMrKy12My9pbmNsdWRlL2JpdHMvc3RsX2l0ZXJhdG9yLmgg Yi9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL3N0bF9pdGVyYXRvci5oCmluZGV4IDhhZmQ2 NzU2NjEzLi41OTRkNGQ1YjY1ZiAxMDA2NDQKLS0tIGEvbGlic3RkYysrLXYzL2luY2x1ZGUv Yml0cy9zdGxfaXRlcmF0b3IuaAorKysgYi9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL3N0 bF9pdGVyYXRvci5oCkBAIC0xMDE3LDYgKzEwMTcsMTMgQEAgX0dMSUJDWFhfQkVHSU5fTkFN RVNQQUNFX1ZFUlNJT04KICAgdGVtcGxhdGU8dHlwZW5hbWUgX0l0ZXJhdG9yLCB0eXBlbmFt ZSBfQ29udGFpbmVyPgogICAgIGNsYXNzIF9fbm9ybWFsX2l0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