220 20545 <CADGW59mVUmCTVN+CSVnk+LCmTvFXBf1YR_L5X1dfEgoKEPF8FQ@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: =?UTF-8?Q?Tomasz_Kami=C5=84ski?= <tomaszkam@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Draft D0065: Movable initializer lists, rev. 2
Date: Mon, 21 Sep 2015 07:41:13 +0200
Lines: 101
Approved: news@gmane.org
Message-ID: <CADGW59mVUmCTVN+CSVnk+LCmTvFXBf1YR_L5X1dfEgoKEPF8FQ@mail.gmail.com>
References: <BAE02C11-9AC8-41F8-BD3C-A2C9B33F9794@gmail.com>
	<87343e65-eecd-4b96-86b7-a883aa7f9d1d@isocpp.org>
	<ADB6E3C0-AD21-41A1-86AA-3DE2637BEABC@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c1a0e65bd65805203b5442
X-Trace: ger.gmane.org 1442814079 5059 80.91.229.3 (21 Sep 2015 05:41:19 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 21 Sep 2015 05:41:19 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBB6VQ72XQKGQEYDTHS7I@isocpp.org Mon Sep 21 07:41:17 2015
Return-path: <std-proposals+bncBDNPVXXG6IGBB6VQ72XQKGQEYDTHS7I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f197.google.com ([209.85.160.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBB6VQ72XQKGQEYDTHS7I@isocpp.org>)
	id 1Zdtqn-0002ee-8M
	for gclcip-std-proposals@m.gmane.org; Mon, 21 Sep 2015 07:41:17 +0200
Original-Received: by ykdg206 with SMTP id g206sf159615199ykd.1
        for <gclcip-std-proposals@m.gmane.org>; Sun, 20 Sep 2015 22:41:16 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=670+zmdT/wAYdV8qtFXyLL3Ix2ZvvLCv7phNuGTMNfk=;
        b=WUgDTusIUCxsM5/TdjaIXW0mIeHxgPGrWoPWFUVZy5sdjdnQdTOkDONdxxSh31wDpn
         gbwnRHVN5ww5hJSKyTo3WRom2kx25lUeZS+fgJuOFVc2FG5dwp0XXKLvK2cdnPeVaBb0
         /FNZ8f+vevNRhpxJYU9JSCWkwMHdWIus3vyVqSsVuSd5CMfg/oFFibYYFdQMSM248Bqu
         e9LLu7cAd7zWQKiNSFd5KSMPXxSTQ49+9hjmyo6zLyQcYqLjxE7ev983OPuZ+Ywmqrae
         K8WcqMORqm5m2N61ctQFpusIkpPnwDLIINw+lBVu0fbI79g3LTDyNkysoVD5Ed0GAy/v
         3IrQ==
X-Gm-Message-State: ALoCoQmimrzmM7mijdIbUzWcwp/X0rIu9UPi1gBezyNsLIprGeY8g+5wg3jiSdvjr/8jq4uh03Vz
X-Received: by 10.13.204.130 with SMTP id o124mr15534412ywd.36.1442814076499;
        Sun, 20 Sep 2015 22:41:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.65.163 with SMTP id y3ls675583obs.66.gmail; Sun, 20 Sep
 2015 22:41:14 -0700 (PDT)
X-Received: by 10.60.117.197 with SMTP id kg5mr10878803oeb.36.1442814074278;
        Sun, 20 Sep 2015 22:41:14 -0700 (PDT)
Original-Received: from mail-ob0-x22f.google.com (mail-ob0-x22f.google.com. [2607:f8b0:4003:c01::22f])
        by mx.google.com with ESMTPS id xj4si11131099oeb.73.2015.09.20.22.41.14
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 20 Sep 2015 22:41:14 -0700 (PDT)
Received-SPF: pass (google.com: domain of tomaszkam@gmail.com designates 2607:f8b0:4003:c01::22f as permitted sender) client-ip=2607:f8b0:4003:c01::22f;
Original-Received: by obbmp4 with SMTP id mp4so40275611obb.3
        for <std-proposals@isocpp.org>; Sun, 20 Sep 2015 22:41:14 -0700 (PDT)
X-Received: by 10.60.69.2 with SMTP id a2mr10228594oeu.3.1442814074015; Sun,
 20 Sep 2015 22:41:14 -0700 (PDT)
Original-Received: by 10.202.87.82 with HTTP; Sun, 20 Sep 2015 22:41:13 -0700 (PDT)
In-Reply-To: <ADB6E3C0-AD21-41A1-86AA-3DE2637BEABC@gmail.com>
X-Original-Sender: tomaszkam@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of tomaszkam@gmail.com designates 2607:f8b0:4003:c01::22f as permitted
 sender) smtp.mailfrom=tomaszkam@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:20545
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20545>

--001a11c1a0e65bd65805203b5442
Content-Type: text/plain; charset=UTF-8

2015-09-21 6:11 GMT+02:00 David Krauss <potswa@gmail.com>:

>
> Both situations are non-trivial to understand and requires knowledge about
> internal implementation (stack array) and are source of errors in the
> program. Both of them would be fixed by making the own_initializer_list
> non-copyable and non-moveable.
>
>
> That would not be sufficient as a fix, because constructing an initializer
> list object from a braced-init-list does not always involve an intermediate
> temporary that needs to be moved.
>


Ok, I agree. Your are pointing that in my example I could use construct as
follows:
struct Composite
{
  Composite(own_initializer_list<ComponentPtr>&& a_list) : a_list(m_list) {}
  Composite() : a_list{std::make_unique<ConcreteComposite1>(),
std::make_unique<ConcreteComposite2>()}

private:
  own_initializer_list<ComponentPtr> m_list;
};
Then Composite c; will lead to dangling reference.

However, I still think that removing the move-constructor would be
beneficial. The existence of the move-constructor and the name
(own_initializer_list) suggest that the list object actually manages
storage and moves it from one object to another. As the
own_initializer_list is effectively wrapped reference to stack allocated
array, it cannot do that, so the current design is misleading.

What is motivation for own_initializer_list being move-able? It's existence
suggest user that the class behaves more like unique_ptr<T[]> than
reference to stack array.

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11c1a0e65bd65805203b5442
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
2015-09-21 6:11 GMT+02:00 David Krauss <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span>:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left:1px solid rgb(204,204,204);padding-left:1ex"><div style=3D"word-wrap:=
break-word"><div><span class=3D""><br><blockquote type=3D"cite"><div><div d=
ir=3D"ltr">Both situations are non-trivial to understand and requires knowl=
edge about internal implementation (stack array) and are source of errors i=
n the program. Both of them would be fixed by making the own_initializer_li=
st non-copyable and non-moveable. </div></div></blockquote><div><br></div><=
/span><div>That would not be sufficient as a fix, because constructing an i=
nitializer list object from a braced-init-list does not always involve an i=
ntermediate temporary that needs to be moved.</div></div></div></blockquote=
><div><br><br>Ok, I agree. Your are pointing that in my example I could use=
 construct as follows:<br>struct Composite<br>{<br>=C2=A0 Composite(own_ini=
tializer_list&lt;ComponentPtr&gt;&amp;&amp; a_list) : a_list(m_list) {}<br>=
=C2=A0 Composite() : a_list{std::make_unique&lt;ConcreteComposite1&gt;(), s=
td::make_unique&lt;ConcreteComposite2&gt;()}=C2=A0 <br><br>private:<br>=C2=
=A0 own_initializer_list&lt;ComponentPtr&gt; m_list;<br>};<br>Then Composit=
e c; will lead to dangling reference.<br><br>However, I still think that re=
moving the move-constructor would be beneficial. The existence of the move-=
constructor and the name (own_initializer_list) suggest that the list objec=
t actually manages storage and moves it from one object to another. As the =
own_initializer_list is effectively wrapped reference to stack allocated ar=
ray, it cannot do that, so the current design is misleading.<br><br></div><=
div>What is motivation for own_initializer_list being move-able? It&#39;s e=
xistence suggest user that the class behaves more like unique_ptr&lt;T[]&gt=
; than reference to stack array.<br></div></div></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c1a0e65bd65805203b5442--

.
