From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52271 invoked by alias); 11 Sep 2017 20:36:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52229 invoked by uid 89); 11 Sep 2017 20:36:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=H*M:cdff, Hx-languages-length:1746 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f47.google.com Received: from mail-wm0-f47.google.com (HELO mail-wm0-f47.google.com) (74.125.82.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Sep 2017 20:36:24 +0000 Received: by mail-wm0-f47.google.com with SMTP id 189so11554044wmh.1; Mon, 11 Sep 2017 13:36:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=5yZF5iyDJAjKxlBckQ94xPPwZpbWErJEoxR3vbgHjPg=; b=cInAKbT7xex6UAyZHTR66Hs5XMLWaMdHJypsZcR23KtuaMj2T4J9hwTSbT3mxnuTHt oT7610gaFii6n1gFOwd8Y2Cchb3l3HfVV9xd4BLoWNvK6dUDJIUBTeSK5n4L4VTyNM6U +v1m26xmljNyd242bJcGdxqYdf+pD+ViAeWzYWyp48ALLiRG5taKRWKMWA0JnhpeIYLJ 2im5t+MVWt4HRQbCbU7PBFp/KlskpdmKWDv0cWh4w9tr+uwINhkgvbDd4sIFCja4GkdW O+cu7EEarLZjTV8HX5VTAYUmLshZhahZl0ELMFwVdYeYX2HCZckmxp0gGcw6Nm/msrqr s0og== X-Gm-Message-State: AHPjjUguEQo+U3MP1ztZRnSYp4c8DyTFioC3xoSuDSdO35UZDzQcQgI6 dfU7b/9AR0IzTTdQ X-Google-Smtp-Source: AOwi7QCn5mnj6Vc85ULsP28uzvLPQ8i91tAT7hv4W3/+NQOVIjY6ZZHukg85KrMpxc0u2dKq4+tsGw== X-Received: by 10.28.125.205 with SMTP id y196mr8981474wmc.128.1505162181917; Mon, 11 Sep 2017 13:36:21 -0700 (PDT) Received: from [192.168.0.23] (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by smtp.googlemail.com with ESMTPSA id e34sm12118090wre.15.2017.09.11.13.36.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2017 13:36:20 -0700 (PDT) Subject: Re: std::forward_list optim for always equal allocator To: Jonathan Wakely , =?UTF-8?Q?Daniel_Kr=c3=bcgler?= Cc: "libstdc++@gcc.gnu.org" , gcc-patches References: <20170908161940.GG4582@redhat.com> <45617be7-8df2-3e50-66de-81a71c3d5f62@gmail.com> <20170911121101.GL4582@redhat.com> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Message-ID: <37b937b0-cdff-ca36-b0de-5f8aa11773ab@gmail.com> Date: Mon, 11 Sep 2017 20:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170911121101.GL4582@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2017-09/txt/msg00626.txt.bz2 On 11/09/2017 14:11, Jonathan Wakely wrote: > On 11/09/17 07:44 +0200, Daniel Krügler wrote: >> 2017-09-11 7:12 GMT+02:00 François Dumont : >>> When user declare a container iterator like that: >>> >>> std::forward_list::iterator it; >>> >>> There is no reason to initialize it with a null node pointer. It is >>> just an >>> uninitialized iterator which is invalid to use except to initialize it. >> >> While that is correct, for every forward iterator (and >> std::forward_list::iterator meets these requirements), it is also >> required that a value-initialized iterator can be compared against >> other initialized iterators, so this reduces the amount of freedom to >> define a default constructor for such iterators even when used to >> default-initialize. This is not meant as a showstopper argument, since >> I have not fully understood of what you are planning, but just a >> reminder. > > Right, which means that > std::forward_list::iterator it = {}; > > must initialize the node pointer to nullptr. If we remove the > initialization of _Fwd_list_iterator::_M_node from the default > constructor then it would be left uninitialized. > > But I'm confused, François was talking about removing the > initialization of _Fwd_list_node_base::_M_next, what has that got to > do with forward_list::iterator? Thee is no node-base in the > iterator. > > So I'm still wondering why the initialization of _M_next should be > removed. > Indeed, the iterator contains a _Fwd_list_node_base*. So my remark was rather for the: _Fwd_list_iterator() noexcept : _M_node() { } that could simply be _Fwd_list_iterator() = default; no ? François