220 22803 <CAB+4KHKRkUWckmvDsO0yYQm8-rwyqor0JcT0SZfjdmGA7=cDKQ@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Designated initializer list status?
Date: Sat, 21 Nov 2015 19:39:43 +0100
Lines: 208
Approved: news@gmane.org
Message-ID: <CAB+4KHKRkUWckmvDsO0yYQm8-rwyqor0JcT0SZfjdmGA7=cDKQ@mail.gmail.com>
References: <8b5cda67-8c22-41b6-b99d-ac2ab22f30d2@isocpp.org>
	<e6680cd7-ecbe-4d1d-8c5e-1c1533514422@isocpp.org>
	<CAB+4KHJS+arQ1o23Q92D0W6Gxp0t_pMd-9isd9wRJgb-V=FQxQ@mail.gmail.com>
	<8be0613a-76d8-425c-8eab-5930a2cf2549@isocpp.org>
	<CAB+4KH+tB4QZj3Qihv8=D-kpP0BC=3WQpJW938yoAG2+Zv5xmQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=047d7bb70c7eca835e05251150e5
X-Trace: ger.gmane.org 1448131190 27216 80.91.229.3 (21 Nov 2015 18:39:50 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 21 Nov 2015 18:39:50 +0000 (UTC)
To: "std-proposals@isocpp.org" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD5KHQXXWYPRB4HUYKZAKGQEPZ66ZZY@isocpp.org Sat Nov 21 19:39:46 2015
Return-path: <std-proposals+bncBD5KHQXXWYPRB4HUYKZAKGQEPZ66ZZY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f200.google.com ([209.85.217.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRB4HUYKZAKGQEPZ66ZZY@isocpp.org>)
	id 1a0D4b-0002uC-NT
	for gclcip-std-proposals@m.gmane.org; Sat, 21 Nov 2015 19:39:45 +0100
Original-Received: by lbbpy8 with SMTP id py8sf47386322lbb.0
        for <gclcip-std-proposals@m.gmane.org>; Sat, 21 Nov 2015 10:39:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=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=Pb5XUoEM1AXIT90STOIlMf67VZoz5csAZ8lt8qfbG3M=;
        b=kyzFyJs/59aX6VwZbbR+KPpdbJqfkkYfrA2efvbUFVl/E4XqKEu50zMGQTYPGrnn8W
         dit75d+hBicSXxND1oXlkMMV0h76umGHbn7+Df6oZRbS4UBtlaxM/UgfcWFu+ex05IaU
         reHHtK4pvY/e54KX+mZpl/zbiez4qDO7cOBJOgcAOBndXxgG4iRXS/M9vdUWTQlRhbkg
         wIP7hdM99zjQlh8xrZzEoTah4KOSje7HTmxdRyRBqAAWNC/crCK7zt0wV9hiNQJqqjuc
         pGOVoaDbaORrT9loaTWKXfc1xrNoWKQhqUz5Ba9VWBY3e1lj/REGTAxXbaPDu47djwxg
         /kOQ==
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=Pb5XUoEM1AXIT90STOIlMf67VZoz5csAZ8lt8qfbG3M=;
        b=dMgKvBVj5cTgaKNaV9tyrSUgqOwwfFRlZOsqvTwCwEPEnSrSBgWQsPXdS5L1z+ssme
         aFhrHSXVWXBTOWTYx+l/6oE2jhysnvBBnkDwxtWb/H2O28zlacj3JKUoz5agMie1lRmW
         YrsLGQXiTj/3XvnBpFL+f7Dyp/s/kHhvkiZR6Q5mu8arXQgxEYks8hVeWvfvxZlQeEAZ
         VGuEd6cNQH9S9oxBXlXyMUMVCcDCpj85KzD/YA2hfZIcjvZLl3bfCz51vGW+gW3AI+kD
         ILAnKlTDP5/b0CT4Ng+hyyK52VY808ucQCPl0/6SYXvYWQZePfDVcqHY7NpSKr+MS3xm
         XZ4w==
X-Gm-Message-State: ALoCoQnRyDuqhy1n6n5OwET/U5IhxnbaJDOkorncfw+U5ah6iPSEoXw1iI3+1XxDIYI9qxrFiTaP
X-Received: by 10.112.139.230 with SMTP id rb6mr3852326lbb.17.1448131185161;
        Sat, 21 Nov 2015 10:39:45 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.72.195 with SMTP id v186ls113585wma.52.gmail; Sat, 21 Nov
 2015 10:39:44 -0800 (PST)
X-Received: by 10.28.183.215 with SMTP id h206mr7691491wmf.0.1448131184042;
        Sat, 21 Nov 2015 10:39:44 -0800 (PST)
Original-Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com. [2a00:1450:400c:c09::230])
        by mx.google.com with ESMTPS id bv6si4988164wjc.97.2015.11.21.10.39.44
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sat, 21 Nov 2015 10:39:44 -0800 (PST)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::230 as permitted sender) client-ip=2a00:1450:400c:c09::230;
Original-Received: by wmww144 with SMTP id w144so53724801wmw.1
        for <std-proposals@isocpp.org>; Sat, 21 Nov 2015 10:39:43 -0800 (PST)
X-Received: by 10.194.200.233 with SMTP id jv9mr25116788wjc.133.1448131183672;
 Sat, 21 Nov 2015 10:39:43 -0800 (PST)
Original-Received: by 10.28.223.69 with HTTP; Sat, 21 Nov 2015 10:39:43 -0800 (PST)
In-Reply-To: <CAB+4KH+tB4QZj3Qihv8=D-kpP0BC=3WQpJW938yoAG2+Zv5xmQ@mail.gmail.com>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2a00:1450:400c:c09::230 as
 permitted sender) smtp.mailfrom=andrewtomazos@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:22803
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22803>

--047d7bb70c7eca835e05251150e5
Content-Type: text/plain; charset=UTF-8

On Sat, Nov 21, 2015 at 7:37 PM, Andrew Tomazos <andrewtomazos@gmail.com>
wrote:

> On Sat, Nov 21, 2015 at 6:56 PM, Nicol Bolas <jmckesson@gmail.com> wrote:
>
>> Oh, and for someone coming up with such a proposal, don't forget that in
>> C++17, types with base classes that have variables will *also* be
>> considered aggregates. So you'll need to come up with a way to use them
>> with designated initializers too.
>>
>> Good luck solving *that* one ;)
>>
>
> The simplest way would be to say that the base classes are default
> constructed and the designated initializer list can only refer to the most
> derived members.
>
> struct D : B { int x; }
> D d = { .x = 42}; // ok, B default constructed
>
> Even simpler would say that the designated initializer list constructor is
> only generated for classes without base classes.
>
> struct D : B { int x; }
> D d = { .x = 42}; // ill-formed
>
> Another solution would be to allow .BaseType as a key in a designated
> initializer list.
>
> struct B { int y; }
> struct D : B { int x; }
> D d = { .B = {.y = 43}, .x = 42}; // ok
>
> Another solution would be to roll up the base object graph into a single
> list of members and the designated initializer list addresses only member
> subobjects (and not base subobjects).
>
> struct B { int y; }
> struct D : B { int x; }
> D d = { .x = 42, .y = 43}; // ok
>
> The third and forth solutions are forward-compatible with the first and
> second solutions.
>
>
>>
>>> One of the things I've been thinking about is that we could have a
>>> std::designated_initializer_list unit type (no member functions) - and for
>>> aggregate class types a constructor taking such a type is generated.  A
>>> constructor taking such a type could also be explicitly defaulted.  We
>>> could then have a syntactic construct designated-init-list.
>>>
>>
>> I don't see the purpose of this. Generally speaking, most types that have
>> constructors have invariants, so their data members are private, so you
>> can't name them.
>>
>
> Noone is suggesting being able to address private members.  The reason I
> suggest using a type, is for forwarding of designated initializer lists.
> To actually consume them (as an endpoint) you need a compiler-generated
> constructor - either implicitly or explicitly defaulted.
>
> eg
>
> struct S { int x,y; };
> std::vector<S> v;
> v.push_back({.x = 42, .y = 43});
>

Sorry this is a bogus example.  I meant something like:

struct S { int x,y; };
std::optional<S> s;
s.emplace({.x = 42, .y = 43});




> So what was the point of providing that type with a constructor?
>>
>
> Apart from the above, its also so we can address the designated
> initializer list constructor, to explicit default or explicitlty delete it.
>
>
>> And don't forget: the last time we made special rules for how
>> braced-init-lists call constructors, we got screwed with the
>> `vector<int>/initializer_list<int>` problem. We shouldn't be making more
>> rules that break uniformity farther than it already has been.
>>
>> I'm not sure what you mean by the  "`vector<int>/initializer_list<int>`
> problem".
>
>

-- 

--- 
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/.

--047d7bb70c7eca835e05251150e5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sat, Nov 21, 2015 at 7:37 PM, Andrew Tomazos <span dir=3D"ltr">&lt;<=
a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andrewtomazos@g=
mail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div =
class=3D"gmail_extra"><div class=3D"gmail_quote"><span class=3D"">On Sat, N=
ov 21, 2015 at 6:56 PM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto=
:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</span> =
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-sty=
le:solid;padding-left:1ex"><div>Oh, and for someone coming up with such a p=
roposal, don&#39;t forget that in C++17, types with base classes that have =
variables will <i>also</i> be considered aggregates. So you&#39;ll need to =
come up with a way to use them with designated initializers too.<br><br>Goo=
d luck solving <i>that</i> one ;)<br></div></blockquote><div><br></div></sp=
an><div>The simplest way would be to say that the base classes are default =
constructed and the designated initializer list can only refer to the most =
derived members.</div><div><br></div><div>struct D : B { int x; }</div><div=
>D d =3D { .x =3D 42}; // ok, B default constructed</div><div><br></div><di=
v>Even simpler would say that the designated initializer list constructor i=
s only generated for classes without base classes.</div><div><br></div><div=
><div>struct D : B { int x; }</div><div>D d =3D { .x =3D 42}; // ill-formed=
</div></div><div><br></div><div>Another solution would be to allow .BaseTyp=
e as a key in a designated initializer list.</div><div><br></div><div>struc=
t B { int y; }</div><div><div><div>struct D : B { int x; }</div><div>D d =
=3D { .B =3D {.y =3D 43}, .x =3D 42}; // ok</div></div></div><div><br></div=
><div>Another solution would be to roll up the base object graph into a sin=
gle list of members and the designated initializer list addresses only memb=
er subobjects (and not base subobjects).</div><div><br></div><div>struct B =
{ int y; }</div><div>struct D : B { int x; }</div><div>D d =3D { .x =3D 42,=
 .y =3D 43}; // ok</div><div>=C2=A0</div><div>The third and forth solutions=
 are forward-compatible with the first and second solutions.</div><span cla=
ss=3D""><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div>=C2=A0</div><span><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1=
px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:=
1ex"><div dir=3D"ltr"><div>One of the things I&#39;ve been thinking about i=
s that we could have a std::designated_initializer_list unit type (no membe=
r functions) - and for aggregate class types a constructor taking such a ty=
pe is generated.=C2=A0 A constructor taking such a type could also be expli=
citly defaulted.=C2=A0 We could then have a syntactic construct designated-=
init-list.</div></div></blockquote></span><div><br>I don&#39;t see the purp=
ose of this. Generally speaking, most types that have constructors have inv=
ariants, so their data members are private, so you can&#39;t name them.<br>=
</div></blockquote><div><br></div></span><div>Noone is suggesting being abl=
e to address private members.=C2=A0 The reason I suggest using a type, is f=
or forwarding of designated initializer lists.=C2=A0 To actually consume th=
em (as an endpoint) you need a compiler-generated constructor - either impl=
icitly or explicitly defaulted.</div><div><br></div><div>eg</div><div><br><=
/div><div>struct S { int x,y; };</div><div>std::vector&lt;S&gt; v;</div><di=
v>v.push_back({.x =3D 42, .y =3D 43});</div></div></div></div></blockquote>=
<div><br></div><div>Sorry this is a bogus example.=C2=A0 I meant something =
like:</div><div><br></div><div><div>struct S { int x,y; };</div><div>std::o=
ptional&lt;S&gt; s;</div><div>s.emplace({.x =3D 42, .y =3D 43});</div></div=
><div><br></div><div><br></div><div>=C2=A0</div><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-=
color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=
=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><span class=
=3D""><div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div>So what was the point of providing t=
hat type with a constructor?<br></div></blockquote><div><br></div></span><d=
iv>Apart from the above, its also so we can address the designated initiali=
zer list constructor, to explicit default or explicitlty delete it.</div><s=
pan class=3D""><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,20=
4,204);border-left-style:solid;padding-left:1ex"><div>And don&#39;t forget:=
 the last time we made special rules for how braced-init-lists call constru=
ctors, we got screwed with the `vector&lt;int&gt;/initializer_list&lt;int&g=
t;` problem. We shouldn&#39;t be making more rules that break uniformity fa=
rther than it already has been.</div><div><div>

<p></p></div></div></blockquote></span></div>I&#39;m not sure what you mean=
 by the =C2=A0&quot;`vector&lt;int&gt;/initializer_list&lt;int&gt;` problem=
&quot;.</div><div class=3D"gmail_extra"><br></div></div>
</blockquote></div><br></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 />

--047d7bb70c7eca835e05251150e5--

.
