220 5738 <CAOfiQq=CkHjg7AZrqWfHz=FsX1qD+80kc537y5fgVdJZ0eDxHg@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Richard Smith <richard@metafoo.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Uniform intialization with std::intializer_list
 is not uniform.
Date: Wed, 14 Aug 2013 20:29:53 -0700
Lines: 172
Approved: news@gmane.org
Message-ID: <CAOfiQq=CkHjg7AZrqWfHz=FsX1qD+80kc537y5fgVdJZ0eDxHg@mail.gmail.com>
References: <ab2d2158-d08c-4fdc-914f-df698e4f7b7c@isocpp.org>
	<CAGNvRgDyVZRfr5MZ3nMHPvjhW96tGbEpMHd9GKKspvdB4PMggg@mail.gmail.com>
	<CAFk2RUbGsghsRCs8mNhTgAbUHyxY5Zrk5kzRWbJ7VY6qMk0ZfQ@mail.gmail.com>
	<CAGNvRgALbHCdb+ithwL-ZsV2O3tcXTRy6QAV-82DoZPxikJ=oA@mail.gmail.com>
	<CAFk2RUb6eOhgbPSgwPHVJ=bnTSjOVo8k5UWCpFD1X6D0DbhoSg@mail.gmail.com>
	<CAGNvRgBMttU2LvJBWCNecTpPHuz9ujUmOEdhyXwr1b3J5SY2MA@mail.gmail.com>
	<CAFk2RUauNpfMQ9th5B7pFFyodZ78hfoJ4O8RNPqgai0Zg=rbvA@mail.gmail.com>
	<CAGNvRgBE3X9BF-6RnCmMMdGY9pNza3n0nFWcSTjzqF5LDx9ROA@mail.gmail.com>
	<CAFk2RUbX7SFj8yeM_qNA2XhfgNfGkS_bUu+_8DiewhGkdF_Ncw@mail.gmail.com>
	<CAGNvRgB7tqttBqt56RTvVzRdOVtv-dz1d-YhMESHi1RmurUjmQ@mail.gmail.com>
	<CAFk2RUbuxGj1__ff-yUmrpw+jEgZowv6vW42PVNhdav6A2uu+w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7bd6c2c45a365f04e3f416d2
X-Trace: ger.gmane.org 1376537396 14193 80.91.229.3 (15 Aug 2013 03:29:56 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 15 Aug 2013 03:29:56 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDVNBJG4YAIBBMMWWGIAKGQEI3MOZOA@isocpp.org Thu Aug 15 05:29:59 2013
Return-path: <std-proposals+bncBDVNBJG4YAIBBMMWWGIAKGQEI3MOZOA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ye0-f199.google.com ([209.85.213.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBBMMWWGIAKGQEI3MOZOA@isocpp.org>)
	id 1V9oG3-0000WR-74
	for gclcip-std-proposals@m.gmane.org; Thu, 15 Aug 2013 05:29:55 +0200
Original-Received: by mail-ye0-f199.google.com with SMTP id l12sf290275yen.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 14 Aug 2013 20:29:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:sender:in-reply-to:references:date:message-id:subject
         :from:to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=UAUZbaBMwofeSZJ6eKpyeGTkiro8eX1lQWx2fiGNcu4=;
        b=y2aN+VAo88OkWLxh+OfCUl0eFGK7ZbUUK/hdytNadpBQCM6xyOJPeAGvSelB2cSPrp
         959aZkKIvQhK091Gj1z2naC+8/RigCDzlDt+1iX/Le0TbW0aiSAyLLFgDzBl/RLA6a79
         P8sEYzVP8/tlcd2lnhrkBqxq4e6jYMHjla2P1hayqLMzOIzp0s47Nwkt9oHc4L0jzc6E
         CLFALc7WrtCzAaJ0p/5ZqEkr3sDJ/QltiRsyx3zrLCT5gFnjCbMSf72/eiv+iVg/9Dbo
         eO1EdhgfBtRG7DfRjN8thDWNRUq1i/vHofBlwIT1DAZg6gdhPuRoeRvC6EUj+OLiA0TS
         1U5A==
X-Received: by 10.58.144.134 with SMTP id sm6mr3994422veb.27.1376537394238;
        Wed, 14 Aug 2013 20:29:54 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.48.49 with SMTP id i17ls164829qen.44.gmail; Wed, 14 Aug
 2013 20:29:53 -0700 (PDT)
X-Received: by 10.221.51.206 with SMTP id vj14mr12541692vcb.17.1376537393703;
        Wed, 14 Aug 2013 20:29:53 -0700 (PDT)
Original-Received: from mail-vb0-x22a.google.com (mail-vb0-x22a.google.com [2607:f8b0:400c:c02::22a])
        by mx.google.com with ESMTPS id gq6si1207821veb.129.2013.08.14.20.29.53
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 14 Aug 2013 20:29:53 -0700 (PDT)
Received-SPF: pass (google.com: domain of metafoo@gmail.com designates 2607:f8b0:400c:c02::22a as permitted sender) client-ip=2607:f8b0:400c:c02::22a;
Original-Received: by mail-vb0-f42.google.com with SMTP id e12so216429vbg.1
        for <std-proposals@isocpp.org>; Wed, 14 Aug 2013 20:29:53 -0700 (PDT)
X-Received: by 10.58.235.69 with SMTP id uk5mr12426635vec.17.1376537393376;
 Wed, 14 Aug 2013 20:29:53 -0700 (PDT)
Original-Sender: metafoo@gmail.com
Original-Received: by 10.58.12.168 with HTTP; Wed, 14 Aug 2013 20:29:53 -0700 (PDT)
In-Reply-To: <CAFk2RUbuxGj1__ff-yUmrpw+jEgZowv6vW42PVNhdav6A2uu+w@mail.gmail.com>
X-Original-Sender: richard@metafoo.co.uk
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of metafoo@gmail.com designates 2607:f8b0:400c:c02::22a as permitted
 sender) smtp.mail=metafoo@gmail.com;       dkim=pass header.i=@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5738
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5738>

--047d7bd6c2c45a365f04e3f416d2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Wed, Aug 14, 2013 at 9:50 AM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:

> On 14 August 2013 17:39, Daniel Kr=FCgler <daniel.kruegler@gmail.com> wro=
te:
>
>> > I think it would be worthwhile to explore whether we can do a fix that
>> > doesn't require such work-arounds. The "wait for the expected
>> range-support" rings an alarm
>> > bell in my head.
>>
>> I don't understand why. Are you against range-support? IMO
>>
>
> No. I'm against lumping every problem we have under the range umbrella.
> string::split being one of them, this move-from-braced-list being another=
..
> I don't think ranges are the proper solution for such things.
>
>
>> std::initializer_list constructors in the library are just a special
>> case of a more generalized range support pattern and I find it more
>> reasonable to look for a more general solution instead of trying to
>> mutate std::initializer_list to something that it was not intended to
>> be.
>>
>
> That's ok, I don't know what the solution should be yet, perhaps
> mutating initializer_list isn't it. The problem shouldn't be "this is how
> initializer_lists work, don't expect braced-initializers to work
> differently".
> I'm not supposed to KNOW there's an initializer_list involved when
> I construct a vector from a braced list. At least I'm under the impressio=
n
> that initializer_list was supposed to be implementation plumbing
> rather than something that's in-my-face. And again, I don't think
> that implementation plumbing works quite right if I can't braced-init
> with move-only types. Other people can freely agree to disagree
> with that.
>

I agree. vector<unique_ptr<T>> can't be brace-initialized, so we have not
fully arrived at the clean, simple, uniform initialization syntax we
wanted. initializer_list<T> is supposed to be the vehicle for communicating
a braced-init-list from an initialization to a constructor, and it's not
fully succeeding at that task.

The core of the problem seems to be that initializer_list<T> does not own
its elements, not that the elements are immutable. If we merely made the
contents of the initializer_list mutable, we would break move-safety:

initializer_list<unique_ptr<T>> x =3D { a, b, c };
auto get() { return x; }
std::vector<unique_ptr<T>> v(get()); // oops, implicitly move here

We could fix this by adding a move-only std::unique_initializer_list<T> (or
similar) that owns its elements, but it seems overly-complicated to have
two similar-but-different initializer_list types in the library.
Conversely, it's probably too late to fix initializer_list to own its
contents (and thus be move-only).

--=20

---=20
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 e=
mail 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-proposa=
ls/.

--047d7bd6c2c45a365f04e3f416d2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wed, Aug 14, 2013 at 9:50 AM, Ville Voutilainen <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_bl=
ank">ville.voutilainen@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gma=
il_extra">

<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<span style=3D"color:rgb(80,0,80)">On 14 August 2013 17:39, Daniel Kr=FCgle=
r </span><span dir=3D"ltr" style=3D"color:rgb(80,0,80)">&lt;<a href=3D"mail=
to:daniel.kruegler@gmail.com" target=3D"_blank">daniel.kruegler@gmail.com</=
a>&gt;</span><span style=3D"color:rgb(80,0,80)"> wrote:</span><br>

<div class=3D"gmail_extra"><div class=3D"gmail_quote"><div>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">&gt; I think it would be worthwhile to explo=
re whether we can do a fix that<br><div>
&gt; doesn&#39;t require such work-arounds. The &quot;wait for the expected=
 range-support&quot; rings an alarm<br>
&gt; bell in my head.<br>
<br>
</div>I don&#39;t understand why. Are you against range-support? IMO<br></b=
lockquote><div><br></div></div><div>No. I&#39;m against lumping every probl=
em we have under the range umbrella.<br></div><div>string::split being one =
of them, this move-from-braced-list being another.<br>


</div><div>I don&#39;t think ranges are the proper solution for such things=
..<br>=A0<br></div><div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
std::initializer_list constructors in the library are just a special<br>
case of a more generalized range support pattern and I find it more<br>
reasonable to look for a more general solution instead of trying to<br>
mutate std::initializer_list to something that it was not intended to<br>
be.<br></blockquote><div><br></div></div><div>That&#39;s ok, I don&#39;t kn=
ow what the solution should be yet, perhaps<br>mutating initializer_list is=
n&#39;t it. The problem shouldn&#39;t be &quot;this is how<br>initializer_l=
ists work, don&#39;t expect braced-initializers to work differently&quot;.<=
br>


</div><div>I&#39;m not supposed to KNOW there&#39;s an initializer_list inv=
olved when<br></div><div>I construct a vector from a braced list. At least =
I&#39;m under the impression<br>that initializer_list was supposed to be im=
plementation plumbing<br>


rather than something that&#39;s in-my-face. And again, I don&#39;t think<b=
r>that implementation plumbing works quite right if I can&#39;t braced-init=
<br>with move-only types. Other people can freely agree to disagree<br>


with that.</div></div></div></div></blockquote><div><br></div><div>I agree.=
 vector&lt;unique_ptr&lt;T&gt;&gt; can&#39;t be brace-initialized, so we ha=
ve not fully arrived at the clean, simple, uniform initialization syntax we=
 wanted. initializer_list&lt;T&gt; is supposed to be the vehicle for commun=
icating a braced-init-list from an initialization to a constructor, and it&=
#39;s not fully succeeding at that task.</div>

<div><br></div><div>The core of the problem seems to be that initializer_li=
st&lt;T&gt; does not own its elements, not that the elements are immutable.=
 If we merely made the contents of the initializer_list mutable, we would b=
reak move-safety:</div>

<div><br></div><div>initializer_list&lt;unique_ptr&lt;T&gt;&gt; x =3D { a, =
b, c };</div><div>auto get() { return x; }</div><div>std::vector&lt;unique_=
ptr&lt;T&gt;&gt; v(get()); // oops, implicitly move here</div><div><br></di=
v>

<div>We could fix this by adding a move-only std::unique_initializer_list&l=
t;T&gt; (or similar) that owns its elements, but it seems overly-complicate=
d to have two similar-but-different initializer_list types in the library. =
Conversely, it&#39;s probably too late to fix initializer_list to own its c=
ontents (and thus be move-only).</div>

</div></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

--047d7bd6c2c45a365f04e3f416d2--

.
