Topic: Replace 'C' style type-casting meaning to
Author: Izzy Coding <matthew.i.greenwood@gmail.com>
Date: Fri, 28 Nov 2014 09:07:46 -0800 (PST)
Raw View
------=_Part_6889_319970096.1417194466182
Content-Type: multipart/alternative;
boundary="----=_Part_6890_438351384.1417194466183"
------=_Part_6890_438351384.1417194466183
Content-Type: text/plain; charset=UTF-8
I am not sure, but I think that for my companies legacy code that could
cause some issues.
VERY VERY BAD CODE we have. Unfortunately until we can update all parts of
our code base this cannot be changed.
Ultimately if there was any way to get a compiler vendor (Ideally
Microsoft) to implement the suggested change and allow us to compile our
code to see what happens. Then maybe this comment could be ignored.
However there might be some old and bizarre code out there that requires
this the way it is.
--
---
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/.
------=_Part_6890_438351384.1417194466183
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I am not sure, but I think that for my companies legacy co=
de that could cause some issues.<div><br></div><div>VERY VERY BAD CODE we h=
ave. Unfortunately until we can update all parts of our code base this cann=
ot be changed.</div><div><br></div><div><br></div><div>Ultimately if there =
was any way to get a compiler vendor (Ideally Microsoft) to implement the s=
uggested change and allow us to compile our code to see what happens. Then =
maybe this comment could be ignored.</div><div>However there might be some =
old and bizarre code out there that requires this the way it is.</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 <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 />
------=_Part_6890_438351384.1417194466183--
------=_Part_6889_319970096.1417194466182--
.
Author: sasho648 <sasho648@mail.bg>
Date: Fri, 28 Nov 2014 12:05:37 -0800 (PST)
Raw View
------=_Part_7930_918300026.1417205137218
Content-Type: multipart/alternative;
boundary="----=_Part_7931_2051049640.1417205137218"
------=_Part_7931_2051049640.1417205137218
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
28 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=BF=D0=B5=D1=82=D1=
=8A=D0=BA, 19:07:46 UTC+2, Izzy Coding =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=
:
>
> I am not sure, but I think that for my companies legacy code that could=
=20
> cause some issues.
>
> VERY VERY BAD CODE we have. Unfortunately until we can update all parts o=
f=20
> our code base this cannot be changed.
>
>
> Ultimately if there was any way to get a compiler vendor (Ideally=20
> Microsoft) to implement the suggested change and allow us to compile our=
=20
> code to see what happens. Then maybe this comment could be ignored.
> However there might be some old and bizarre code out there that requires=
=20
> this the way it is.
>
The only time when old code will be illegal is when using the comma=20
operator in the brackets after the brackets of '*type-of-the-unnamed-object=
*'=20
which will be a very uncommon construct. Something like this:
(int *)(cout << "Strange way to express.", nullptr)
Which now will executes the content before the comma, then the one after it=
=20
which result will be casted. In the new syntax this will means that the=20
'int *' let's say constructor will be instanced with two arguments but I=20
believe nobody have actually written this - as it's a very unreadable=20
construct. He could write this after all:
(int *)nullptr, cout << "Strange way to express.";
Which is a lot better.
--=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_7931_2051049640.1417205137218
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">28 =D0=BD=D0=BE=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=BF=
=D0=B5=D1=82=D1=8A=D0=BA, 19:07:46 UTC+2, Izzy Coding =D0=BD=D0=B0=D0=BF=D0=
=B8=D1=81=D0=B0:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">I am not sure, but I think that for my companies legacy code that could =
cause some issues.<div><br></div><div>VERY VERY BAD CODE we have. Unfortuna=
tely until we can update all parts of our code base this cannot be changed.=
</div><div><br></div><div><br></div><div>Ultimately if there was any way to=
get a compiler vendor (Ideally Microsoft) to implement the suggested chang=
e and allow us to compile our code to see what happens. Then maybe this com=
ment could be ignored.</div><div>However there might be some old and bizarr=
e code out there that requires this the way it is.</div></div></blockquote>=
<div><br></div><div> The only time when old code will be illegal is wh=
en using the comma operator in the brackets after the brackets of '<i>type-=
of-the-unnamed-object</i>' which will be a very uncommon construct. Somethi=
ng like this:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, =
250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><font color=3D"#000=
088"><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span></font><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">"Strange way to express."</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">nullptr</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span></div></code></div><br>Which now will executes th=
e content before the comma, then the one after it which result will be cast=
ed. In the new syntax this will means that the 'int *' let's say constructo=
r will be instanced with two arguments but I believe nobody have actually w=
ritten this - as it's a very unreadable construct. He could write this afte=
r all:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187=
, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">*)</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">nullptr</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> cou=
t </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #080;" class=3D"styled-by-prettify">"Strange way to exp=
ress."</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan></div></code></div><br>Which is a lot better.</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 <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 />
------=_Part_7931_2051049640.1417205137218--
------=_Part_7930_918300026.1417205137218--
.
Author: sasho648 <sasho648@mail.bg>
Date: Fri, 28 Nov 2014 12:19:31 -0800 (PST)
Raw View
------=_Part_8021_1101164544.1417205971542
Content-Type: multipart/alternative;
boundary="----=_Part_8022_258421162.1417205971542"
------=_Part_8022_258421162.1417205971542
Content-Type: text/plain; charset=UTF-8
This syntax will be useful for creating named variables in expressions too.
Something like this:
int SomeFunc();
cout << "Result of 'SomeFunc()'" << ((int SomeFuncRet)() = SomeFunc()) <<
endl;
// now in 'SomeFuncRet' the return value of 'SomeFunc' will be store
--
---
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/.
------=_Part_8022_258421162.1417205971542
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This syntax will be useful for creating named variables in=
expressions too. Something like this:<div><br></div><div><div class=3D"pre=
ttyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-w=
ord; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-=
prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeFu=
nc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>cout </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #080;" class=3D"styled-by-prettify">"Result of 'SomeFunc()'=
"</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">SomeFuncRet</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)()</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">SomeFun=
c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">())</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// now in 'SomeFuncRet' the return value of=
'SomeFunc' will be store</span></div></code></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" 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 />
------=_Part_8022_258421162.1417205971542--
------=_Part_8021_1101164544.1417205971542--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 28 Nov 2014 18:05:35 -0800
Raw View
On Friday 28 November 2014 12:05:37 sasho648 wrote:
> (int *)(cout << "Strange way to express.", nullptr)
>
> Which now will executes the content before the comma, then the one after it
> which result will be casted. In the new syntax this will means that the
> 'int *' let's say constructor will be instanced with two arguments but I
> believe nobody have actually written this - as it's a very unreadable
> construct. He could write this after all:
>
> (int *)nullptr, cout << "Strange way to express.";
>
> Which is a lot better.
Except that this changes the behaviour, since now the result of the expression
is a std::ostream&, instead of an int*.
Anyway, I don't see why we need this since we can do it without the
parentheses.
auto y = SomeStruct();
typedef int *pint;
auto x = pint(nullptr);
Also with braces:
auto x = (int *){nullptr};
auto y = SomeStruct{};
or even:
int *x{};
SomeStruct y{};
Note how the last line would be the "most vexing" if we used ().
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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/.
.
Author: sasho648 <sasho648@mail.bg>
Date: Sat, 29 Nov 2014 03:14:45 -0800 (PST)
Raw View
------=_Part_7657_974145789.1417259685301
Content-Type: multipart/alternative;
boundary="----=_Part_7658_52950995.1417259685301"
------=_Part_7658_52950995.1417259685301
Content-Type: text/plain; charset=UTF-8
Then it could be written:
cout << "Strange way to express.", (int *)nullptr;
Anyway, I don't see why we need this since we can do it without the
> parentheses.
> auto y = SomeStruct();
> typedef int *pint;
> auto x = pint(nullptr);
> Also with braces:
> auto x = (int *){nullptr};
> auto y = SomeStruct{};
> or even:
> int *x{};
> SomeStruct y{};
> Note how the last line would be the "most vexing" if we used ().
Because using braces - the initialization rules are different and somewhat
confusing to some people. That's way I think it will be a good idea to add
this new syntax which when used will be easily distinguished from function
declaration. It will also make programmers life-easy as - the behavior of
the construct will be different if there is only one initialization
argument - In such case first a constructor of the target type will be
searched to instance and after that a cast operator of the object casted.
So you could write less code.
Examples:
(std::string var)(std::string(x), size_t(y));
Which now should be written like this, in order to prevent it to be
interpreted as a function declaration:
std::string var((std::string(x)), (size_t(y)));
And the default initialization should be always declared using a copy
constructor (which is a performance waste) like this:
string str ((string()));
or this:
string str = string();
Which now will be as simply as:
(string str)();
--
---
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/.
------=_Part_7658_52950995.1417259685301
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Then it could be written:<div><br></div><div><div class=3D=
"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: bre=
ak-word; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"S=
trange way to express."</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*)</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">nullptr</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span></div></code></div><span style=3D"color:=
rgb(136, 136, 136);"><br></span></div><blockquote class=3D"gmail_quote" st=
yle=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;">Anyway,=
I don't see why we need this since we can do it without the <br>paren=
theses. <br> auto y =3D=
SomeStruct(); <br> typ=
edef int *pint; <br> au=
to x =3D pint(nullptr); <br>Also with braces: <br> &nb=
sp; auto x =3D (int *){nullptr}; <br>&nbs=
p; auto y =3D SomeStruct{}; <=
br>or even: <br> int *x=
{}; <br> SomeStruct y{}=
; <br>Note how the last line would be the "most vexing" if we used ().=
</blockquote><div><br></div><div>Because using braces - the initializ=
ation rules are different and somewhat confusing to some people. That=
's way I think it will be a good idea to add this new syntax which when use=
d will be easily distinguished from function declaration. It will also make=
programmers life-easy as - the behavior of the construct will be different=
if there is only one initialization argument - In such case first a constr=
uctor of the target type will be searched to instance and after that a cast=
operator of the object casted. So you could write less code.</div><div><br=
></div><div>Examples:<br><br><div class=3D"prettyprint" style=3D"border: 1p=
x solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(25=
0, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">var</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">string</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">x</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> size_t</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">y</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">));</span></div></code></div><br></div><div>Which now should=
be written like this, in order to prevent it to be interpreted as a functi=
on declaration:<br><br><div class=3D"prettyprint" style=3D"border: 1px soli=
d rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250=
, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">var</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">((</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">string=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">x</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)),</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">size_t</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">y</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)));</span></div></code></div><span class=3D"styled-by-prettify" style=3D=
"background-color: rgb(250, 250, 250);"><div style=3D"color: rgb(102, 102, =
0); font-family: monospace;"><span class=3D"styled-by-prettify" style=3D"fo=
nt-family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 2=
50, 250);"><br></span></div><span style=3D"color: rgb(34, 34, 34); font-fam=
ily: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">A=
nd the default </span>initialization should be always declared using a=
copy constructor (which is a performance waste) like this:</span></div><di=
v><span class=3D"styled-by-prettify" style=3D"background-color: rgb(250, 25=
0, 250);"><br></span></div><div><span class=3D"styled-by-prettify" style=3D=
"background-color: rgb(250, 250, 250);"><div class=3D"prettyprint" style=3D=
"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-co=
lor: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #008;" class=3D"styled-by-prettify">string</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> str </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()));</span></div></code></d=
iv><div><span class=3D"styled-by-prettify" style=3D"background-color: rgb(2=
50, 250, 250);"><br></span></div>or this:<br><br><div class=3D"prettyprint"=
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; back=
ground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">string</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
str </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">();</span></div></code></d=
iv><span class=3D"styled-by-prettify" style=3D"font-family: monospace; colo=
r: rgb(102, 102, 0);"><div><span class=3D"styled-by-prettify" style=3D"back=
ground-color: rgb(250, 250, 250);"><span class=3D"styled-by-prettify" style=
=3D"font-family: monospace; color: rgb(102, 102, 0);"><br></span></span></d=
iv><span style=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sa=
ns-serif;">Which now will be as simply as:</span></span></span></div><div><=
span class=3D"styled-by-prettify" style=3D"background-color: rgb(250, 250, =
250);"><span class=3D"styled-by-prettify"><br></span></span></div><div><spa=
n class=3D"styled-by-prettify" style=3D"background-color: rgb(250, 250, 250=
);"><span class=3D"styled-by-prettify"><div class=3D"prettyprint" style=3D"=
border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-col=
or: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprett=
yprint"><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> str</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)();</span></div></code></di=
v></span><br></span><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" 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 />
------=_Part_7658_52950995.1417259685301--
------=_Part_7657_974145789.1417259685301--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sat, 29 Nov 2014 09:53:24 -0800
Raw View
On Saturday 29 November 2014 03:14:45 sasho648 wrote:
> Because using braces - the initialization rules are different and somewhat
> confusing to some people. That's way I think it will be a good idea to add
> this new syntax which when used will be easily distinguished from function
> declaration. It will also make programmers life-easy as - the behavior of
> the construct will be different if there is only one initialization
> argument - In such case first a constructor of the target type will be
> searched to instance and after that a cast operator of the object casted.
If we're going to teach them something, why not teach the rules for braces?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
--
---
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/.
.
Author: David Stone <deusexsophismata@gmail.com>
Date: Sat, 29 Nov 2014 10:08:42 -0800 (PST)
Raw View
------=_Part_75_987253077.1417284522980
Content-Type: multipart/alternative;
boundary="----=_Part_76_1303808417.1417284522980"
------=_Part_76_1303808417.1417284522980
Content-Type: text/plain; charset=UTF-8
Because braces are a less powerful method of initialization. With parens, I
can call an initializer-list constructor with T({1, 2}). With braces, I
cannot call a non-initializer-list constructor in any way. This shows up
regularly, for example, with std::vector<integer_type> when you use either
a one or two argument constructor. I have not finished writing it yet, but
you can reference http://doublewise.net/c++/initialization/ . This covers
the types of pitfalls that occur in zero- and single- argument constructors
when you do not necessarily want to call an initializer-list constructor.
--
---
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/.
------=_Part_76_1303808417.1417284522980
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Because braces are a less powerful method of initializatio=
n. With parens, I can call an initializer-list constructor with T({1, 2}). =
With braces, I cannot call a non-initializer-list constructor in any way. T=
his shows up regularly, for example, with std::vector<integer_type> w=
hen you use either a one or two argument constructor. I have not finished w=
riting it yet, but you can reference http://doublewise.net/c++/initializati=
on/ . This covers the types of pitfalls that occur in zero- and single- arg=
ument constructors when you do not necessarily want to call an initializer-=
list constructor.<br></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 <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 />
------=_Part_76_1303808417.1417284522980--
------=_Part_75_987253077.1417284522980--
.
Author: sasho648 <sasho648@mail.bg>
Date: Sun, 7 Dec 2014 14:01:03 -0800 (PST)
Raw View
------=_Part_3374_1363136281.1417989663952
Content-Type: multipart/alternative;
boundary="----=_Part_3375_875928571.1417989663952"
------=_Part_3375_875928571.1417989663952
Content-Type: text/plain; charset=UTF-8
Yep, so do we all agree that this should be included in the new standard?
Allowing this structure as a replacement (or addition) to the 'C' cast:
*(**type-of-temporary**)(**constructor-args**)*
In order to avoid the most vexing parse:
// Is this:
// 1) A variable of type std::string initialized to a std::string()?
// 2) The declaration of a function that returns a std::string and has one
argument,
// which is a pointer to a function with no arguments that returns a
std::string?
std::string foo(std::string());
// Is this:
// 1) A variable of type int initialized to int(x)?
// 2) The declaration of a function that returns an int and has one
argument,
// which is an int named x?
int bar(int(x));
Which for now can be avoided only this way (a very non-intuitive and
complex one):
std::string foo((std::string()));
int bar((int(x)));
Which by using my construct could be written as:
(std::string foo)(std::string());
(int bar)(int(x));
Or like that:
std::string foo((std::string)());
int bar((int)(x));
Which I believe is way better than what we have for now.
The new syntax will also allow us to construct local, named objects in
expressions like this:
int SomeFunc();
cout << "Result of 'SomeFunc()'" << (int SomeFuncRet)(SomeFunc()) << endl;
// now in 'SomeFuncRet' the return value of 'SomeFunc' will be store
With minimal legacy code incompatibility cost when comma operator is used
in the 'C' cast like that:
(int)(cout << "Hi", 0.0f) //first operation before comma will be executed,
and after that the '0.0f' will be converted into 'int', using my new syntax
this will mean an instance of possible 'int' constructor with 2 arguments
which will instance compiler error
--
---
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/.
------=_Part_3375_875928571.1417989663952
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yep, so do we all agree that this should be included in th=
e new standard? Allowing this structure as a replacement (or addition) to t=
he 'C' cast:<br><br><b>(</b><i>type-of-temporary</i><b>)(</b><i>constructor=
-args</i><b>)</b><div><b><br></b></div><div>In order to avoid the most vexi=
ng parse:<br><br><div class=3D"prettyprint" style=3D"border: 1px solid rgb(=
187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250)=
;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// Is this:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">// 1) A variable of type std::stri=
ng initialized to a std::string()?</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// 2) The declaration of a function that returns a std::s=
tring and has one argument,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// which is a pointer to a function with no argumen=
ts that returns a std::string?</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">string</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">());</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">// Is this:</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// 1) A variable of type int initialized =
to int(x)?</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// 2) =
The declaration of a function that returns an int and has one argument,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">// whic=
h is an int named x?</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ba=
r</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">));</span></div></code></div><div><br></div=
></div><div>Which for now can be avoided only this way (a very non-intuitiv=
e and complex one):<br><br><span class=3D"styled-by-prettify" style=3D"font=
-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 25=
0);"></span></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb=
(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250=
);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">((</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>string</span><span style=3D"color: #660;" class=3D"styled-by-prettify">())=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> bar</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">x</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)));</span></div></code></div><div><span class=3D"styled=
-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0); bac=
kground-color: rgb(250, 250, 250);"><span class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica=
, sans-serif; background-color: rgb(255, 255, 255);">Which by using my cons=
truct could be written as:</span><br></span></div><div><span class=3D"style=
d-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0); ba=
ckground-color: rgb(250, 250, 250);"><span style=3D"color: rgb(34, 34, 34);=
font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255,=
255);"><br></span></span></div><div class=3D"prettyprint" style=3D"border:=
1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb=
(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">string</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> bar</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">x</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">));</span></div></code></div><div><span class=3D"styled-by-pretti=
fy" style=3D"font-family: monospace; color: rgb(102, 102, 0); background-co=
lor: rgb(250, 250, 250);"><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 136); background-color: white;"><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);=
"><br></span></span></span></div><div>Or like that:<br><br><div class=3D"pr=
ettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-=
word; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by=
-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">stri=
ng</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">((</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)());</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> bar</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">((</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">x</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">));</span></div><=
/code></div><div><span class=3D"styled-by-prettify" style=3D"font-family: m=
onospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136); backgroun=
d-color: white;"><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0); background-color: rgb(250, 250, 250);"><br></span></span></span>=
</div></div><div><span class=3D"styled-by-prettify" style=3D"font-family: m=
onospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136); backgroun=
d-color: white;"><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0); background-color: rgb(250, 250, 250);"><br></span></span></span>=
</div><div>Which I believe is way better than what we have for now.<br></di=
v><div><br></div><div>The new syntax will also allow us to construct local,=
named objects in expressions like this:<br><br><span style=3D"font-family:=
monospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);"><=
/span></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, =
187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><c=
ode class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">SomeFunc</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br>cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"Result of 'SomeFunc()'"</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">SomeFuncRet</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">SomeFunc</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">())</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-=
by-prettify">// now in 'SomeFuncRet' the return value of 'SomeFunc' will be=
store</span></div></code></div><div><span style=3D"font-family: monospace;=
color: rgb(136, 0, 0); background-color: rgb(250, 250, 250);"><br></span>W=
ith minimal legacy code incompatibility cost when comma operator is used in=
the 'C' cast like that:<br><br><div class=3D"prettyprint" style=3D"border:=
1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb=
(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify">"Hi"</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">0.0f<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//first operation before com=
ma will be executed, and after that the '0.0f' will be converted into 'int'=
, using my new syntax this will mean an instance of possible 'int' construc=
tor with 2 arguments which will instance compiler error</span></div></code>=
</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" 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 />
------=_Part_3375_875928571.1417989663952--
------=_Part_3374_1363136281.1417989663952--
.
Author: Bo Persson <bop@gmb.dk>
Date: Sun, 07 Dec 2014 23:49:15 +0100
Raw View
On 2014-12-07 23:01, sasho648 wrote:
> Yep, so do we all agree that this should be included in the new
> standard? Allowing this structure as a replacement (or addition) to the
> 'C' cast:
>
> *(*/type-of-temporary/*)(*/constructor-args/*)*
> *
> *
> In order to avoid the most vexing parse:
>
> |
> // Is this:
> // 1) A variable of type std::string initialized to a std::string()?
> // 2) The declaration of a function that returns a std::string and has
> one argument,
> // which is a pointer to a function with no arguments that returns a
> std::string?
> std::string foo(std::string());
>
> // Is this:
> // 1) A variable of type int initialized to int(x)?
> // 2) The declaration of a function that returns an int and has one
> argument,
> // which is an int named x?
> int bar(int(x));
> |
>
> Which for now can be avoided only this way (a very non-intuitive and
> complex one):
>
> |
> std::string foo((std::string()));
>
> int bar((int(x)));
> |
>
Or, using initialization syntax already added to the language:
std::string foo{std::string{}};
int bar{static_cast<int>(x)};
--
---
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/.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 8 Dec 2014 01:26:30 +0200
Raw View
On 8 December 2014 at 00:01, sasho648 <sasho648@mail.bg> wrote:
> Yep, so do we all agree that this should be included in the new standard?
> Allowing this structure as a replacement (or addition) to the 'C' cast:
>
> (type-of-temporary)(constructor-args)
I'm afraid we don't all agree on that, no.
--
---
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/.
.
Author: sasho648 <sasho648@mail.bg>
Date: Mon, 8 Dec 2014 03:16:49 -0800 (PST)
Raw View
------=_Part_1590_318569822.1418037409051
Content-Type: multipart/alternative;
boundary="----=_Part_1591_526266383.1418037409051"
------=_Part_1591_526266383.1418037409051
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
As @David Stone said - braces are less powerful way of initialization and=
=20
can't be always used. Example of that is when we have both a constructor=20
with parameter of type "initializer_list<T>" and constructor with arguments=
=20
of type "T". Of-course if the constructor we want to invoke have only 1=20
parameter of type 'T' and 'T' have a constructor with 1 param of another=20
type 'Y', we could directly pass a variable of type 'Y' and thus avoid=20
ambiguity like this.
struct S1
{
S1(initializer_list<const struct N1>) { cout << "S1(initializer_list<co=
nst=20
struct N1>)" << endl;}
S1(const struct N1 &a) { cout << "S1(const struct N1 &a)" << endl;}
};
struct N1
{
N1(initializer_list<const struct G>) { cout << "N1(initializer_list<con=
st=20
struct G1>)" << endl;}
N1(int b) { cout << "N1(int b)" << endl;}
};
And now we want to create an object from type 'S1' with 'S1(const struct N1=
=20
&a)' constructor. We can't do that by using the new braces initialization=
=20
because it will invoke 'S1(initializer_list<const struct N1>)'.
int main()
{
int b;
S1 tmp{b}; //will invoke 'S1(initializer_list<const struct N1>)' with a=
=20
temporary
S1 tmp1(b); //will invoke 'S1(const struct N1 &a)' with a temporary
S1 tmp2((N1(b))); //same as above, using double brackets in order to=20
avoid confusion with function declaration
return 0;
}
As you can see in the above example the new braces wouldn't do our job, but=
=20
as we saw we don't need to use the complex double brackets either as our=20
compiler will understand what we are asking for by just passing an variable=
=20
with which the temporary could be constructed. The things can get nasty=20
however if we need to construct another temporary for the temporary=20
constructor argument in which case we should explicitly show that (it's a=
=20
rare case but it shows that the brackets initialization is still required=
=20
in cases when it could be interpreted as a function declaration). Example:
struct S
{
S(initializer_list<const struct N>) { cout << "S(initializer_list<const=
=20
struct N>)" << endl;}
S(const struct N &a) { cout << "S(const struct N &a)" << endl;}
};
struct N
{
N(initializer_list<const struct G>) { cout << "N(initializer_list<const=
=20
struct G>)" << endl;}
N(const struct G &b) { cout << "N(const struct G &b)" << endl;}
};
struct G
{
G(initializer_list<int>) { cout << "G(initializer_list<int>)" << endl;}
G(int b) { cout << "G(int b)" << endl;}
};
int main()
{
int b;
S tmp{N(b)}; //will instance 'S(initializer_list<const struct N>)'
S tmp1(b); // won't compile
S tmp2(N(b)); // function declaration
S tmp3((N(b))); // using double brackets, 'S(const struct N &a)' is=20
invoked in order to construct 'tmp'
return 0;
}
By adding my new syntax, this could be rewritten a way more readable like:
int main()
{
int b;
(S tmp3)(N(b)); // 'S(const struct N &a)' is invoked in order to=20
construct 'tmp', using my new syntax
return 0;
}
As I said above, it will be not only useful in those rare cases but also=20
when you want to create an local named object in expressions, as I showed=
=20
before.
08 =D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=BF=D0=BE=D0=
=BD=D0=B5=D0=B4=D0=B5=D0=BB=D0=BD=D0=B8=D0=BA, 00:49:35 UTC+2, Bo Persson =
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:
>
> On 2014-12-07 23:01, sasho648 wrote:=20
> > Yep, so do we all agree that this should be included in the new=20
> > standard? Allowing this structure as a replacement (or addition) to the=
=20
> > 'C' cast:=20
> >=20
> > *(*/type-of-temporary/*)(*/constructor-args/*)*=20
> > *=20
> > *=20
> > In order to avoid the most vexing parse:=20
> >=20
> > |=20
> > // Is this:=20
> > // 1) A variable of type std::string initialized to a std::string()?=20
> > // 2) The declaration of a function that returns a std::string and has=
=20
> > one argument,=20
> > // which is a pointer to a function with no arguments that returns a=
=20
> > std::string?=20
> > std::string foo(std::string());=20
> >=20
> > // Is this:=20
> > // 1) A variable of type int initialized to int(x)?=20
> > // 2) The declaration of a function that returns an int and has one=20
> > argument,=20
> > // which is an int named x?=20
> > int bar(int(x));=20
> > |=20
> >=20
> > Which for now can be avoided only this way (a very non-intuitive and=20
> > complex one):=20
> >=20
> > |=20
> > std::string foo((std::string()));=20
> >=20
> > int bar((int(x)));=20
> > |=20
> >=20
>
> Or, using initialization syntax already added to the language:=20
>
> std::string foo{std::string{}};=20
>
> int bar{static_cast<int>(x)};=20
>
>
>
>
>
>
>
--=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_1591_526266383.1418037409051
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">As @<span class=3D"_username" style=3D"white-space: nowrap=
;"><span class=3D"GCJGRCPBI-B">David Stone</span></span><span style=3D"whit=
e-space: nowrap;"> said - </span>braces are less powerful way of =
initialization and can't be always used. Example of that is when we have bo=
th a constructor with parameter of type "initializer_list<T>" and con=
structor with arguments of type "T". Of-course if the constructor we want t=
o invoke have only 1 parameter of type 'T' and 'T' have a constructor with =
1 param of another type 'Y', we could directly pass a variable of type 'Y' =
and thus avoid ambiguity like this.<br><br><div class=3D"prettyprint" style=
=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background=
-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">struc=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> S1<br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br> S1<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">initializer_list</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> N1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">>)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> cout </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"S1(init=
ializer_list<const struct N1>)"</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br><br><br> S1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">st=
ruct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> N1 </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"S1(const struct N1 &a)"</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> N1<br></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br> N1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">initializer_list</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> G</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">>)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
lt;<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #080;" class=3D"styled-by-prettify">"N1(initiali=
zer_list<const struct G1>)"</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br><br> N1</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> cout </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" cl=
ass=3D"styled-by-prettify">"N1(int b)"</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};=
</span></div></code></div><div><br></div><div>And now we want to create an =
object from type 'S1' with '<span class=3D"styled-by-prettify" style=3D"fon=
t-family: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 2=
50);">S1</span><span class=3D"styled-by-prettify" style=3D"font-family: mon=
ospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);">(</=
span><span class=3D"styled-by-prettify" style=3D"font-family: monospace; co=
lor: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">const</span><sp=
an class=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb=
(0, 0, 0); background-color: rgb(250, 250, 250);"> </span><span class=
=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(0, 0, 1=
36); background-color: rgb(250, 250, 250);">struct</span><span class=3D"sty=
led-by-prettify" style=3D"font-family: monospace; color: rgb(0, 0, 0); back=
ground-color: rgb(250, 250, 250);"> N1 </span><span class=3D"styl=
ed-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0); b=
ackground-color: rgb(250, 250, 250);">&</span><span class=3D"styled-by-=
prettify" style=3D"font-family: monospace; color: rgb(0, 0, 0); background-=
color: rgb(250, 250, 250);">a</span><span class=3D"styled-by-prettify" styl=
e=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: rgb=
(250, 250, 250);">)</span>' constructor. We can't do that by using the new =
braces initialization because it will invoke '<span class=3D"styled-by-pret=
tify" style=3D"font-family: monospace; color: rgb(0, 0, 0); background-colo=
r: rgb(250, 250, 250);">S1</span><span class=3D"styled-by-prettify" style=
=3D"font-family: monospace; color: rgb(102, 102, 0); background-color: rgb(=
250, 250, 250);">(</span><span class=3D"styled-by-prettify" style=3D"font-f=
amily: monospace; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250)=
;">initializer_list</span><span class=3D"styled-by-prettify" style=3D"font-=
family: monospace; color: rgb(102, 102, 0); background-color: rgb(250, 250,=
250);"><</span><span class=3D"styled-by-prettify" style=3D"font-family:=
monospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">c=
onst</span><span class=3D"styled-by-prettify" style=3D"font-family: monospa=
ce; color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"> </spa=
n><span class=3D"styled-by-prettify" style=3D"font-family: monospace; color=
: rgb(0, 0, 136); background-color: rgb(250, 250, 250);">struct</span><span=
class=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(0=
, 0, 0); background-color: rgb(250, 250, 250);"> N1</span><span class=
=3D"styled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 10=
2, 0); background-color: rgb(250, 250, 250);">>)</span>'.<br><br><div cl=
ass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wra=
p: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pretty=
print"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"=
styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br><br> S1 tm=
p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//will invoke 'S1(initializer_list<const =
struct N1>)' with a temporary</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br> S1 tmp1</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">b</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">//will invoke 'S1(const struct N1 &a)' with a temporary</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> &nb=
sp; S1 tmp2</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>((</span><span style=3D"color: #000;" class=3D"styled-by-prettify">N1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)));</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">//same as above, using double brackets in order =
to avoid confusion with function declaration</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span></div></code></div><div><br></div></div>As you can see in=
the above example the new braces wouldn't do our job, but as we saw we don=
't need to use the complex double brackets either as our compiler will unde=
rstand what we are asking for by just passing an variable with which the te=
mporary could be constructed. The things can get nasty however if we need t=
o construct another temporary for the temporary constructor argument in whi=
ch case we should explicitly show that (it's a rare case but it shows that =
the brackets initialization is still required in cases when it could be int=
erpreted as a function declaration). Example:<br><br><div class=3D"prettypr=
int" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> S<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; S</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">initializer_=
list</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">>)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify"=
>"S(initializer_list<const struct N>)"</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br><br> S</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> N </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">"S(const struct N &a)"</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">s=
truct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> N<br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
N</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">initializer_list</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> G</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">>)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> cout </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">"N(init=
ializer_list<const struct G>)"</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><<</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br><br> N</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">stru=
ct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> G </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-prett=
ify">"N(const struct G &b)"</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> G<br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> G</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">initializer_list</span><span sty=
le=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"G(initializer_list<int>)"</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br><br> G</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> cout </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"G(int b)"</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;}</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ma=
in</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br><br><br> S tmp</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">)};</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/will instance 'S(initializer_list<const struct N>)'</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br> S=
tmp1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">// won't compile</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br><br> S tmp2</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">N</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">b</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">// function declaration</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br><br> S tmp3</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">((</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">N</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">)));</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// using double brackets, 'S(const struct N &a)' is invoked in order to=
construct 'tmp'</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div=
></code></div><div><div><br></div></div><div>By adding my new syntax, this =
could be rewritten a way more readable like:<br><br><div class=3D"prettypri=
nt" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; b=
ackground-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ma=
in</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br><br> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">S tmp3</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">N</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">));</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">// 'S(const struct N &=
amp;a)' is invoked in order to construct 'tmp', using my new syntax</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">}</span></div></code></div><span class=3D"s=
tyled-by-prettify" style=3D"font-family: monospace; color: rgb(102, 102, 0)=
; background-color: rgb(250, 250, 250);"><br></span>As I said above, it wil=
l be not only useful in those rare cases but also when you want to create a=
n local named object in expressions, as I showed before.</div><div><br>08 =
=D0=B4=D0=B5=D0=BA=D0=B5=D0=BC=D0=B2=D1=80=D0=B8 2014, =D0=BF=D0=BE=D0=BD=
=D0=B5=D0=B4=D0=B5=D0=BB=D0=BD=D0=B8=D0=BA, 00:49:35 UTC+2, Bo Persson =D0=
=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;">On 2014-12-07 23:01, sasho648 wrote:
<br>> Yep, so do we all agree that this should be included in the new
<br>> standard? Allowing this structure as a replacement (or addition) t=
o the
<br>> 'C' cast:
<br>>
<br>> *(*/type-of-temporary/*)(*/<wbr>constructor-args/*)*
<br>> *
<br>> *
<br>> In order to avoid the most vexing parse:
<br>>
<br>> |
<br>> // Is this:
<br>> // 1) A variable of type std::string initialized to a std::string(=
)?
<br>> // 2) The declaration of a function that returns a std::string and=
has
<br>> one argument,
<br>> // which is a pointer to a function with no arguments=
that returns a
<br>> std::string?
<br>> std::string foo(std::string());
<br>>
<br>> // Is this:
<br>> // 1) A variable of type int initialized to int(x)?
<br>> // 2) The declaration of a function that returns an int and has on=
e
<br>> argument,
<br>> // which is an int named x?
<br>> int bar(int(x));
<br>> |
<br>>
<br>> Which for now can be avoided only this way (a very non-intuitive a=
nd
<br>> complex one):
<br>>
<br>> |
<br>> std::string foo((std::string()));
<br>>
<br>> int bar((int(x)));
<br>> |
<br>>
<br>
<br>Or, using initialization syntax already added to the language:
<br>
<br>std::string foo{std::string{}};
<br>
<br>int bar{static_cast<int>(x)};
<br>
<br>
<br>
<br>
<br>
<br>
<br></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 <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 />
------=_Part_1591_526266383.1418037409051--
------=_Part_1590_318569822.1418037409051--
.
Author: sasho648 <sasho648@mail.bg>
Date: Wed, 10 Dec 2014 14:30:31 -0800 (PST)
Raw View
------=_Part_6333_1514417072.1418250631820
Content-Type: multipart/alternative;
boundary="----=_Part_6334_831544860.1418250631820"
------=_Part_6334_831544860.1418250631820
Content-Type: text/plain; charset=UTF-8
I wanted to post examples of the other usage of my new syntax where
variables could be declared inside expressions. The rules for doing it so
are the following:
Variables could be declared with equal names only if either of them will be
initialized (they should be in separate control flows), and if they have
equal types. Examples:
int main()
{
extern bool b;
double Func(), Func1();
char Func2();
b ? (auto Tmp)(Func()) : (auto Tmp)(Func1()); //'Tmp' will be either
created by 'Func' or 'Func1' call
b ? (auto Tmp1)(Func()) : (auto Tmp1)(Func2()); //error, 'Tmp1' is
re-declared with different type ('char')
(auto Tmp1)(Func()), (auto Tmp1)(Func1()); //error, 'Tmp1' is
re-declared within the same control flow
return 0;
}
Memory for all variables declared in the expression should be provided,
even if they don't get initialized. Examples:
int main()
{
extern bool b;
double Func(), Func1();
b ? (auto Tmp)(Func()) : (auto Tmp1)(Func1()); // memory will be
reserved for 'Tmp' & 'Tmp1', but only one of them will be initialized
return 0;
}
What do you think about it? The syntax doesn't break any legacy - it just
add a new cool feature.
--
---
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/.
------=_Part_6334_831544860.1418250631820
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I wanted to post examples of the other usage of my new syn=
tax where variables could be declared inside expressions. The rules for doi=
ng it so are the following:<br><br><div>Variables could be declared with eq=
ual names only if either of them will be initialized (they should be in sep=
arate control flows), and if they have equal types. Examples:<br><br><div c=
lass=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wr=
ap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span class=3D"styled-by-prettify"><f=
ont color=3D"#000000"><div class=3D"subprettyprint">int main()</div><div cl=
ass=3D"subprettyprint">{<br> extern bool b;<br><br> &nbs=
p; double Func(), Func1();<br> <br> char Fun=
c2();<br> <br></div><div class=3D"subprettyprint"> b ? (a=
uto Tmp)(Func()) : <span style=3D"font-family: Arial, Helvetica, sans-=
serif;">(auto Tmp)(Func1())</span><span style=3D"font-family: Arial, Helvet=
ica, sans-serif;">; //'Tmp' will be either created by 'Func' or 'Func1' cal=
l<br><br></span></div></font><font color=3D"#000000"><div class=3D"subprett=
yprint"><span style=3D"font-family: Arial, Helvetica, sans-serif;"> &=
nbsp;</span><span style=3D"font-family: Arial, Helvetica, sans-serif;">&nbs=
p;</span><span style=3D"font-family: Arial, Helvetica, sans-serif;"> =
</span><span style=3D"font-family: Arial, Helvetica, sans-serif;">b &=
nbsp;? (auto Tmp1)(Func()) : </span><span style=3D"font-family: =
Arial, Helvetica, sans-serif;">(auto Tmp1)(</span>Func2<span style=3D"font-=
family: Arial, Helvetica, sans-serif;">())</span><span style=3D"font-family=
: Arial, Helvetica, sans-serif;">; //error, 'Tmp1' is re-declared with diff=
erent type ('char')<br><br></span><span style=3D"font-family: Arial, Helvet=
ica, sans-serif;"> </span><span style=3D"font-family: Arial, He=
lvetica, sans-serif;"> </span><span style=3D"font-family: Arial, Helve=
tica, sans-serif;"> </span><span style=3D"font-family: Arial, H=
elvetica, sans-serif;">(auto Tmp1)(Func()), </span><span style=3D"font=
-family: Arial, Helvetica, sans-serif;">(auto Tmp1)(</span>Func1<span style=
=3D"font-family: Arial, Helvetica, sans-serif;">())</span><span style=3D"fo=
nt-family: Arial, Helvetica, sans-serif;">; //error, 'Tmp1' is re-declared =
within the same </span><font face=3D"Arial, Helvetica, sans-serif">con=
trol flow</font><br><br></div></font><font color=3D"#000000"><div class=3D"=
subprettyprint"> return 0;</div><div class=3D"subprettyprint">=
}</div></font></span></div></code></div><br></div><div><br></div><div>Memor=
y for all variables declared in the expression should be provided, even if =
they don't get initialized. Examples:<br><br><div class=3D"prettyprint" sty=
le=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgrou=
nd-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">int=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> main</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">extern</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">double</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func1</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br> <br> &n=
bsp; b </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Tmp</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)(</span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">())</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">Tmp1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)(</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Func1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">());</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// m=
emory will be reserved for 'Tmp' & 'Tmp1', but only one of them will be=
initialized</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br> </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify"=
>0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></=
div><font color=3D"#000000" style=3D"font-family: monospace; background-col=
or: rgb(250, 250, 250);"><div class=3D"subprettyprint"><br></div><div class=
=3D"subprettyprint">What do you think about it? The syntax doesn't break an=
y legacy - it just add a new cool feature.</div></font></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 <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 />
------=_Part_6334_831544860.1418250631820--
------=_Part_6333_1514417072.1418250631820--
.
Author: sasho648 <sasho648@mail.bg>
Date: Wed, 10 Dec 2014 14:32:40 -0800 (PST)
Raw View
------=_Part_6798_900636231.1418250760688
Content-Type: multipart/alternative;
boundary="----=_Part_6799_1528390361.1418250760688"
------=_Part_6799_1528390361.1418250760688
Content-Type: text/plain; charset=UTF-8
I wanted to post examples of the other usage of my new syntax where
variables could be declared inside expressions. The rules for doing it so
are the following:
Variables could be declared with equal names only if either of them will be
initialized (they should be in separate control flows), and if they have
equal types. Examples:
int main()
{
extern bool b;
double Func(), Func1();
char Func2();
b ? (auto Tmp)(Func()) : (auto Tmp)(Func1()); //'Tmp' will be either
created by 'Func' or 'Func1' call
b ? (auto Tmp1)(Func()) : (auto Tmp1)(Func2()); //error, 'Tmp1' is
re-declared with different type ('char')
(auto Tmp1)(Func()), (auto Tmp1)(Func1()); //error, 'Tmp1' is
re-declared within the same control flow
return 0;
}
Memory for all variables declared in the expression should be provided,
even if they don't get initialized. Examples:
int main()
{
extern bool b;
double Func(), Func1();
b ? (auto Tmp)(Func()) : (auto Tmp1)(Func1()); // memory will be
reserved for 'Tmp' & 'Tmp1', but only one of them will be initialized
return 0;
}
What do you think about it? The syntax doesn't break any legacy - it just
add a new cool feature.
--
---
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/.
------=_Part_6799_1528390361.1418250760688
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I wanted to post examples of the other usage of my ne=
w syntax where variables could be declared inside expressions. The rules fo=
r doing it so are the following:</div><div><br></div><div>Variables could b=
e declared with equal names only if either of them will be initialized (the=
y should be in separate control flows), and if they have equal types. Examp=
les:</div><div><br></div><div class=3D"prettyprint" style=3D"border: 1px so=
lid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 2=
50, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">extern</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=
</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">double</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(),</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Func1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br> <br> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">Func2</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br> <br> b </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">?</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Tmp</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">())</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Tmp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">());</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//'Tmp' will be either creat=
ed by 'Func' or 'Func1' call</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br><br> b </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Tmp1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">())</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Tmp1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Func2</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">());</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//error, 'Tmp1' is re-declared wit=
h different type ('char')</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br><br> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Tmp1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(<=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Func</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">()),</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Tmp1</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)(</span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Func1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
());</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//error, 'Tmp1'=
is re-declared within the same control flow</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span></div></code></div><div><br></div><div><br></div><div><br=
></div><div>Memory for all variables declared in the expression should be p=
rovided, even if they don't get initialized. Examples:</div><div><br></div>=
<div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); w=
ord-wrap: break-word; background-color: rgb(250, 250, 250);"><code class=3D=
"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> main</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
extern</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">double</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Func</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(),</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Func1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br> <br> b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">Tmp</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Func</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">())</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">Tmp1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">Func1</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">());</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">// memory will be reserved for 'Tmp' & 'Tmp1', but o=
nly one of them will be initialized</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><=
/div></code></div><div><br></div><div><br></div><div>What do you think abou=
t it? The syntax doesn't break any legacy - it just add a new cool feature.=
</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 <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 />
------=_Part_6799_1528390361.1418250760688--
------=_Part_6798_900636231.1418250760688--
.
Author: David Stone <david@doublewise.net>
Date: Thu, 11 Dec 2014 05:48:31 -0700
Raw View
--047d7bfe9fd489030a0509f0312f
Content-Type: text/plain; charset=UTF-8
auto Tmp = b ? Func() : Func1();
works just as well with your example and doesn't introduce weird "in the
middle" variable declarations.
On Wed, Dec 10, 2014 at 3:30 PM, sasho648 <sasho648@mail.bg> wrote:
>
> I wanted to post examples of the other usage of my new syntax where
> variables could be declared inside expressions. The rules for doing it so
> are the following:
>
> Variables could be declared with equal names only if either of them will
> be initialized (they should be in separate control flows), and if they have
> equal types. Examples:
>
> int main()
> {
> extern bool b;
>
> double Func(), Func1();
>
> char Func2();
>
> b ? (auto Tmp)(Func()) : (auto Tmp)(Func1()); //'Tmp' will be either
> created by 'Func' or 'Func1' call
>
> b ? (auto Tmp1)(Func()) : (auto Tmp1)(Func2()); //error, 'Tmp1'
> is re-declared with different type ('char')
>
> (auto Tmp1)(Func()), (auto Tmp1)(Func1()); //error, 'Tmp1' is
> re-declared within the same control flow
>
> return 0;
> }
>
>
> Memory for all variables declared in the expression should be provided,
> even if they don't get initialized. Examples:
>
> int main()
> {
> extern bool b;
>
> double Func(), Func1();
>
> b ? (auto Tmp)(Func()) : (auto Tmp1)(Func1()); // memory will be
> reserved for 'Tmp' & 'Tmp1', but only one of them will be initialized
>
> return 0;
> }
>
> What do you think about it? The syntax doesn't break any legacy - it just
> add a new cool feature.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/1z0uI7LCQAI/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/.
>
--
---
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/.
--047d7bfe9fd489030a0509f0312f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div><div>auto Tmp =3D b ? Func() : Func1();<br></div=
><div><br></div>works just as well with your example and doesn't introd=
uce weird "in the middle" variable declarations.<br></div></div><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Dec =
10, 2014 at 3:30 PM, sasho648 <span dir=3D"ltr"><<a href=3D"mailto:sasho=
648@mail.bg" target=3D"_blank">sasho648@mail.bg</a>></span> wrote:<block=
quote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc=
solid;padding-left:1ex"><div dir=3D"ltr">I wanted to post examples of the =
other usage of my new syntax where variables could be declared inside expre=
ssions. The rules for doing it so are the following:<br><br><div>Variables =
could be declared with equal names only if either of them will be initializ=
ed (they should be in separate control flows), and if they have equal types=
.. Examples:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wra=
p:break-word;background-color:rgb(250,250,250)"><code><div><span><font colo=
r=3D"#000000"><div>int main()</div><div>{<br>=C2=A0 =C2=A0 extern bool b;<b=
r><br>=C2=A0 =C2=A0 double Func(), Func1();<br>=C2=A0 =C2=A0=C2=A0<br>=C2=
=A0 =C2=A0 char Func2();<br>=C2=A0<br></div><div>=C2=A0 =C2=A0 b ? (auto Tm=
p)(Func()) :=C2=A0<span style=3D"font-family:Arial,Helvetica,sans-serif">(a=
uto Tmp)(Func1())</span><span style=3D"font-family:Arial,Helvetica,sans-ser=
if">; //'Tmp' will be either created by 'Func' or 'Func=
1' call<br><br></span></div></font><font color=3D"#000000"><div><span s=
tyle=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0</span><span s=
tyle=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0</span><span style=3D=
"font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0</span><span style=3D=
"font-family:Arial,Helvetica,sans-serif">b =C2=A0? =C2=A0(auto Tmp1)(Func()=
) :=C2=A0</span><span style=3D"font-family:Arial,Helvetica,sans-serif">(aut=
o Tmp1)(</span>Func2<span style=3D"font-family:Arial,Helvetica,sans-serif">=
())</span><span style=3D"font-family:Arial,Helvetica,sans-serif">; //error,=
'Tmp1' is re-declared with different type ('char')<br><br>=
</span><span style=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0=
</span><span style=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0</span>=
<span style=3D"font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0</span>=
<span style=3D"font-family:Arial,Helvetica,sans-serif">(auto Tmp1)(Func()),=
=C2=A0</span><span style=3D"font-family:Arial,Helvetica,sans-serif">(auto T=
mp1)(</span>Func1<span style=3D"font-family:Arial,Helvetica,sans-serif">())=
</span><span style=3D"font-family:Arial,Helvetica,sans-serif">; //error, &#=
39;Tmp1' is re-declared within the same=C2=A0</span><font face=3D"Arial=
, Helvetica, sans-serif">control flow</font><br><br></div></font><font colo=
r=3D"#000000"><div>=C2=A0 =C2=A0 return 0;</div><div>}</div></font></span><=
/div></code></div><br></div><div><br></div><div>Memory for all variables de=
clared in the expression should be provided, even if they don't get ini=
tialized. Examples:<br><br><div style=3D"border:1px solid rgb(187,187,187);=
word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span st=
yle=3D"color:#008">int</span><span style=3D"color:#000"> main</span><span s=
tyle=3D"color:#660">()</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">extern</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#008">bool</span><span style=3D"color:#000"> b</sp=
an><span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#008">double</span><span style=3D=
"color:#000"> </span><span style=3D"color:#606">Func</span><span style=3D"c=
olor:#660">(),</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#606">Func1</span><span style=3D"color:#660">();</span><span style=3D"col=
or:#000"><br>=C2=A0<br>=C2=A0 =C2=A0 b </span><span style=3D"color:#660">?<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span=
><span style=3D"color:#008">auto</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">Tmp</span><span style=3D"color:#660">)(</span><sp=
an style=3D"color:#606">Func</span><span style=3D"color:#660">())</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">:</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Tmp1</span><span style=3D"color:#660">)(</span><span style=
=3D"color:#606">Func1</span><span style=3D"color:#660">());</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#800">// memory will be rese=
rved for 'Tmp' & 'Tmp1', but only one of them will be i=
nitialized</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 </span><s=
pan style=3D"color:#008">return</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#066">0</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#660">}</span></div></c=
ode></div><font style=3D"font-family:monospace;background-color:rgb(250,250=
,250)" color=3D"#000000"><div><br></div><div>What do you think about it? Th=
e syntax doesn't break any legacy - it just add a new cool feature.</di=
v></font></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/1z0uI7LCQAI/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/1z0uI7LCQAI=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</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 <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 />
--047d7bfe9fd489030a0509f0312f--
.
Author: sasho648 <sasho648@mail.bg>
Date: Thu, 11 Dec 2014 14:54:32 -0800 (PST)
Raw View
------=_Part_40_2062031760.1418338472998
Content-Type: multipart/alternative;
boundary="----=_Part_41_476695034.1418338472998"
------=_Part_41_476695034.1418338472998
Content-Type: text/plain; charset=UTF-8
Not every-time is the case. For example when you want to initialize a group
of variables depending on some common condition you would benefit from my
construction and easy your work. Examples of the case (using existing
syntax):
struct S1
{
S1 () { cout << "S1::S1()" << endl; };
S1 (const S1 &arg) { a = arg.a, b = arg.b, c = arg.c, d = arg.d, cout << "S1::S1(const
S1 &arg)" << endl; }
S1 &operator= (const S1 &arg) { a = arg.a, b = arg.b, c = arg.c, d = arg
..d, cout << "S1::operator= (const S1 &arg)" << endl; return *this; }
int a{}, b{}, c{}, d{}; //'a', 'b', 'c' and 'd' will be zero-initialized
};
struct FunctionReturningS1
{
explicit FunctionReturningS1(bool b); //implementation isn't important
- it sets different values at 'return_value', depending on 'b'
S1 return_value;
};
void Func(bool b)
{
//here 2 unneeded constructors and assigment operators will be
instanced, instead of directly copying construct the objects
S1 tmp;
S1 tmp1;
cout << "Func(bool b)" << endl;
b ? (tmp = FunctionReturningS1(false).return_value, tmp1 =
FunctionReturningS1(false).return_value) : (tmp = FunctionReturningS1(true).
return_value, tmp1 = FunctionReturningS1(true).return_value);
}
void Func1(bool b)
{
//here 'return-value' prvalue will be bound to 'rvalue' reference, thus
extending it's life-time (most optimized implementation), but it's clearly
hardly readable and comparsion with 'b' is done twice
S1 &&tmp(b ? FunctionReturningS1(false).return_value :
FunctionReturningS1(true).return_value), &&tmp1(b ? FunctionReturningS1(true
).return_value : FunctionReturningS1(false).return_value);
cout << "Func(bool b)" << endl;
}
Life example <http://melpon.org/wandbox/permlink/QapTeoBw7lWErp1Q>.
Using my new syntax, 'Func1' could be reworded like this:
void Func1(bool b)
{
b ? ((S1 &&tmp)(FunctionReturningS1(false).return_value), (S1 &&tmp1)(
FunctionReturningS1(false).return_value)) : ((S1 &&tmp)(FunctionReturningS1(
true).return_value), (S1 &&tmp1)(FunctionReturningS1(false).return_value));
cout << "Func(bool b)" << endl;
}
Which shows the connection better, as 'b' is compared only once.
It will be useful to shorten 'if' statements also. Example:
int main()
{
if((S1 &&tmp)(FunctionReturningS1(false).return_value).b >= 9)
{
//Do something with 'tmp', both created and compared above
}
}
Also when you want to create a variable at the same-time when storing in it
a value which then is used by another operator. Example:
int main()
{
cout << (S1 &&tmp)(FunctionReturningS1(false).return_value).b << endl; //
both cout 'return_value.b' and store it in the newly created 'tmp'
}
Of-course all of the above examples can be implemented without this syntax
too but it adds a new flexibility after all and it doesn't cost much to
implement.
--
---
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/.
------=_Part_41_476695034.1418338472998
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Not every-time is the case. For example when you want to i=
nitialize a group of variables depending on some common condition you would=
benefit from my construction and easy your work. Examples of the case (usi=
ng existing syntax):<br><br><div class=3D"prettyprint" style=3D"border: 1px=
solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250=
, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> S1<br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> S1 </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"S1::S1()"</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e=
ndl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br> S1 </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> S1 </span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">arg</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> arg</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> c </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> arg</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> d </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">d</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> cout </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"=
styled-by-prettify">"S1::S1(const S1 &arg)"</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r> S1 </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> S1 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">arg</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> arg</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> c </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> arg</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> d </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> arg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">d</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> cout </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" c=
lass=3D"styled-by-prettify">"S1::operator=3D (const S1 &arg)"</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">this</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br><br> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{},</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{},</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{},</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{};<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">//'a', 'b', 'c' and =
'd' will be zero-initialized</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Functio=
nReturningS1</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">expli=
cit</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturnin=
gS1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">//implementation isn't important - it sets di=
fferent values at '</span><span style=3D"color: rgb(0, 0, 0); font-family: =
Arial, Helvetica, sans-serif;">return_value</span><span style=3D"color: rgb=
(136, 0, 0); font-family: Arial, Helvetica, sans-serif;">', depending on 'b=
'</span></div><div class=3D"subprettyprint"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br> S1 return_value</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Func</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//here 2 unneeded constructo=
rs and assigment operators will be instanced, instead of directly copying c=
onstruct the objects</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> <br> S1 tmp</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br> S1 tmp1</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br><br> cout </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #080;" class=3D"styled-by-prettify">"Func(bool b)"</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> endl</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br> b </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">?</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">tmp </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Functio=
nReturningS1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">false</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">).</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">return_value</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> tmp1 </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">FunctionReturningS1</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">false</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">return_value</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">tmp </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">FunctionReturningS1</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">true</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">).</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">return_value</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> tmp1 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturni=
ngS1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">true</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">return_value</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Func1</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//here 'return-value' prvalu=
e will be bound to 'rvalue' reference, thus extending it's life-time (most =
optimized implementation), but it's clearly hardly readable and comparsion =
with 'b' is done twice</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> <br> S1 </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&&</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">tmp</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">b </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">?</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">F=
unctionReturningS1</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">f=
alse</span><span style=3D"color: #660;" class=3D"styled-by-prettify">).</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">return_value <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS1</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">return_value</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&&</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">tmp1</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">b </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS1</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">return_value </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">FunctionReturningS1</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">false</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">).</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">return_value</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br> cout </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"style=
d-by-prettify">"Func(bool b)"</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> endl</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><br>=
</div></code></div><div><br></div><div>Life <a href=3D"http://melpon.org/wa=
ndbox/permlink/QapTeoBw7lWErp1Q">example</a>.</div><div><br></div><div>Usin=
g my new syntax, 'Func1' could be reworded like this:<br><br><div class=3D"=
prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: brea=
k-word; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Fu=
nc1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> b </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">((</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">S1 </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>tmp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturn=
ingS1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">false</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">return_value</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">),</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">S1 </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&&</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">tmp1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)(</span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">FunctionReturningS1</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">false</span><span style=3D"color: #660;" class=3D"styled-by-prettify">).=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">return_val=
ue</span><span style=3D"color: #660;" class=3D"styled-by-prettify">))</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">((</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">S1 </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&&</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">tmp</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">)(</span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">FunctionReturningS1</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">true</span><span style=3D"color: #660;" class=3D"styled-by-prettify">).</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">return_value=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">S1 </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&&</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">tmp1</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">)(</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">FunctionReturningS1</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">false</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">).</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">return_value</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">));</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br> cout </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><<</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-pret=
tify">"Func(bool b)"</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><<</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
endl</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code>=
</div><span class=3D"styled-by-prettify" style=3D"font-family: monospace; c=
olor: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></span>W=
hich shows the connection better, as 'b' is compared only once.</div><div><=
br></div><div>It will be useful to shorten 'if' statements also. Example:<b=
r><br></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, =
187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><c=
ode class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">if</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">((</span><span style=3D"color: #000;" class=3D"styled-by-prettify">S1 <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">tmp</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">false</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">return_value</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">>=3D</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">9</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//Do something with 'tmp', both created and compared above</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></cod=
e></div><div><br></div><div>Also when you want to create a variable at the =
same-time when storing in it a value which then is used by another operator=
.. Example:<br><br><span class=3D"styled-by-prettify" style=3D"font-family: =
monospace; color: rgb(0, 0, 136); background-color: rgb(250, 250, 250);"></=
span></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 1=
87, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><co=
de class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color=
: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> cout </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">S1 <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&&<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">tmp</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">FunctionReturningS1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">false</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">return_value</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">).</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">b </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> endl</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>// both cout 'return_value.b' and store it in the newly created 'tmp'</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code>=
</div><div><span class=3D"styled-by-prettify" style=3D"font-family: monospa=
ce; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><br></s=
pan></div><div><span class=3D"styled-by-prettify" style=3D"font-family: mon=
ospace; color: rgb(102, 102, 0); background-color: rgb(250, 250, 250);"><sp=
an style=3D"color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-ser=
if; background-color: rgb(255, 255, 255);">Of-course all of the above examp=
les can be implemented without this syntax too but it adds a new flexibilit=
y after all and it doesn't cost much to implement.</span></span><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" 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 />
------=_Part_41_476695034.1418338472998--
------=_Part_40_2062031760.1418338472998--
.
Author: Thomas Braxton <kde.braxton@gmail.com>
Date: Thu, 11 Dec 2014 17:00:20 -0600
Raw View
--001a113b51b68d357b0509f8bd49
Content-Type: text/plain; charset=UTF-8
On Thu, Dec 11, 2014 at 4:54 PM, sasho648 <sasho648@mail.bg> wrote:
>
> Not every-time is the case. For example when you want to initialize a
> group of variables depending on some common condition you would benefit
> from my construction and easy your work. Examples of the case (using
> existing syntax):
>
> struct S1
> {
> S1 () { cout << "S1::S1()" << endl; };
>
> S1 (const S1 &arg) { a = arg.a, b = arg.b, c = arg.c, d = arg.d, cout
> << "S1::S1(const S1 &arg)" << endl; }
>
> S1 &operator= (const S1 &arg) { a = arg.a, b = arg.b, c = arg.c, d =
> arg.d, cout << "S1::operator= (const S1 &arg)" << endl; return *this; }
>
> int a{}, b{}, c{}, d{}; //'a', 'b', 'c' and 'd' will be
> zero-initialized
> };
>
>
> struct FunctionReturningS1
> {
> explicit FunctionReturningS1(bool b); //implementation isn't
> important - it sets different values at 'return_value', depending on 'b'
>
> S1 return_value;
> };
>
>
> void Func(bool b)
> {
> //here 2 unneeded constructors and assigment operators will be
> instanced, instead of directly copying construct the objects
>
> S1 tmp;
>
> S1 tmp1;
>
> cout << "Func(bool b)" << endl;
>
> b ? (tmp = FunctionReturningS1(false).return_value, tmp1 =
> FunctionReturningS1(false).return_value) : (tmp = FunctionReturningS1(true
> ).return_value, tmp1 = FunctionReturningS1(true).return_value);
> }
>
>
> void Func1(bool b)
> {
> //here 'return-value' prvalue will be bound to 'rvalue' reference,
> thus extending it's life-time (most optimized implementation), but it's
> clearly hardly readable and comparsion with 'b' is done twice
>
> S1 &&tmp(b ? FunctionReturningS1(false).return_value :
> FunctionReturningS1(true).return_value), &&tmp1(b ? FunctionReturningS1(
> true).return_value : FunctionReturningS1(false).return_value);
>
> cout << "Func(bool b)" << endl;
> }
>
> Life example <http://melpon.org/wandbox/permlink/QapTeoBw7lWErp1Q>.
>
> Using my new syntax, 'Func1' could be reworded like this:
>
> void Func1(bool b)
> {
> b ? ((S1 &&tmp)(FunctionReturningS1(false).return_value), (S1 &&tmp1)(
> FunctionReturningS1(false).return_value)) : ((S1 &&tmp)(
> FunctionReturningS1(true).return_value), (S1 &&tmp1)(FunctionReturningS1(
> false).return_value));
>
> cout << "Func(bool b)" << endl;
> }
>
> Which shows the connection better, as 'b' is compared only once.
>
> It will be useful to shorten 'if' statements also. Example:
>
> int main()
> {
> if((S1 &&tmp)(FunctionReturningS1(false).return_value).b >= 9)
> {
> //Do something with 'tmp', both created and compared above
> }
> }
>
> Also when you want to create a variable at the same-time when storing in
> it a value which then is used by another operator. Example:
>
> int main()
> {
> cout << (S1 &&tmp)(FunctionReturningS1(false).return_value).b << endl; //
> both cout 'return_value.b' and store it in the newly created 'tmp'
> }
>
> Of-course all of the above examples can be implemented without this syntax
> too but it adds a new flexibility after all and it doesn't cost much to
> implement.
>
Where has this been implemented?
--
---
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/.
--001a113b51b68d357b0509f8bd49
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Dec 11, 2014 at 4:54 PM, sasho648 <span dir=3D"ltr"><<a href=3D"mail=
to:sasho648@mail.bg" target=3D"_blank">sasho648@mail.bg</a>></span> wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Not every-time is the cas=
e. For example when you want to initialize a group of variables depending o=
n some common condition you would benefit from my construction and easy you=
r work. Examples of the case (using existing syntax):<br><br><div style=3D"=
border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb=
(250,250,250)"><code><div><span style=3D"color:#008">struct</span><span sty=
le=3D"color:#000"> S1<br></span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"><br>=C2=A0 =C2=A0 S1 </span><span style=3D"color:#660">(=
)</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"> cout </span><span style=3D"color:#660"><&=
lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&qu=
ot;S1::S1()"</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660"><<</span><span style=3D"color:#000"> endl</span><span styl=
e=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">};</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 S1 </=
span><span style=3D"color:#660">(</span><span style=3D"color:#008">const</s=
pan><span style=3D"color:#000"> S1 </span><span style=3D"color:#660">&<=
/span><span style=3D"color:#000">arg</span><span style=3D"color:#660">)</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><s=
pan style=3D"color:#000"> a </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> arg</span><span style=3D"color:#660">.</span><span=
style=3D"color:#000">a</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> b </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> arg</span><span style=3D"color:#660">.</span><span style=
=3D"color:#000">b</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> c </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> arg</span><span style=3D"color:#660">.</span><span style=3D"colo=
r:#000">c</span><span style=3D"color:#660">,</span><span style=3D"color:#00=
0"> d </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000=
"> arg</span><span style=3D"color:#660">.</span><span style=3D"color:#000">=
d</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> cout=
</span><span style=3D"color:#660"><<</span><span style=3D"color:#000=
"> </span><span style=3D"color:#080">"S1::S1(const S1 &arg)"<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660"><<=
;</span><span style=3D"color:#000"> endl</span><span style=3D"color:#660">;=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</spa=
n><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 S1 </span><span style=3D=
"color:#660">&</span><span style=3D"color:#008">operator</span><span st=
yle=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">const</span><span style=
=3D"color:#000"> S1 </span><span style=3D"color:#660">&</span><span sty=
le=3D"color:#000">arg</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#000"> a </span><span style=3D"color:#660">=3D</span><span style=3D"co=
lor:#000"> arg</span><span style=3D"color:#660">.</span><span style=3D"colo=
r:#000">a</span><span style=3D"color:#660">,</span><span style=3D"color:#00=
0"> b </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000=
"> arg</span><span style=3D"color:#660">.</span><span style=3D"color:#000">=
b</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> c </=
span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> arg</=
span><span style=3D"color:#660">.</span><span style=3D"color:#000">c</span>=
<span style=3D"color:#660">,</span><span style=3D"color:#000"> d </span><sp=
an style=3D"color:#660">=3D</span><span style=3D"color:#000"> arg</span><sp=
an style=3D"color:#660">.</span><span style=3D"color:#000">d</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> cout </span><span st=
yle=3D"color:#660"><<</span><span style=3D"color:#000"> </span><span =
style=3D"color:#080">"S1::operator=3D (const S1 &arg)"</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#660"><<</spa=
n><span style=3D"color:#000"> endl</span><span style=3D"color:#660">;</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">return</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">*</span><spa=
n style=3D"color:#008">this</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span style=
=3D"color:#000"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">int=
</span><span style=3D"color:#000"> a</span><span style=3D"color:#660">{},</=
span><span style=3D"color:#000"> b</span><span style=3D"color:#660">{},</sp=
an><span style=3D"color:#000"> c</span><span style=3D"color:#660">{},</span=
><span style=3D"color:#000"> d</span><span style=3D"color:#660">{};</span><=
span style=3D"color:#000"> </span><span style=3D"color:#800">//'a',=
'b', 'c' and 'd' will be zero-initialized</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><sp=
an style=3D"color:#000"><br><br><br></span><span style=3D"color:#008">struc=
t</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Funct=
ionReturningS1</span><span style=3D"color:#000"><br></span><span style=3D"c=
olor:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><spa=
n style=3D"color:#008">explicit</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">FunctionReturningS1</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#008">bool</span><span style=3D"color:#000"=
> b</span><span style=3D"color:#660">);</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#800">//implementation isn't important - it =
sets different values at '</span><span style=3D"color:rgb(0,0,0);font-f=
amily:Arial,Helvetica,sans-serif">return_value</span><span style=3D"color:r=
gb(136,0,0);font-family:Arial,Helvetica,sans-serif">', depending on =
9;b'</span></div><div><span style=3D"color:#000"><br>=C2=A0 =C2=A0 S1 r=
eturn_value</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">};</span><span style=3D"color:#0=
00"><br><br><br></span><span style=3D"color:#008">void</span><span style=3D=
"color:#000"> </span><span style=3D"color:#606">Func</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#008">bool</span><span style=3D"col=
or:#000"> b</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#00=
0"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">//here 2 unneeded co=
nstructors and assigment operators will be instanced, instead of directly c=
opying construct the objects</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 <br>=C2=A0 =C2=A0 S1 tmp</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"><br><br>=C2=A0 =C2=A0 S1 tmp1</span><span style=3D=
"color:#660">;</span><span style=3D"color:#000"><br><br>=C2=A0 =C2=A0 cout =
</span><span style=3D"color:#660"><<</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080">"Func(bool b)"</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660"><<</span><span =
style=3D"color:#000"> endl</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br><br>=C2=A0 =C2=A0 b </span><span style=3D"color:#66=
0">?</span><span style=3D"color:#000"> </span><span style=3D"color:#660">(<=
/span><span style=3D"color:#000">tmp </span><span style=3D"color:#660">=3D<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#606">Functio=
nReturningS1</span><span style=3D"color:#660">(</span><span style=3D"color:=
#008">false</span><span style=3D"color:#660">).</span><span style=3D"color:=
#000">return_value</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> tmp1 </span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">FunctionReturningS1</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#008">false</span=
><span style=3D"color:#660">).</span><span style=3D"color:#000">return_valu=
e</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">:</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">tmp </span><spa=
n style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#606">FunctionReturningS1</span><span style=3D"color:#660">(<=
/span><span style=3D"color:#008">true</span><span style=3D"color:#660">).</=
span><span style=3D"color:#000">return_value</span><span style=3D"color:#66=
0">,</span><span style=3D"color:#000"> tmp1 </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#606">=
FunctionReturningS1</span><span style=3D"color:#660">(</span><span style=3D=
"color:#008">true</span><span style=3D"color:#660">).</span><span style=3D"=
color:#000">return_value</span><span style=3D"color:#660">);</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">}</span><span styl=
e=3D"color:#000"><br><br><br></span><span style=3D"color:#008">void</span><=
span style=3D"color:#000"> </span><span style=3D"color:#606">Func1</span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#008">bool</span><spa=
n style=3D"color:#000"> b</span><span style=3D"color:#660">)</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800">//here=
'return-value' prvalue will be bound to 'rvalue' reference=
, thus extending it's life-time (most optimized implementation), but it=
's clearly hardly readable and comparsion with 'b' is done twic=
e</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 S1 <=
/span><span style=3D"color:#660">&&</span><span style=3D"color:#000=
">tmp</span><span style=3D"color:#660">(</span><span style=3D"color:#000">b=
</span><span style=3D"color:#660">?</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#606">FunctionReturningS1</span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#008">false</span><span style=3D"color=
:#660">).</span><span style=3D"color:#000">return_value </span><span style=
=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#606">FunctionReturningS1</span><span style=3D"color:#660">(</span><sp=
an style=3D"color:#008">true</span><span style=3D"color:#660">).</span><spa=
n style=3D"color:#000">return_value</span><span style=3D"color:#660">),</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">&&=
</span><span style=3D"color:#000">tmp1</span><span style=3D"color:#660">(</=
span><span style=3D"color:#000">b </span><span style=3D"color:#660">?</span=
><span style=3D"color:#000"> </span><span style=3D"color:#606">FunctionRetu=
rningS1</span><span style=3D"color:#660">(</span><span style=3D"color:#008"=
>true</span><span style=3D"color:#660">).</span><span style=3D"color:#000">=
return_value </span><span style=3D"color:#660">:</span><span style=3D"color=
:#000"> </span><span style=3D"color:#606">FunctionReturningS1</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#008">false</span><span st=
yle=3D"color:#660">).</span><span style=3D"color:#000">return_value</span><=
span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br>=C2=
=A0 =C2=A0 cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">"Func(bool b)"=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660"><&=
lt;</span><span style=3D"color:#000"> endl</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}=
</span><br></div></code></div><div><br></div><div>Life <a href=3D"http://me=
lpon.org/wandbox/permlink/QapTeoBw7lWErp1Q" target=3D"_blank">example</a>.<=
/div><div><br></div><div>Using my new syntax, 'Func1' could be rewo=
rded like this:<br><br><div style=3D"border:1px solid rgb(187,187,187);word=
-wrap:break-word;background-color:rgb(250,250,250)"><code><div><span style=
=3D"color:#008">void</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Func1</span><span style=3D"color:#660">(</span><span style=
=3D"color:#008">bool</span><span style=3D"color:#000"> b</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 b </sp=
an><span style=3D"color:#660">?</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">((</span><span style=3D"color:#000">S1 </span><spa=
n style=3D"color:#660">&&</span><span style=3D"color:#000">tmp</spa=
n><span style=3D"color:#660">)(</span><span style=3D"color:#606">FunctionRe=
turningS1</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
8">false</span><span style=3D"color:#660">).</span><span style=3D"color:#00=
0">return_value</span><span style=3D"color:#660">),</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#=
000">S1 </span><span style=3D"color:#660">&&</span><span style=3D"c=
olor:#000">tmp1</span><span style=3D"color:#660">)(</span><span style=3D"co=
lor:#606">FunctionReturningS1</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#008">false</span><span style=3D"color:#660">).</span><spa=
n style=3D"color:#000">return_value</span><span style=3D"color:#660">))</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">:</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">((</span><span =
style=3D"color:#000">S1 </span><span style=3D"color:#660">&&</span>=
<span style=3D"color:#000">tmp</span><span style=3D"color:#660">)(</span><s=
pan style=3D"color:#606">FunctionReturningS1</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#008">true</span><span style=3D"color:#660"=
>).</span><span style=3D"color:#000">return_value</span><span style=3D"colo=
r:#660">),</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">(</span><span style=3D"color:#000">S1 </span><span style=3D"color:#660"=
>&&</span><span style=3D"color:#000">tmp1</span><span style=3D"colo=
r:#660">)(</span><span style=3D"color:#606">FunctionReturningS1</span><span=
style=3D"color:#660">(</span><span style=3D"color:#008">false</span><span =
style=3D"color:#660">).</span><span style=3D"color:#000">return_value</span=
><span style=3D"color:#660">));</span><span style=3D"color:#000"><br><br>=
=C2=A0 =C2=A0 cout </span><span style=3D"color:#660"><<</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#080">"Func(bool b)&q=
uot;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&l=
t;<</span><span style=3D"color:#000"> endl</span><span style=3D"color:#6=
60">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660=
">}</span></div></code></div><span style=3D"font-family:monospace;color:rgb=
(102,102,0);background-color:rgb(250,250,250)"><br></span>Which shows the c=
onnection better, as 'b' is compared only once.</div><div><br></div=
><div>It will be useful to shorten 'if' statements also. Example:<b=
r><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break=
-word;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#0=
08">int</span><span style=3D"color:#000"> main</span><span style=3D"color:#=
660">()</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">if</span><span style=3D"color:#660">((</span><span style=3D=
"color:#000">S1 </span><span style=3D"color:#660">&&</span><span st=
yle=3D"color:#000">tmp</span><span style=3D"color:#660">)(</span><span styl=
e=3D"color:#606">FunctionReturningS1</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#008">false</span><span style=3D"color:#660">).</sp=
an><span style=3D"color:#000">return_value</span><span style=3D"color:#660"=
>).</span><span style=3D"color:#000">b </span><span style=3D"color:#660">&g=
t;=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066">9=
</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#800">/=
/Do something with 'tmp', both created and compared above</span><sp=
an style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#660"=
>}</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}=
</span></div></code></div><div><br></div><div>Also when you want to create =
a variable at the same-time when storing in it a value which then is used b=
y another operator. Example:<br><br><span style=3D"font-family:monospace;co=
lor:rgb(0,0,136);background-color:rgb(250,250,250)"></span></div><div style=
=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color=
:rgb(250,250,250)"><code><div><span style=3D"color:#008">int</span><span st=
yle=3D"color:#000"> main</span><span style=3D"color:#660">()</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 cout </span><span style=3D"color:#660">&=
lt;<</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>(</span><span style=3D"color:#000">S1 </span><span style=3D"color:#660">&a=
mp;&</span><span style=3D"color:#000">tmp</span><span style=3D"color:#6=
60">)(</span><span style=3D"color:#606">FunctionReturningS1</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#008">false</span><span styl=
e=3D"color:#660">).</span><span style=3D"color:#000">return_value</span><sp=
an style=3D"color:#660">).</span><span style=3D"color:#000">b </span><span =
style=3D"color:#660"><<</span><span style=3D"color:#000"> endl</span>=
<span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span=
style=3D"color:#800">// both cout 'return_value.b' and store it in=
the newly created 'tmp'</span><span style=3D"color:#000"><br></spa=
n><span style=3D"color:#660">}</span></div></code></div><div><span style=3D=
"font-family:monospace;color:rgb(102,102,0);background-color:rgb(250,250,25=
0)"><br></span></div><div><span style=3D"font-family:monospace;color:rgb(10=
2,102,0);background-color:rgb(250,250,250)"><span style=3D"color:rgb(34,34,=
34);font-family:Arial,Helvetica,sans-serif;background-color:rgb(255,255,255=
)">Of-course all of the above examples can be implemented without this synt=
ax too but it adds a new flexibility after all and it doesn't cost much=
to implement.</span></span><br></div></div></blockquote><div><br></div><di=
v>Where has this been implemented? <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" 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 />
--001a113b51b68d357b0509f8bd49--
.
Author: sasho648 <sasho648@mail.bg>
Date: Fri, 12 Dec 2014 03:18:31 -0800 (PST)
Raw View
------=_Part_141_788675888.1418383111251
Content-Type: multipart/alternative;
boundary="----=_Part_142_136041762.1418383111259"
------=_Part_142_136041762.1418383111259
Content-Type: text/plain; charset=UTF-8
Still no-where but what do you think. Is it worth proposing it to ISO C++
standard?
--
---
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/.
------=_Part_142_136041762.1418383111259
Content-Type: text/html; charset=UTF-8
<div dir="ltr">Still no-where but what do you think. Is it worth proposing it to ISO C++ standard?</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />
------=_Part_142_136041762.1418383111259--
------=_Part_141_788675888.1418383111251--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 12 Dec 2014 13:41:17 +0200
Raw View
On 12 December 2014 at 13:18, sasho648 <sasho648@mail.bg> wrote:
> Still no-where but what do you think. Is it worth proposing it to ISO C++
> standard?
I find it very hard to believe it would be accepted. It doesn't remove the
vexing parse, it introduces yet another way to initialize objects, and being
a way for initializing temporaries begs the question why it would be so
important to add a new way to initialize temporaries.
Comparing that to the cost of specifying, implementing and teaching
this feature, the benefit/cost ratio seems rather questionable.
--
---
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/.
.