Topic: Auto constructor to variable that has been
Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Sun, 2 Feb 2014 16:23:24 +0100
Raw View
--089e0149c380f12a0f04f16dfc51
Content-Type: text/plain; charset=UTF-8
On Sun, Feb 2, 2014 at 4:16 PM, otakuto otakuto <otakuto5648@gmail.com>wrote:
> //This is the same as "a = std::remove_pointer<decltype(a)>::type();"
> or "a = decltype(a)();"
> a = auto();
>
Isn't it equivalent to the following?
a = {};
Now that I think more about it, it depends on the type of a, if the default
constructor is explicit or not...
--
---
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/.
--089e0149c380f12a0f04f16dfc51
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">=
On Sun, Feb 2, 2014 at 4:16 PM, otakuto otakuto <span dir=3D"ltr"><<a hr=
ef=3D"mailto:otakuto5648@gmail.com" target=3D"_blank">otakuto5648@gmail.com=
</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">=C2=A0=C2=A0 //This is the =
same as "a =3D std::remove_pointer<decltype(a)>::type();" o=
r "a =3D decltype(a)();"<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 a =3D auto();</div></blockquote>=
</div><br></div><div class=3D"gmail_extra">Isn't it equivalent to the f=
ollowing?</div><div class=3D"gmail_extra"><br></div><div class=3D"gmail_ext=
ra">=C2=A0 =C2=A0 a =3D {};</div><div class=3D"gmail_extra">
<br></div><div class=3D"gmail_extra">Now that I think more about it, it dep=
ends on the type of a, if the default constructor is explicit or not...</di=
v></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--089e0149c380f12a0f04f16dfc51--
.
Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Sun, 2 Feb 2014 19:38:30 -0800 (PST)
Raw View
------=_Part_3048_24546795.1391398710347
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
The real thing about this is that once you get to
a =3D auto()
a has already been iitiated using its default constructor once (as it was=
=20
not mentioned in the constructor initializer list of foo::foo()).
The suggested syntax could however, inside a constructor, be defined to=20
mean that the compiler could be free to defer construction of a until the=
=20
assignment. The advantage would be that now there is a way to specify=20
initialization order different than member declaration order.
However, there are many problems with this, and really rather small gains.=
=20
For instance the compiler must check if such assignments occur before it=20
knows whether to auto-generate the code for the default construction of a=
=20
in the preamble of the ctor object code.
Another interpretation of the suggestion would be that the intention is=20
actually to provide an abbreviated copy-assignment-to-new-object syntax.=20
The usage of this is however very limited, and there are other problems=20
such as the fact that assignment operators can return any type, be chained=
=20
etc.
Den s=C3=B6ndagen den 2:e februari 2014 kl. 16:23:24 UTC+1 skrev Klaim - Jo=
=C3=ABl=20
Lamotte:
>
>
> On Sun, Feb 2, 2014 at 4:16 PM, otakuto otakuto <otaku...@gmail.com<javas=
cript:>
> > wrote:
>
>> //This is the same as "a =3D std::remove_pointer<decltype(a)>::type()=
;"=20
>> or "a =3D decltype(a)();"
>> a =3D auto();
>>
>
> Isn't it equivalent to the following?
>
> a =3D {};
>
> Now that I think more about it, it depends on the type of a, if the=20
> default constructor is explicit or not...
>
--=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/.
------=_Part_3048_24546795.1391398710347
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The real thing about this is that once you get to<div><br>=
</div><div>a =3D auto()</div><div><br></div><div>a has already been iitiate=
d using its default constructor once (as it was not mentioned in the constr=
uctor initializer list of foo::foo()).</div><div><br></div><div>The suggest=
ed syntax could however, inside a constructor, be defined to mean that the =
compiler could be free to defer construction of a until the assignment. The=
advantage would be that now there is a way to specify initialization order=
different than member declaration order.</div><div>However, there are many=
problems with this, and really rather small gains. For instance the compil=
er must check if such assignments occur before it knows whether to auto-gen=
erate the code for the default construction of a in the preamble of the cto=
r object code.</div><div><br></div><div>Another interpretation of the sugge=
stion would be that the intention is actually to provide an abbreviated cop=
y-assignment-to-new-object syntax. The usage of this is however very limite=
d, and there are other problems such as the fact that assignment operators =
can return any type, be chained etc.<br><br>Den s=C3=B6ndagen den 2:e febru=
ari 2014 kl. 16:23:24 UTC+1 skrev Klaim - Jo=C3=ABl Lamotte:<blockquote cla=
ss=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #=
ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br><div class=3D"gmail=
_quote">On Sun, Feb 2, 2014 at 4:16 PM, otakuto otakuto <span dir=3D"ltr">&=
lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"yRb0K=
k_f_QIJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"=
this.href=3D'javascript:';return true;">otaku...@gmail.com</a>></span> w=
rote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"> //This is the =
same as "a =3D std::remove_pointer<decltype(<wbr>a)>::type();" or "a =
=3D decltype(a)();"<br>
a =3D auto();</div></blockquote>=
</div><br></div><div>Isn't it equivalent to the following?</div><div><br></=
div><div> a =3D {};</div><div>
<br></div><div>Now that I think more about it, it depends on the type of a,=
if the default constructor is explicit or not...</div></div>
</blockquote></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" 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 />
------=_Part_3048_24546795.1391398710347--
.