From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 7E12A3858C27; Sat, 2 Oct 2021 13:08:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7E12A3858C27 Received: by mail-wm1-x331.google.com with SMTP id s24so9241069wmh.4; Sat, 02 Oct 2021 06:08:51 -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=cmg+HXf/f/3gbFdKU/V5JgCTkNTmAKGqbdRNokkdjNo=; b=yYALT3cedAzWSP6X4mMZR5VGIHNMTOuCATRFSqHKDNwt9xlu+dp2RY/aLnwbVFbg94 Y34l96nbFDMDxORmlgeILLMphU01FD0hD6Ux1ZvedGWjsQ8mc+yIsc522uUaSPPTb5oH 9tpsVFU16GpL34CWvDoFh8AoY6q/DkPxqShFTRtv5xvQXTrahkqS0Zjw7DbVrlmPYs2w ikTpuccgrYRS7VpWYEeZvHPYyD1eniMrDIjz3w3KEJkc8ELW14ywQPvB03xEM2hootqR Nph378iWMCv+HiBDJ4WGbEhD4SkKOClpm9xxIrQXqfEm0TYH/CDWlH9FYxgFbk7pPh30 cqKg== X-Gm-Message-State: AOAM532R6r2vBjVi/nsFLJtCq2FQRJyBKax5g7ETZAHJJD5MB1SCn4aR K3dNn+LggREmeYOnWuGItp8qQ/WkGT4= X-Google-Smtp-Source: ABdhPJxqwsnw/yvUrZMf0BT1x0rAj6ZGX1vZOFqcJfK5HJ4pLkGsSFyc0l030lVZpBorL9Hy2hIhUA== X-Received: by 2002:a05:600c:2282:: with SMTP id 2mr9186795wmf.47.1633180130381; Sat, 02 Oct 2021 06:08:50 -0700 (PDT) Received: from ?IPv6:2a01:e0a:1dc:b1c0:9908:f72:d429:814b? ([2a01:e0a:1dc:b1c0:9908:f72:d429:814b]) by smtp.googlemail.com with ESMTPSA id y5sm4701174wma.5.2021.10.02.06.08.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Oct 2021 06:08:48 -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: <0dbec215-2a5f-5291-49d7-afea2cd611a7@gmail.com> Date: Sat, 2 Oct 2021 15:08:48 +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="------------94DD1B11DBBA5CA8173550DD" Content-Language: fr X-Spam-Status: No, score=-11.6 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 13:08:53 -0000 This is a multi-part message in MIME format. --------------94DD1B11DBBA5CA8173550DD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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.) Is the attached patch what you had in mind ? At least it is passing tests. > >> 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. > This is why I think that my patch of the unordered containers to support custom pointers is not so bad because it avoids usage of pointer_traits::to_pointer :-) --------------94DD1B11DBBA5CA8173550DD Content-Type: text/plain; charset=UTF-8; name="patch.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="patch.txt" ZGlmZiAtLWdpdCBhL2xpYnN0ZGMrKy12My9pbmNsdWRlL2JpdHMvc3RsX2l0ZXJhdG9yLmgg Yi9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL3N0bF9pdGVyYXRvci5oCmluZGV4IDhhZmQ2 NzU2NjEzLi5mNmRiZTU2MjUwNSAxMDA2NDQKLS0tIGEvbGlic3RkYysrLXYzL2luY2x1ZGUv Yml0cy9zdGxfaXRlcmF0b3IuaAorKysgYi9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL3N0 bF9pdGVyYXRvci5oCkBAIC0xMzE0LDIzICsxMzE0LDE5IEBAIF9HTElCQ1hYX0JFR0lOX05B TUVTUEFDRV9WRVJTSU9OCiAKICAgLy8gTmVlZCB0byBzcGVjaWFsaXplIHBvaW50ZXJfdHJh aXRzIGJlY2F1c2UgdGhlIHByaW1hcnkgdGVtcGxhdGUgd2lsbAogICAvLyBkZWR1Y2UgZWxl bWVudF90eXBlIG9mIF9fbm9ybWFsX2l0ZXJhdG9yPFQqLCBDPiBhcyBUKiByYXRoZXIg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