From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 0574E385AC1F; Mon, 4 Oct 2021 20:05:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0574E385AC1F Received: by mail-wm1-x32f.google.com with SMTP id m14-20020a05600c3b0e00b0030d4dffd04fso943985wms.3; Mon, 04 Oct 2021 13:05:12 -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-transfer-encoding :content-language; bh=8R/kLyM67tkzuV5ub5dIPywul+B6Gln1nnPZ70LE85M=; b=Z4fcYMprY+mgcFJXsGNMkQwsAzhd4Crjo/xseZKzFPByHnl+V4dF2i3GDant7Eg4lU yYXNSQMwVm85A5suLtwfqqngpwvvjsO2WjWZi6+9E5J8Zl0fswcJibJzMKU8CNGjsxTZ f41MVruod5EkXmu2gVeu0OMzXwFqQqndWFQ7gyvS1OKDZbt4wiojJGS0Uimar20ST9Fc VH6OUQQutRMZJgkLLyPRHSCAMQkhGOfe/5jTHw4rvQiMgetrGdNps/37pu22avnoJ+Xv 1yYFBjolhFzraUjhSKBeWa9sMUcjgJsEbSAB8NHd4Ks2THFEyPun3aZNwWXDyKAHZ1/s s0Qg== X-Gm-Message-State: AOAM533ROqlzUTy90Wt7v/5ln0F3ErDWhsqkC1mPjqfg/LVFope3uHeS wMAI5EBrGAeOwmd9a1RDDyZiyyerbnlymg== X-Google-Smtp-Source: ABdhPJyW1dT8XbGV4fqtHf7dtsPTbCgrkNylmMNMLgdceAsCpJa88nhrAxbfQGjSPM7RYKL0IA4ssw== X-Received: by 2002:a1c:1b4a:: with SMTP id b71mr12459304wmb.33.1633377911642; Mon, 04 Oct 2021 13:05:11 -0700 (PDT) Received: from ?IPv6:2a01:e0a:1dc:b1c0:e5de:4d6e:565b:8a5e? ([2a01:e0a:1dc:b1c0:e5de:4d6e:565b:8a5e]) by smtp.googlemail.com with ESMTPSA id x21sm18186128wmc.14.2021.10.04.13.05.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 Oct 2021 13:05:10 -0700 (PDT) Subject: Re: [committed] libstdc++: Specialize std::pointer_traits<__normal_iterator> To: Jonathan Wakely Cc: libstdc++ , gcc-patches References: <57b54891-59ba-394d-3d53-218f5061b8ef@gmail.com> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Message-ID: <9ea0770a-54fb-2c17-b527-2797b5fd3b50@gmail.com> Date: Mon, 4 Oct 2021 22:05:10 +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: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: fr X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: Mon, 04 Oct 2021 20:05:14 -0000 On 02/10/21 10:24 pm, Jonathan Wakely wrote: > On Sat, 2 Oct 2021 at 18:27, François Dumont wrote: >> 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. > But I would rather not have these members present in vector::iterator > and string::iterator, in case users accidentally start to rely on them > being present. Making pointer_traits friends would help but I do not like it neither. > > Another option would be to overload std::__to_address so it knows how > to get the address from __normal_iterator and _Safe_iterator. > > . I start thinking that rather than proposing not-useful and even incorrect code in the case of the _Safe_iterator<> it might be a better approach. Even the rebind for __normal_iterator is a little strange because when doing rebind on std::vector::iterator for long it produces __normal_iterator>, quite inconsistent even if useless. But there's something that I'm missing, what is the relation between __addressof and std::pointer_traits ? Is it that __builtin_addressof is using it ?