Topic: relaxing rules for ternary operator. Allow
Author: ma.kalbfuss@web.de
Date: Sat, 20 May 2017 10:41:56 -0700 (PDT)
Raw View
------=_Part_1857_31001462.1495302116957
Content-Type: multipart/alternative;
boundary="----=_Part_1858_1927772858.1495302116957"
------=_Part_1858_1927772858.1495302116957
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi Guys,
I had the following situation:
I have a Group of StaticSet classes with a compatible interface but=20
distinct in there concrete type. empty_set is not an intervall!
I tried the following:
auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE) - =
1);
auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' + (bas=
e=20
- 1 - DECIMAL_BASE)) : empty_set;
auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' + (bas=
e=20
- 1 - DECIMAL_BASE)) : empty_set;
Wouldn't it be possible to allow such code, especially in conjunction with=
=20
concepts?
MFG
Martin Kalbfu=C3=9F
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1b5ee8eb-53df-4e98-af2f-829c7bc2e5b2%40isocpp.or=
g.
------=_Part_1858_1927772858.1495302116957
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi Guys,<br><br>I had the following situation:<br><br>I ha=
ve a Group of StaticSet classes with a compatible interface but distinct in=
there concrete type. empty_set is not an intervall!<br>I tried the followi=
ng:<br><br><br>auto dec_digit =3D make_interval('0', '0' + =
std::min(base, DECIMAL_BASE) - 1);<br>auto upper_digit =3D (base > DECIM=
AL_DIGIT) ? make_interval('A', 'A' + (base - 1 - DECIMAL_BA=
SE)) : empty_set;<br>auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_=
interval('a', 'a' + (base - 1 - DECIMAL_BASE)) : empty_set;=
<br><br><br>Wouldn't it be possible to allow such code, especially in c=
onjunction with concepts?<br><br>MFG<br><br>Martin Kalbfu=C3=9F<br></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1b5ee8eb-53df-4e98-af2f-829c7bc2e5b2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1b5ee8eb-53df-4e98-af2f-829c7bc2e5b2=
%40isocpp.org</a>.<br />
------=_Part_1858_1927772858.1495302116957--
------=_Part_1857_31001462.1495302116957--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sat, 20 May 2017 12:29:51 -0700
Raw View
On s=C3=A1bado, 20 de maio de 2017 10:41:56 PDT ma.kalbfuss@web.de wrote:
> Hi Guys,
>=20
> I had the following situation:
>=20
> I have a Group of StaticSet classes with a compatible interface but
> distinct in there concrete type. empty_set is not an intervall!
> I tried the following:
>=20
>=20
> auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE) =
- 1);
> auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' + (b=
ase
> - 1 - DECIMAL_BASE)) : empty_set;
> auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' + (b=
ase
> - 1 - DECIMAL_BASE)) : empty_set;
>=20
>=20
> Wouldn't it be possible to allow such code, especially in conjunction wit=
h
> concepts?
No. lower_digit must have exactly one type, determined at compile-time. Wha=
t=20
you're asking for would cause the type to be determined at runtime, which i=
s=20
not possible in C++.
Alternatives:
* convert empty_set to make_interval's type
* convert either to a common type (which you need to be explicit about, so =
it=20
won't work with auto)
* use std::variant<interval, decltype(empty_set)>
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/9064929.QEV8q21eIZ%40tjmaciei-mobl1.
.
Author: ma.kalbfuss@web.de
Date: Sat, 20 May 2017 12:45:26 -0700 (PDT)
Raw View
------=_Part_1870_1211906855.1495309526348
Content-Type: multipart/alternative;
boundary="----=_Part_1871_1679238250.1495309526348"
------=_Part_1871_1679238250.1495309526348
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Thanks for your answer. I see the problem now. The condition is a runtime=
=20
condition. So this isn't going to work. But wouldn't it be possible for a=
=20
constexpr condition?
for Example:
auto x =3D (std::is_integral_v<T>) ? A{} : B{};
This would be like if constexpr with implicit constexpr determinded by the=
=20
compiler.
Am Samstag, 20. Mai 2017 19:41:57 UTC+2 schrieb ma.ka...@web.de:
>
> Hi Guys,
>
> I had the following situation:
>
> I have a Group of StaticSet classes with a compatible interface but=20
> distinct in there concrete type. empty_set is not an intervall!
> I tried the following:
>
>
> auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE) =
-=20
> 1);
> auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' + (b=
ase=20
> - 1 - DECIMAL_BASE)) : empty_set;
> auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' + (b=
ase=20
> - 1 - DECIMAL_BASE)) : empty_set;
>
>
> Wouldn't it be possible to allow such code, especially in conjunction wit=
h=20
> concepts?
>
> MFG
>
> Martin Kalbfu=C3=9F
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/9770742d-c5de-4a55-869f-ab71231cc775%40isocpp.or=
g.
------=_Part_1871_1679238250.1495309526348
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks for your answer. I see the problem now. The conditi=
on is a runtime condition. So this isn't going to work. But wouldn'=
t it be possible for a constexpr condition?<br><br>for Example:<br><br><div=
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" =
class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span st=
yle=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: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">is_integral_v</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"c=
olor: #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"> B</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{};</span></div></code></div><br><br><br>This would be like if cons=
texpr with implicit constexpr determinded by the compiler.<br><br><br>Am Sa=
mstag, 20. Mai 2017 19:41:57 UTC+2 schrieb ma.ka...@web.de:<blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi Guys,<br><br>I had the fol=
lowing situation:<br><br>I have a Group of StaticSet classes with a compati=
ble interface but distinct in there concrete type. empty_set is not an inte=
rvall!<br>I tried the following:<br><br><br>auto dec_digit =3D make_interva=
l('0', '0' + std::min(base, DECIMAL_BASE) - 1);<br>auto upp=
er_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A&=
#39; + (base - 1 - DECIMAL_BASE)) : empty_set;<br>auto lower_digit =3D (bas=
e > DECIMAL_DIGIT) ? make_interval('a', 'a' + (base - 1 =
- DECIMAL_BASE)) : empty_set;<br><br><br>Wouldn't it be possible to all=
ow such code, especially in conjunction with concepts?<br><br>MFG<br><br>Ma=
rtin Kalbfu=C3=9F<br></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9770742d-c5de-4a55-869f-ab71231cc775%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9770742d-c5de-4a55-869f-ab71231cc775=
%40isocpp.org</a>.<br />
------=_Part_1871_1679238250.1495309526348--
------=_Part_1870_1211906855.1495309526348--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 02:03:45 -0700 (PDT)
Raw View
------=_Part_2043_190528582.1495357425403
Content-Type: multipart/alternative;
boundary="----=_Part_2044_681404285.1495357425404"
------=_Part_2044_681404285.1495357425404
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I revisited your statement, that this isn't possible, because the type=20
would be determined at runtime. I have to disagree, now. It is possible at=
=20
compile time.
Look at the following code:
auto x =3D runtime_condition ? A{} : B{};
x.doit();
This is not going to work, as you stated. But you could write the following=
=20
instead:
auto f =3D [&](auto x) { x.doit(); };
runtime_condition ? f(A{}) : f(B{});
The code, following the ternary statement is moved into a generic lambda.
auto x =3D runtime_condition ? A{} : B{};
The generic lambda is instantiated two times, for each branch. Depending on=
=20
runtime_condition,
only one instance is executed. The statement
auto x =3D runtime_condition ? A{} : X{};
could introduce the following code inside the current scope twice, like the=
=20
generic lambda did. Ones for each type.
Depending on the runtime_condition, the code pointer is moved to the first=
=20
or the second instantiaton with a jump.
The following C++ code snippet describes roughly how the generated code=20
could look like.
#include <iostream>
struct A{ void doit(){ std::cout << "A::doit" << std::endl; } };
struct B{ void doit(){ std::cout << "B::doit" << std::endl; } };
int main()
{
auto runtime_condition =3D true;
if(runtime_condition)
goto ternary_branch_1;
else
goto ternary_branch_2;
ternary_branch_1:
A __instance1__;
__instance1__.doit();
return 0;
ternary_branch_2:
B __instance2__;
__instance2__.doit();
return 0;
}
Am Samstag, 20. Mai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:
>
> On s=C3=A1bado, 20 de maio de 2017 10:41:56 PDT ma.ka...@web.de <javascri=
pt:>=20
> wrote:=20
> > Hi Guys,=20
> >=20
> > I had the following situation:=20
> >=20
> > I have a Group of StaticSet classes with a compatible interface but=20
> > distinct in there concrete type. empty_set is not an intervall!=20
> > I tried the following:=20
> >=20
> >=20
> > auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE=
) -=20
> 1);=20
> > auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' +=
=20
> (base=20
> > - 1 - DECIMAL_BASE)) : empty_set;=20
> > auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' +=
=20
> (base=20
> > - 1 - DECIMAL_BASE)) : empty_set;=20
> >=20
> >=20
> > Wouldn't it be possible to allow such code, especially in conjunction=
=20
> with=20
> > concepts?=20
>
> No. lower_digit must have exactly one type, determined at compile-time.=
=20
> What=20
> you're asking for would cause the type to be determined at runtime, which=
=20
> is=20
> not possible in C++.=20
>
> Alternatives:=20
> * convert empty_set to make_interval's type=20
> * convert either to a common type (which you need to be explicit about, s=
o=20
> it=20
> won't work with auto)=20
> * use std::variant<interval, decltype(empty_set)>=20
>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
> Software Architect - Intel Open Source Technology Center=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/99350a9e-0c6b-468d-9761-f2b2b052275e%40isocpp.or=
g.
------=_Part_2044_681404285.1495357425404
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I revisited your statement, that this isn't possible, =
because the type would be determined at runtime. I have to disagree, now.=
=C2=A0 It is possible at compile time.<br><br>Look at the following code:<b=
r><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: bre=
ak-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">au=
to</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> runtime_condition </s=
pan><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"colo=
r: #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"> B</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>x</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></co=
de></div><br>This is not going to work, as you stated. But you could write =
the following instead:<br><br><div style=3D"background-color: rgb(250, 250,=
250); border-color: rgb(187, 187, 187); border-style: solid; border-width:=
1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> f </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </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"> x</span><spa=
n 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"> x</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">();</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"><br>runtime_condit=
ion </span><span style=3D"color: #660;" class=3D"styled-by-prettify">?</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</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: #6=
60;" 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"styled-by-p=
rettify"> f</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"><br></span></div></code=
></div><br>The code, following the ternary statement is moved into a generi=
c lambda.<br><code class=3D"prettyprint"><div style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> runtime_condition </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</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"co=
lor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>The generic lambd=
a is instantiated two times, for each branch. Depending on runtime_conditio=
n,<br>only one instance is executed. The statement<br></span></code><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"></span><br><span style=
=3D"color: #000;" class=3D"styled-by-prettify"></span><code class=3D"pretty=
print"><span style=3D"color: #000;" class=3D"styled-by-prettify"><div style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; overflow-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> runtime_condition </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">?</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> A</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"style=
d-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> X</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n></div></code></div><br>could introduce the following code inside the curr=
ent scope twice, like the generic lambda did. Ones for each type.<br>Depend=
ing on the runtime_condition, the code pointer is moved to the first or the=
second instantiaton with a jump.<br><br></span></code>The following C++ co=
de snippet describes roughly how the generated code could look like.<br><br=
><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187,=
187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-wo=
rd;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">#includ=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #080;" class=3D"styled-by-prettify"><iostream></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</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: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> doit</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-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">"A::doit&quo=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span st=
yle=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;" 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"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"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> B</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: #008;=
" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> doit</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-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
out </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&l=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #080;" class=3D"styled-by-prettify">"B::doit&quo=
t;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span st=
yle=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;" 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"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"><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"> main</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"co=
lor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> runtime_condition </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: #008;" cl=
ass=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"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">runtime_condition</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">goto</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> ternary_branch_1</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>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">else</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> ternary_branch_2</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br>ternary_branch_1</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 A __instance1__</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 __i=
nstance1__</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>ternary_branch_2</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 B __instance2__</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 __instance=
2__</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #66=
0;" 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"st=
yled-by-prettify">}</span></div></code></div><br><br><br><br><br><br><br>Am=
Samstag, 20. Mai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
#ccc solid;padding-left: 1ex;">On s=C3=A1bado, 20 de maio de 2017 10:41:56=
PDT <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"da4=
CDbczAwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:'=
;;return true;" onclick=3D"this.href=3D'javascript:';return true;">=
ma.ka...@web.de</a> wrote:
<br>> Hi Guys,
<br>>=20
<br>> I had the following situation:
<br>>=20
<br>> I have a Group of StaticSet classes with a compatible interface bu=
t
<br>> distinct in there concrete type. empty_set is not an intervall!
<br>> I tried the following:
<br>>=20
<br>>=20
<br>> auto dec_digit =3D make_interval('0', '0' + std::m=
in(base, DECIMAL_BASE) - 1);
<br>> auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval(=
9;A', 'A' + (base
<br>> - 1 - DECIMAL_BASE)) : empty_set;
<br>> auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval(=
9;a', 'a' + (base
<br>> - 1 - DECIMAL_BASE)) : empty_set;
<br>>=20
<br>>=20
<br>> Wouldn't it be possible to allow such code, especially in conj=
unction with
<br>> concepts?
<br>
<br>No. lower_digit must have exactly one type, determined at compile-time.=
What=20
<br>you're asking for would cause the type to be determined at runtime,=
which is=20
<br>not possible in C++.
<br>
<br>Alternatives:
<br>* convert empty_set to make_interval's type
<br>* convert either to a common type (which you need to be explicit about,=
so it=20
<br>=C2=A0 =C2=A0won't work with auto)
<br>* use std::variant<interval, decltype(empty_set)>
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/99350a9e-0c6b-468d-9761-f2b2b052275e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/99350a9e-0c6b-468d-9761-f2b2b052275e=
%40isocpp.org</a>.<br />
------=_Part_2044_681404285.1495357425404--
------=_Part_2043_190528582.1495357425403--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 02:15:21 -0700 (PDT)
Raw View
------=_Part_2087_1113621356.1495358121806
Content-Type: multipart/alternative;
boundary="----=_Part_2088_1911461960.1495358121807"
------=_Part_2088_1911461960.1495358121807
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
The coresponding assembly code without iostream to avoid unecessary=20
complexity:
A::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
B::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov BYTE PTR [rbp-1], 1
cmp BYTE PTR [rbp-1], 0
je .L9
nop
lea rax, [rbp-2]
mov rdi, rax
call A::doit()
mov eax, 0
jmp .L8
..L9:
nop
lea rax, [rbp-3]
mov rdi, rax
call B::doit()
mov eax, 0
..L8:
leave
ret
Am Sonntag, 21. Mai 2017 11:03:45 UTC+2 schrieb ma.ka...@web.de:
>
> I revisited your statement, that this isn't possible, because the type=20
> would be determined at runtime. I have to disagree, now. It is possible =
at=20
> compile time.
>
> Look at the following code:
>
> auto x =3D runtime_condition ? A{} : B{};
> x.doit();
>
> This is not going to work, as you stated. But you could write the=20
> following instead:
>
> auto f =3D [&](auto x) { x.doit(); };
> runtime_condition ? f(A{}) : f(B{});
>
> The code, following the ternary statement is moved into a generic lambda.
> auto x =3D runtime_condition ? A{} : B{};
>
> The generic lambda is instantiated two times, for each branch. Depending=
=20
> on runtime_condition,
> only one instance is executed. The statement
>
> auto x =3D runtime_condition ? A{} : X{};
>
> could introduce the following code inside the current scope twice, like=
=20
> the generic lambda did. Ones for each type.
> Depending on the runtime_condition, the code pointer is moved to the firs=
t=20
> or the second instantiaton with a jump.
>
> The following C++ code snippet describes roughly how the generated code=
=20
> could look like.
>
> #include <iostream>
>
> struct A{ void doit(){ std::cout << "A::doit" << std::endl; } };
> struct B{ void doit(){ std::cout << "B::doit" << std::endl; } };
>
> int main()
> {
> auto runtime_condition =3D true;
>
> if(runtime_condition)
> goto ternary_branch_1;
> else
> goto ternary_branch_2;
>
> ternary_branch_1:
> A __instance1__;
> __instance1__.doit();
> return 0;
> ternary_branch_2:
> B __instance2__;
> __instance2__.doit();
> return 0;
> }
>
>
>
>
>
>
>
> Am Samstag, 20. Mai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:
>>
>> On s=C3=A1bado, 20 de maio de 2017 10:41:56 PDT ma.ka...@web.de wrote:=
=20
>> > Hi Guys,=20
>> >=20
>> > I had the following situation:=20
>> >=20
>> > I have a Group of StaticSet classes with a compatible interface but=20
>> > distinct in there concrete type. empty_set is not an intervall!=20
>> > I tried the following:=20
>> >=20
>> >=20
>> > auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BAS=
E)=20
>> - 1);=20
>> > auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' +=
=20
>> (base=20
>> > - 1 - DECIMAL_BASE)) : empty_set;=20
>> > auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' +=
=20
>> (base=20
>> > - 1 - DECIMAL_BASE)) : empty_set;=20
>> >=20
>> >=20
>> > Wouldn't it be possible to allow such code, especially in conjunction=
=20
>> with=20
>> > concepts?=20
>>
>> No. lower_digit must have exactly one type, determined at compile-time.=
=20
>> What=20
>> you're asking for would cause the type to be determined at runtime, whic=
h=20
>> is=20
>> not possible in C++.=20
>>
>> Alternatives:=20
>> * convert empty_set to make_interval's type=20
>> * convert either to a common type (which you need to be explicit about,=
=20
>> so it=20
>> won't work with auto)=20
>> * use std::variant<interval, decltype(empty_set)>=20
>>
>> --=20
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>> Software Architect - Intel Open Source Technology Center=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/5d084b24-5fd4-4a81-968f-aa8561b19e09%40isocpp.or=
g.
------=_Part_2088_1911461960.1495358121807
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The coresponding assembly code without iostream to avoid u=
necessary complexity:<br><br><div style=3D"background-color: rgb(250, 250, =
250); border-color: rgb(187, 187, 187); border-style: solid; border-width: =
1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D=
"styled-by-prettify">A</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">8</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">],</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>B=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">():</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">8</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">],</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rdi<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0=
=C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>main</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=
=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">su=
b</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =
=C2=A0 rsp</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: #066;" class=3D"styled-by-prettify">16</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1=
</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: #066;" class=3D"styled-by-prettify">1</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmp =
=C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><spa=
n 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=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=A0 =C2=
=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L9<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=
=A0 rax</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: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 call =C2=A0 =C2=A0A</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=
=3D"styled-by-prettify">0</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">L8<br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">L9</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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: #000;" class=3D"styled-by-prettify">rbp=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">3</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
ax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0B</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax<=
/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: #066;" class=3D"styled-by-prettify">0</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">L8</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 leave<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
ret</span></div></code></div><br><br><br><br><br>Am Sonntag, 21. Mai 2017 =
11:03:45 UTC+2 schrieb ma.ka...@web.de:<blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;"><div dir=3D"ltr">I revisited your statement, that this isn't p=
ossible, because the type would be determined at runtime. I have to disagre=
e, now.=C2=A0 It is possible at compile time.<br><br>Look at the following =
code:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px"><code><div><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> x </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> runtime_condition </s=
pan><span style=3D"color:#660">?</span><span style=3D"color:#000"> A</span>=
<span style=3D"color:#660">{}</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">:</span><span style=3D"color:#000"> B</span><span st=
yle=3D"color:#660">{};</span><span style=3D"color:#000"><br>x</span><span s=
tyle=3D"color:#660">.</span><span style=3D"color:#000">doit</span><span sty=
le=3D"color:#660">();</span><span style=3D"color:#000"><br></span></div></c=
ode></div><br>This is not going to work, as you stated. But you could write=
the following instead:<br><br><div style=3D"background-color:rgb(250,250,2=
50);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><cod=
e><div><span style=3D"color:#008">auto</span><span style=3D"color:#000"> f =
</span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">[&](</span><span style=3D"color:#008">au=
to</span><span style=3D"color:#000"> x</span><span style=3D"color:#660">)</=
span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span>=
<span style=3D"color:#000"> x</span><span style=3D"color:#660">.</span><spa=
n style=3D"color:#000">doit</span><span style=3D"color:#660">();</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660">};</span><span st=
yle=3D"color:#000"><br>runtime_condition </span><span style=3D"color:#660">=
?</span><span style=3D"color:#000"> f</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#000">A</span><span style=3D"color:#660">{})</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">:</span><spa=
n style=3D"color:#000"> f</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">B</span><span style=3D"color:#660">{});</span><span styl=
e=3D"color:#000"><br></span></div></code></div><br>The code, following the =
ternary statement is moved into a generic lambda.<br><code><div style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px"><code><div><span style=3D"color:#008">auto</span><s=
pan style=3D"color:#000"> x </span><span style=3D"color:#660">=3D</span><sp=
an style=3D"color:#000"> runtime_condition </span><span style=3D"color:#660=
">?</span><span style=3D"color:#000"> A</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"> B</span><span style=3D"color:#660">{};</span>=
<span style=3D"color:#000"><br></span></div></code></div><span style=3D"col=
or:#000"><br>The generic lambda is instantiated two times, for each branch.=
Depending on runtime_condition,<br>only one instance is executed. The stat=
ement<br></span></code><span style=3D"color:#000"></span><br><span style=3D=
"color:#000"></span><code><span style=3D"color:#000"><div style=3D"backgrou=
nd-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;=
border-width:1px"><code><div><span style=3D"color:#008">auto</span><span st=
yle=3D"color:#000"> x </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> runtime_condition </span><span style=3D"color:#660">?</s=
pan><span style=3D"color:#000"> A</span><span style=3D"color:#660">{}</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">:</span><spa=
n style=3D"color:#000"> X</span><span style=3D"color:#660">{};</span><span =
style=3D"color:#000"><br></span></div></code></div><br>could introduce the =
following code inside the current scope twice, like the generic lambda did.=
Ones for each type.<br>Depending on the runtime_condition, the code pointe=
r is moved to the first or the second instantiaton with a jump.<br><br></sp=
an></code>The following C++ code snippet describes roughly how the generate=
d code could look like.<br><br><div style=3D"background-color:rgb(250,250,2=
50);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><cod=
e><div><span style=3D"color:#800">#include</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080"><iostream></span><span style=3D"c=
olor:#000"><br><br></span><span style=3D"color:#008">struct</span><span sty=
le=3D"color:#000"> A</span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> doit</span><span style=3D"color:#660">(){</span><span styl=
e=3D"color:#000"> std</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">"A::doit"=
;</span><span style=3D"color:#000"> </span><span style=3D"color:#660"><&=
lt;</span><span style=3D"color:#000"> std</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"> </span><span style=3D"color:#660">};</span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#008">struct</span=
><span style=3D"color:#000"> B</span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#008">void</span><span=
style=3D"color:#000"> doit</span><span style=3D"color:#660">(){</span><spa=
n style=3D"color:#000"> std</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">"B::doi=
t"</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
><<</span><span style=3D"color:#000"> std</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">=
}</span><span style=3D"color:#000"> </span><span style=3D"color:#660">};</s=
pan><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">in=
t</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:#660">{<=
/span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"co=
lor:#008">auto</span><span style=3D"color:#000"> runtime_condition </span><=
span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">true</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008=
">if</span><span style=3D"color:#660">(</span><span style=3D"color:#000">ru=
ntime_condition</span><span style=3D"color:#660">)</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">=
goto</span><span style=3D"color:#000"> ternary_branch_1</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color:#008">else</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">goto</span><span=
style=3D"color:#000"> ternary_branch_2</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br><br>ternary_branch_1</span><span style=
=3D"color:#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 A __in=
stance1__</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"><br>=C2=A0 =C2=A0 __instance1__</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">doit</span><span style=3D"color:#660">();</span=
><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#=
008">return</span><span style=3D"color:#000"> </span><span style=3D"color:#=
066">0</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br>ternary_branch_2</span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 B __instance2__</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 __instance2__<=
/span><span style=3D"color:#660">.</span><span style=3D"color:#000">doit</s=
pan><span style=3D"color:#660">();</span><span style=3D"color:#000"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#066">0</span><span style=3D"color:#=
660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">}</span></div></code></div><br><br><br><br><br><br><br>Am Samstag, 20. M=
ai 2017 21:29:56 UTC+2 schrieb Thiago Macieira:<blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex">On s=C3=A1bado, 20 de maio de 2017 10:41:56 PDT <a rel=3D"nofol=
low">ma.ka...@web.de</a> wrote:
<br>> Hi Guys,
<br>>=20
<br>> I had the following situation:
<br>>=20
<br>> I have a Group of StaticSet classes with a compatible interface bu=
t
<br>> distinct in there concrete type. empty_set is not an intervall!
<br>> I tried the following:
<br>>=20
<br>>=20
<br>> auto dec_digit =3D make_interval('0', '0' + std::m=
in(base, DECIMAL_BASE) - 1);
<br>> auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval(=
9;A', 'A' + (base
<br>> - 1 - DECIMAL_BASE)) : empty_set;
<br>> auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval(=
9;a', 'a' + (base
<br>> - 1 - DECIMAL_BASE)) : empty_set;
<br>>=20
<br>>=20
<br>> Wouldn't it be possible to allow such code, especially in conj=
unction with
<br>> concepts?
<br>
<br>No. lower_digit must have exactly one type, determined at compile-time.=
What=20
<br>you're asking for would cause the type to be determined at runtime,=
which is=20
<br>not possible in C++.
<br>
<br>Alternatives:
<br>* convert empty_set to make_interval's type
<br>* convert either to a common type (which you need to be explicit about,=
so it=20
<br>=C2=A0 =C2=A0won't work with auto)
<br>* use std::variant<interval, decltype(empty_set)>
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.googl=
e.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3=
dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return tru=
e;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofol=
low" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.co=
m/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGR=
Jdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5d084b24-5fd4-4a81-968f-aa8561b19e09%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5d084b24-5fd4-4a81-968f-aa8561b19e09=
%40isocpp.org</a>.<br />
------=_Part_2088_1911461960.1495358121807--
------=_Part_2087_1113621356.1495358121806--
.
Author: Mingxin Wang <wmx16835vv@163.com>
Date: Sun, 21 May 2017 06:00:03 -0700 (PDT)
Raw View
------=_Part_2126_688443543.1495371603183
Content-Type: multipart/alternative;
boundary="----=_Part_2127_711408470.1495371603183"
------=_Part_2127_711408470.1495371603183
Content-Type: text/plain; charset="UTF-8"
You may as well consider the following situations:
*Loops*
It is difficult for compilers to generate code for loops with the feature
you proposed, e.g.:
void foo(int n) {
/* A: Do something before the loop */
for (int i = 0; i < n; ++i) {
/* B: Do something */
auto x = runtime_condition() ? A{} : B{};
/* C: Do some other things with x */
}
/* D: Do something after the loop */
}
*Code Snippet 1*
As far as I am concerned, here is the equivalent of the code that the
compiler would automatically generate for the code above (with your method):
template <class T>
void bar(int i, int n, T x) {
/* C: Do some other things with x */
++i;
if (i < n) {
/* B: Do something */
if (runtime_condition()) {
bar(i, n, A{});
} else {
bar(i, n, B{});
}
}
}
void foo(int n) {
/* A: Do something before the loop */
if (0 < n) {
/* B: Do something */
if (runtime_condition()) {
bar(1, n, A{});
} else {
bar(1, n, B{});
}
}
/* D: Do something after the loop */
}
*Code Snippet 2*
It is too complicated! Moreover, as the recursive call of the "function
template bar" is not able to be optimized, it will possibly increase the
runtime overhead.
*Size*
Compilers may generate a lot of redundant code when the feature is used
extensively, e.g.:
auto x0 = runtime_condition_0() ? A0{} : B0{};
auto x1 = runtime_condition_1() ? A1{} : B1{};
// ...
auto xn = runtime_condition_n() ? An{} : Bn{};
*Code Snippet 3*
As you introduced, the compiler is supposed to generate code for every
path! For the code above, it requires O(2^n) size for code generation,
which is NOT acceptable in most cases.
In fact, the challenges above can be solved gracefully with the "proxies"
and the "wrappers".
As the condition is determined at runtime, the concrete type cannot be
deduced at compile time. The only reason for us to save the returned value
is that *they have similar expressions and semantics*. We can simply
extract the common expressions of the types which are used in the context
to a "proxy", and save the returned value with a "wrapper", e.g. Code
Snippet 1 can be reconstructed as is shown below (with better performance
and smaller size):
/* Declares the common expressions required in the context */
proxy P {
void f_0();
double f_1(int, int);
};
void foo(int n) {
/* A: Do something before the loop */
for (int i = 0; i < n; ++i) {
/* B: Do something */
Wrapper<P> x(runtime_condition() ? Wrapper<P>(A{}) : Wrapper<P>(B{}));
P p = x.get_proxy();
/* C: Do some other things with p */
}
/* D: Do something after the loop */
}
*Code Snippet 4*
Mingxin Wang
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/795341bd-d042-49c9-9eba-6b8ac6ca8a5e%40isocpp.org.
------=_Part_2127_711408470.1495371603183
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><font face=3D"georgia, serif">You may as well conside=
r the following situations:<br></font></div><div><font face=3D"georgia, ser=
if"><br></font></div><div><div style=3D"font-family: georgia, serif;"><b><f=
ont size=3D"4">Loops</font></b></div><div style=3D"font-family: georgia, se=
rif;"><br></div><div style=3D"font-family: georgia, serif;">It is difficult=
for compilers to generate code for loops with the feature you proposed, e.=
g.:</div><div style=3D"font-family: georgia, serif;"><br></div><div style=
=3D"font-family: georgia, serif;"><div class=3D"prettyprint" style=3D"borde=
r: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: r=
gb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><div class=3D"subprettyprint">void foo(int n) {</div><div class=3D"subpr=
ettyprint">=C2=A0 /* A: Do something before the loop */</div><div class=3D"=
subprettyprint">=C2=A0 for (int i =3D 0; i < n; ++i) {</div><div class=
=3D"subprettyprint">=C2=A0 =C2=A0 /* B: Do something */</div><div class=3D"=
subprettyprint">=C2=A0 =C2=A0 auto x =3D runtime_condition() ? A{} : B{};</=
div><div class=3D"subprettyprint">=C2=A0 =C2=A0 /* C: Do some other things =
with x */</div><div class=3D"subprettyprint">=C2=A0 }</div><div class=3D"su=
bprettyprint">=C2=A0 /* D: Do something after the loop */</div><div class=
=3D"subprettyprint">}</div></div></code></div><div style=3D"text-align: cen=
ter;"><b>Code Snippet 1</b></div></div><div style=3D"font-family: georgia, =
serif;"><br></div><div style=3D"font-family: georgia, serif;">As far as I a=
m concerned, here is the equivalent of the code that the compiler would aut=
omatically generate for the code above (with your method):<br></div><div st=
yle=3D"font-family: georgia, serif;"><br></div><div><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"><font color=3D"#660066"><div class=3D"subprettyprint">=
template <class T></div><div class=3D"subprettyprint">void bar(int i,=
int n, T x) {</div><div class=3D"subprettyprint">=C2=A0 /* C: Do some othe=
r things with x */</div><div class=3D"subprettyprint">=C2=A0 ++i;</div><div=
class=3D"subprettyprint">=C2=A0 if (i < n) {</div><div class=3D"subpret=
typrint">=C2=A0 =C2=A0 /* B: Do something */</div><div class=3D"subprettypr=
int">=C2=A0 =C2=A0 if (runtime_condition()) {</div><div class=3D"subprettyp=
rint">=C2=A0 =C2=A0 =C2=A0 bar(i, n, A{});</div><div class=3D"subprettyprin=
t">=C2=A0 =C2=A0 } else {</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =
=C2=A0 bar(i, n, B{});</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 }</=
div><div class=3D"subprettyprint">=C2=A0 }</div><div class=3D"subprettyprin=
t">}</div><div class=3D"subprettyprint"><br></div><div class=3D"subprettypr=
int">void foo(int n) {</div><div class=3D"subprettyprint">=C2=A0 /* A: Do s=
omething before the loop */</div><div class=3D"subprettyprint">=C2=A0 if (0=
< n) {</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 /* B: Do someth=
ing */</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 if (runtime_conditi=
on()) {</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 bar(1, n, A=
{});</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 } else {</div><div cl=
ass=3D"subprettyprint">=C2=A0 =C2=A0 =C2=A0 bar(1, n, B{});</div><div class=
=3D"subprettyprint">=C2=A0 =C2=A0 }</div><div class=3D"subprettyprint">=C2=
=A0 }</div><div class=3D"subprettyprint">=C2=A0 /* D: Do something after th=
e loop */</div><div class=3D"subprettyprint">}</div></font></div></code></d=
iv><div style=3D"text-align: center; "><font face=3D"georgia, serif"><b>Cod=
e Snippet 2</b></font></div><div><font face=3D"georgia, serif"><br></font><=
/div><div><font face=3D"georgia, serif">It is too complicated! Moreover, as=
the recursive call of the "function template bar" is not able to=
be optimized, it will possibly increase the runtime overhead.</font></div>=
<div><font face=3D"georgia, serif"><br></font></div><div><font face=3D"geor=
gia, serif" size=3D"4"><b>Size</b></font></div><div><font face=3D"georgia, =
serif"><br></font></div><div><font face=3D"georgia, serif">Compilers may ge=
nerate a lot of redundant code when the feature is used extensively, e.g.:<=
/font></div></div><div><font face=3D"georgia, serif"><br></font></div><div>=
<font face=3D"georgia, serif"><div class=3D"prettyprint" style=3D"border: 1=
px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(2=
50, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
div class=3D"subprettyprint">auto x0 =3D runtime_condition_0() ? A0{} : B0{=
};</div><div class=3D"subprettyprint">auto x1 =3D runtime_condition_1() ? A=
1{} : B1{};</div><div class=3D"subprettyprint">// ...</div><div class=3D"su=
bprettyprint">auto xn =3D runtime_condition_n() ? An{} : Bn{};</div></div><=
/code></div><div style=3D"text-align: center; "><b>Code Snippet 3</b></div>=
<div><br></div><div>As you introduced, the compiler is supposed to generate=
code for every path! For the code above, it requires O(2^n) size for code =
generation, which is NOT acceptable in most cases.</div><div><br></div><div=
>In fact, the challenges above can be solved gracefully with the "prox=
ies" and the "wrappers".</div><div><br></div><div>As the con=
dition is determined at runtime, the concrete type cannot be deduced at com=
pile time. The only reason for us to save the returned value is that <b>the=
y have similar expressions and semantics</b>. We can simply extract the com=
mon expressions of the types which are used in the context to a "proxy=
", and save the returned value with a "wrapper", e.g. Code S=
nippet 1 can be reconstructed as is shown below (with better performance an=
d smaller size):</div></font></div><div><font face=3D"georgia, serif"><br><=
/font></div></div><div><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"><font co=
lor=3D"#660066"><div class=3D"subprettyprint">/* Declares the common expres=
sions required in the context */</div><div class=3D"subprettyprint">proxy P=
{</div><div class=3D"subprettyprint">=C2=A0 void f_0();</div><div class=3D=
"subprettyprint">=C2=A0 double f_1(int, int);</div><div class=3D"subprettyp=
rint">};</div><div class=3D"subprettyprint"><br></div><div class=3D"subpret=
typrint">void foo(int n) {</div><div class=3D"subprettyprint">=C2=A0 /* A: =
Do something before the loop */</div><div class=3D"subprettyprint">=C2=A0 f=
or (int i =3D 0; i < n; ++i) {</div><div class=3D"subprettyprint">=C2=A0=
=C2=A0 /* B: Do something */</div><div class=3D"subprettyprint">=C2=A0 =C2=
=A0 Wrapper<P> x(runtime_condition() ? Wrapper<P>(A{}) : Wrappe=
r<P>(B{}));</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 P p =3D =
x.get_proxy();</div><div class=3D"subprettyprint">=C2=A0 =C2=A0 /* C: Do so=
me other things with p */</div><div class=3D"subprettyprint">=C2=A0 }</div>=
<div class=3D"subprettyprint">=C2=A0 /* D: Do something after the loop */</=
div><div class=3D"subprettyprint">}</div></font></div></code></div><div sty=
le=3D"text-align: center;"><font face=3D"georgia, serif"><b>Code Snippet 4<=
/b></font></div></div><div style=3D"text-align: left;"><font face=3D"georgi=
a, serif"><br></font></div><div style=3D"text-align: left;"><font face=3D"g=
eorgia, serif">Mingxin Wang</font></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/795341bd-d042-49c9-9eba-6b8ac6ca8a5e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/795341bd-d042-49c9-9eba-6b8ac6ca8a5e=
%40isocpp.org</a>.<br />
------=_Part_2127_711408470.1495371603183--
------=_Part_2126_688443543.1495371603183--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 07:07:54 -0700 (PDT)
Raw View
------=_Part_2118_1299156135.1495375674459
Content-Type: multipart/alternative;
boundary="----=_Part_2119_2006947193.1495375674459"
------=_Part_2119_2006947193.1495375674459
Content-Type: text/plain; charset="UTF-8"
Am Sonntag, 21. Mai 2017 15:00:03 UTC+2 schrieb Mingxin Wang:
>
> You may as well consider the following situations:
>
> *Loops*
>
> It is difficult for compilers to generate code for loops with the feature
> you proposed, e.g.:
>
> void foo(int n) {
> /* A: Do something before the loop */
> for (int i = 0; i < n; ++i) {
> /* B: Do something */
> auto x = runtime_condition() ? A{} : B{};
> /* C: Do some other things with x */
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 1*
>
> As far as I am concerned, here is the equivalent of the code that the
> compiler would automatically generate for the code above (with your method):
>
> template <class T>
> void bar(int i, int n, T x) {
> /* C: Do some other things with x */
> ++i;
> if (i < n) {
> /* B: Do something */
> if (runtime_condition()) {
> bar(i, n, A{});
> } else {
> bar(i, n, B{});
> }
> }
> }
>
> void foo(int n) {
> /* A: Do something before the loop */
> if (0 < n) {
> /* B: Do something */
> if (runtime_condition()) {
> bar(1, n, A{});
> } else {
> bar(1, n, B{});
> }
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 2*
>
> It is too complicated! Moreover, as the recursive call of the "function
> template bar" is not able to be optimized, it will possibly increase the
> runtime overhead.
>
> *Size*
>
> Compilers may generate a lot of redundant code when the feature is used
> extensively, e.g.:
>
> auto x0 = runtime_condition_0() ? A0{} : B0{};
> auto x1 = runtime_condition_1() ? A1{} : B1{};
> // ...
> auto xn = runtime_condition_n() ? An{} : Bn{};
> *Code Snippet 3*
>
> As you introduced, the compiler is supposed to generate code for every
> path! For the code above, it requires O(2^n) size for code generation,
> which is NOT acceptable in most cases.
>
> In fact, the challenges above can be solved gracefully with the "proxies"
> and the "wrappers".
>
> As the condition is determined at runtime, the concrete type cannot be
> deduced at compile time. The only reason for us to save the returned value
> is that *they have similar expressions and semantics*. We can simply
> extract the common expressions of the types which are used in the context
> to a "proxy", and save the returned value with a "wrapper", e.g. Code
> Snippet 1 can be reconstructed as is shown below (with better performance
> and smaller size):
>
> /* Declares the common expressions required in the context */
> proxy P {
> void f_0();
> double f_1(int, int);
> };
>
> void foo(int n) {
> /* A: Do something before the loop */
> for (int i = 0; i < n; ++i) {
> /* B: Do something */
> Wrapper<P> x(runtime_condition() ? Wrapper<P>(A{}) : Wrapper<P>(B{}));
> P p = x.get_proxy();
> /* C: Do some other things with p */
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 4*
>
> Mingxin Wang
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5b87a9c6-b15d-465d-9d42-1620842e4f86%40isocpp.org.
------=_Part_2119_2006947193.1495375674459
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Am Sonntag, 21. Mai 2017 15:00:03 UTC+2 schrieb Mingxin Wa=
ng:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><font=
face=3D"georgia, serif">You may as well consider the following situations:=
<br></font></div><div><font face=3D"georgia, serif"><br></font></div><div><=
div style=3D"font-family:georgia,serif"><b><font size=3D"4">Loops</font></b=
></div><div style=3D"font-family:georgia,serif"><br></div><div style=3D"fon=
t-family:georgia,serif">It is difficult for compilers to generate code for =
loops with the feature you proposed, e.g.:</div><div style=3D"font-family:g=
eorgia,serif"><br></div><div style=3D"font-family:georgia,serif"><div style=
=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color=
:rgb(250,250,250)"><code><div><div>void foo(int n) {</div><div>=C2=A0 /* A:=
Do something before the loop */</div><div>=C2=A0 for (int i =3D 0; i < =
n; ++i) {</div><div>=C2=A0 =C2=A0 /* B: Do something */</div><div>=C2=A0 =
=C2=A0 auto x =3D runtime_condition() ? A{} : B{};</div><div>=C2=A0 =C2=A0 =
/* C: Do some other things with x */</div><div>=C2=A0 }</div><div>=C2=A0 /*=
D: Do something after the loop */</div><div>}</div></div></code></div><div=
style=3D"text-align:center"><b>Code Snippet 1</b></div></div><div style=3D=
"font-family:georgia,serif"><br></div><div style=3D"font-family:georgia,ser=
if">As far as I am concerned, here is the equivalent of the code that the c=
ompiler would automatically generate for the code above (with your method):=
<br></div><div style=3D"font-family:georgia,serif"><br></div><div><div styl=
e=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-colo=
r:rgb(250,250,250)"><code><div><font color=3D"#660066"><div>template <cl=
ass T></div><div>void bar(int i, int n, T x) {</div><div>=C2=A0 /* C: Do=
some other things with x */</div><div>=C2=A0 ++i;</div><div>=C2=A0 if (i &=
lt; n) {</div><div>=C2=A0 =C2=A0 /* B: Do something */</div><div>=C2=A0 =C2=
=A0 if (runtime_condition()) {</div><div>=C2=A0 =C2=A0 =C2=A0 bar(i, n, A{}=
);</div><div>=C2=A0 =C2=A0 } else {</div><div>=C2=A0 =C2=A0 =C2=A0 bar(i, n=
, B{});</div><div>=C2=A0 =C2=A0 }</div><div>=C2=A0 }</div><div>}</div><div>=
<br></div><div>void foo(int n) {</div><div>=C2=A0 /* A: Do something before=
the loop */</div><div>=C2=A0 if (0 < n) {</div><div>=C2=A0 =C2=A0 /* B:=
Do something */</div><div>=C2=A0 =C2=A0 if (runtime_condition()) {</div><d=
iv>=C2=A0 =C2=A0 =C2=A0 bar(1, n, A{});</div><div>=C2=A0 =C2=A0 } else {</d=
iv><div>=C2=A0 =C2=A0 =C2=A0 bar(1, n, B{});</div><div>=C2=A0 =C2=A0 }</div=
><div>=C2=A0 }</div><div>=C2=A0 /* D: Do something after the loop */</div><=
div>}</div></font></div></code></div><div style=3D"text-align:center"><font=
face=3D"georgia, serif"><b>Code Snippet 2</b></font></div><div><font face=
=3D"georgia, serif"><br></font></div><div><font face=3D"georgia, serif">It =
is too complicated! Moreover, as the recursive call of the "function t=
emplate bar" is not able to be optimized, it will possibly increase th=
e runtime overhead.</font></div><div><font face=3D"georgia, serif"><br></fo=
nt></div><div><font size=3D"4" face=3D"georgia, serif"><b>Size</b></font></=
div><div><font face=3D"georgia, serif"><br></font></div><div><font face=3D"=
georgia, serif">Compilers may generate a lot of redundant code when the fea=
ture is used extensively, e.g.:</font></div></div><div><font face=3D"georgi=
a, serif"><br></font></div><div><font face=3D"georgia, serif"><div style=3D=
"border:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rg=
b(250,250,250)"><code><div><div>auto x0 =3D runtime_condition_0() ? A0{} : =
B0{};</div><div>auto x1 =3D runtime_condition_1() ? A1{} : B1{};</div><div>=
// ...</div><div>auto xn =3D runtime_condition_n() ? An{} : Bn{};</div></di=
v></code></div><div style=3D"text-align:center"><b>Code Snippet 3</b></div>=
<div><br></div><div>As you introduced, the compiler is supposed to generate=
code for every path! For the code above, it requires O(2^n) size for code =
generation, which is NOT acceptable in most cases.</div><div><br></div><div=
>In fact, the challenges above can be solved gracefully with the "prox=
ies" and the "wrappers".</div><div><br></div><div>As the con=
dition is determined at runtime, the concrete type cannot be deduced at com=
pile time. The only reason for us to save the returned value is that <b>the=
y have similar expressions and semantics</b>. We can simply extract the com=
mon expressions of the types which are used in the context to a "proxy=
", and save the returned value with a "wrapper", e.g. Code S=
nippet 1 can be reconstructed as is shown below (with better performance an=
d smaller size):</div></font></div><div><font face=3D"georgia, serif"><br><=
/font></div></div><div><div style=3D"border:1px solid rgb(187,187,187);word=
-wrap:break-word;background-color:rgb(250,250,250)"><code><div><font color=
=3D"#660066"><div>/* Declares the common expressions required in the contex=
t */</div><div>proxy P {</div><div>=C2=A0 void f_0();</div><div>=C2=A0 doub=
le f_1(int, int);</div><div>};</div><div><br></div><div>void foo(int n) {</=
div><div>=C2=A0 /* A: Do something before the loop */</div><div>=C2=A0 for =
(int i =3D 0; i < n; ++i) {</div><div>=C2=A0 =C2=A0 /* B: Do something *=
/</div><div>=C2=A0 =C2=A0 Wrapper<P> x(runtime_condition() ? Wrapper&=
lt;P>(A{}) : Wrapper<P>(B{}));</div><div>=C2=A0 =C2=A0 P p =3D x.g=
et_proxy();</div><div>=C2=A0 =C2=A0 /* C: Do some other things with p */</d=
iv><div>=C2=A0 }</div><div>=C2=A0 /* D: Do something after the loop */</div=
><div>}</div></font></div></code></div><div style=3D"text-align:center"><fo=
nt face=3D"georgia, serif"><b>Code Snippet 4</b></font></div></div><div sty=
le=3D"text-align:left"><font face=3D"georgia, serif"><br></font></div><div =
style=3D"text-align:left"><font face=3D"georgia, serif">Mingxin Wang</font>=
</div></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5b87a9c6-b15d-465d-9d42-1620842e4f86%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5b87a9c6-b15d-465d-9d42-1620842e4f86=
%40isocpp.org</a>.<br />
------=_Part_2119_2006947193.1495375674459--
------=_Part_2118_1299156135.1495375674459--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 07:11:13 -0700 (PDT)
Raw View
------=_Part_2087_1742423123.1495375873967
Content-Type: multipart/alternative;
boundary="----=_Part_2088_776051707.1495375873969"
------=_Part_2088_776051707.1495375873969
Content-Type: text/plain; charset="UTF-8"
The following code should be generated when a loop is involved. the loop
has its own scope. The code duplication is limited to the scope of the loop.
But let's improve it further. Instead of duplicate the following code in
the enclosing scope, it is sufficient to duplicate the dependend code.
Code is dependend if the result of the ternary operation is involved. So
only these parst are duplicated. As an addition, the code is only
duplicated,
if the condition is known at runtime. If it is known at compile time, only
one branch is created. Code outside of the loop or the code necessary to
implement the loop is NOT duplicated and is not part of the branches. For
now, I will call this construct "generic ternary operator". Like other
generics
it introduces code duplication. It's not a special problem of this
construct.
It is important, that existing code does not break. For cases where the
existing conversion rules apply, there should be no duplication.
Exmaple including a loop:
struct A{ void doit(){ } };
struct B{ void doit(){ } };
int main()
{
auto runtime_condition = true;
for(int i = 0; i < 100; i++) {
auto x = runtime_condition ? A{} : B{};
x.doit();
/* do something without x */
x.doit()
/* do something without x */
}
return 0;
}
struct A{ void doit(){ } };
struct B{ void doit(){ } };
int main()
{
auto runtime_condition = true;
for(int i = 0; i < 100; i++) {
if(runtime_condition)
goto ternary_branch_1;
else
goto ternary_branch_2;
ternary_branch_1:
A __instance1__;
__instance1__.doit();
goto ternary_end_1;
ternary_branch_2:
B __instance2__;
__instance2__.doit();
ternary_end_1:
/* do something without x */;
ternary_branch_3:
__instance1__.doit();
goto ternary_end_2;
ternary_branch_4:
__instance2__.doit();
ternary_end_2:
/* do something without x */;
}
return 0;
}
A::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
B::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov BYTE PTR [rbp-5], 1
mov DWORD PTR [rbp-4], 0
..L11:
cmp DWORD PTR [rbp-4], 99
jg .L4
cmp BYTE PTR [rbp-5], 0
je .L13
nop
lea rax, [rbp-6]
mov rdi, rax
call A::doit()
jmp .L9
..L13:
nop
lea rax, [rbp-7]
mov rdi, rax
call B::doit()
..L9:
lea rax, [rbp-6]
mov rdi, rax
call A::doit()
nop
add DWORD PTR [rbp-4], 1
jmp .L11
..L4:
mov eax, 0
leave
ret
Am Sonntag, 21. Mai 2017 15:00:03 UTC+2 schrieb Mingxin Wang:
>
> You may as well consider the following situations:
>
> *Loops*
>
> It is difficult for compilers to generate code for loops with the feature
> you proposed, e.g.:
>
> void foo(int n) {
> /* A: Do something before the loop */
> for (int i = 0; i < n; ++i) {
> /* B: Do something */
> auto x = runtime_condition() ? A{} : B{};
> /* C: Do some other things with x */
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 1*
>
> As far as I am concerned, here is the equivalent of the code that the
> compiler would automatically generate for the code above (with your method):
>
> template <class T>
> void bar(int i, int n, T x) {
> /* C: Do some other things with x */
> ++i;
> if (i < n) {
> /* B: Do something */
> if (runtime_condition()) {
> bar(i, n, A{});
> } else {
> bar(i, n, B{});
> }
> }
> }
>
> void foo(int n) {
> /* A: Do something before the loop */
> if (0 < n) {
> /* B: Do something */
> if (runtime_condition()) {
> bar(1, n, A{});
> } else {
> bar(1, n, B{});
> }
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 2*
>
> It is too complicated! Moreover, as the recursive call of the "function
> template bar" is not able to be optimized, it will possibly increase the
> runtime overhead.
>
> *Size*
>
> Compilers may generate a lot of redundant code when the feature is used
> extensively, e.g.:
>
> auto x0 = runtime_condition_0() ? A0{} : B0{};
> auto x1 = runtime_condition_1() ? A1{} : B1{};
> // ...
> auto xn = runtime_condition_n() ? An{} : Bn{};
> *Code Snippet 3*
>
> As you introduced, the compiler is supposed to generate code for every
> path! For the code above, it requires O(2^n) size for code generation,
> which is NOT acceptable in most cases.
>
> In fact, the challenges above can be solved gracefully with the "proxies"
> and the "wrappers".
>
> As the condition is determined at runtime, the concrete type cannot be
> deduced at compile time. The only reason for us to save the returned value
> is that *they have similar expressions and semantics*. We can simply
> extract the common expressions of the types which are used in the context
> to a "proxy", and save the returned value with a "wrapper", e.g. Code
> Snippet 1 can be reconstructed as is shown below (with better performance
> and smaller size):
>
> /* Declares the common expressions required in the context */
> proxy P {
> void f_0();
> double f_1(int, int);
> };
>
> void foo(int n) {
> /* A: Do something before the loop */
> for (int i = 0; i < n; ++i) {
> /* B: Do something */
> Wrapper<P> x(runtime_condition() ? Wrapper<P>(A{}) : Wrapper<P>(B{}));
> P p = x.get_proxy();
> /* C: Do some other things with p */
> }
> /* D: Do something after the loop */
> }
> *Code Snippet 4*
>
> Mingxin Wang
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2798d4f2-09b1-4030-965d-0bbb36a5549b%40isocpp.org.
------=_Part_2088_776051707.1495375873969
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">The following code should be generated when a loop is invo=
lved. the loop has its own scope. The code duplication is limited to the sc=
ope of the loop.<br>But let's improve it further. Instead of duplicate =
the following code in the enclosing scope, it is sufficient to duplicate th=
e dependend code.<br>Code is dependend=C2=A0 if the result of the ternary o=
peration is involved. So only these parst are duplicated. As an addition, t=
he code is only duplicated,<br>if the condition is known at runtime. If it =
is known at compile time, only one branch is created. Code outside of the l=
oop or the code necessary to<br>implement the loop is NOT duplicated and is=
not part of the branches. For now, I will call this construct "generi=
c ternary operator". Like other generics<br>it introduces code duplica=
tion. It's not a special problem of this construct.<br>It is important,=
that existing code does not break. For cases where the existing conversion=
rules apply, there should be no duplication.<br><br>Exmaple including a lo=
op:<div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(18=
7, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-=
word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</spa=
n><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;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">void</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> doit</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">}</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"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">struct</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"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </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"=
color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> main</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"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> runtime_condition </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D</span><span style=3D"color: #000;" 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">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0=
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">fo=
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: #000;" class=3D"styled-by-prettify"> i </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;" cl=
ass=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> i </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">100</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> i</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: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:=
#008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> runtime_condition </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{}</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"> B</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
x</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/* do som=
ething without x */</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 x</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">/* do something without x */</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"colo=
r: #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><br><br><br><div style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; overflow-wrap: break-word;" class=
=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> A</span><span style=3D"col=
or: #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">void</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </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: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</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: #008;" class=3D"styled-by=
-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> doit</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 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: #00=
0;" 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"> main</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>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
untime_condition </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">true</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">for</span><s=
pan 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"col=
or: #000;" class=3D"styled-by-prettify"> i </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
i </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: #066;" class=3D"styled-by-prettify">100</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> i</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"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">runtime_condition</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> ternary_branch_1</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">else</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">goto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> ternary_branch_2</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>ternary_branch_1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 A __instance1__</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
__instance1__</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">goto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t=
ernary_end_1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>ter=
nary_branch_2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 B __instance2__</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 __instance2__</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>ternary_end_1</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 =C2=A0 =C2=A0 <br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">/* do something without x */</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>ternary_branch_3</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 __instance1__</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> ternary_end_2</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>ternary_branch_4</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0__instance2__</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>ternary_e=
nd_2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">/* do something without x */</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 </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><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" c=
lass=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><br><br><br><br><div style=3D"background-color: rgb(250, =
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wi=
dth: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">A</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">():</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">8</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">],</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<=
br>B</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">():</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=
=A0 rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">8</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">],</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop=
=C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>main</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 p=
ush =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">sub</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
=C2=A0 =C2=A0 rsp</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">16</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 mov =C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">5</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: #066;" class=3D"styled-by-prettify">1</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 DWORD PTR </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">=
4</span><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: #066;" class=3D"styled-by-prettify">0</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">L11</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmp =C2=A0 =C2=A0 DWORD PTR </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">4</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: #066;" class=3D"styled-by-pr=
ettify">99</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jg =C2=A0 =C2=A0 =C2=A0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">L4<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmp=
=C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</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=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=A0 =C2=
=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L13<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =
=C2=A0 rax</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">rbp</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">6</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 call =C2=A0 =C2=A0A</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">L9<br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">L13</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=
=A0 =C2=A0 rax</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">rbp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">7</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0=
=C2=A0 =C2=A0 call =C2=A0 =C2=A0B</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">doit</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">.</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">L9</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 lea =C2=A0 =C2=A0 rax</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">6</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=
=A0 rdi</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0A</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 add =C2=A0 =C2=A0 DWORD PTR </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">4=
</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: #066;" class=3D"styled-by-prettify">1</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =
=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L11<b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">L4</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mo=
v =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</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: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 leave<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret</span></div></code><=
/div><br><br><br><br><br><br><br><br>Am Sonntag, 21. Mai 2017 15:00:03 UTC+=
2 schrieb Mingxin Wang:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><div><font face=3D"georgia, serif">You may as well consider the f=
ollowing situations:<br></font></div><div><font face=3D"georgia, serif"><br=
></font></div><div><div style=3D"font-family:georgia,serif"><b><font size=
=3D"4">Loops</font></b></div><div style=3D"font-family:georgia,serif"><br><=
/div><div style=3D"font-family:georgia,serif">It is difficult for compilers=
to generate code for loops with the feature you proposed, e.g.:</div><div =
style=3D"font-family:georgia,serif"><br></div><div style=3D"font-family:geo=
rgia,serif"><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break=
-word;background-color:rgb(250,250,250)"><code><div><div>void foo(int n) {<=
/div><div>=C2=A0 /* A: Do something before the loop */</div><div>=C2=A0 for=
(int i =3D 0; i < n; ++i) {</div><div>=C2=A0 =C2=A0 /* B: Do something =
*/</div><div>=C2=A0 =C2=A0 auto x =3D runtime_condition() ? A{} : B{};</div=
><div>=C2=A0 =C2=A0 /* C: Do some other things with x */</div><div>=C2=A0 }=
</div><div>=C2=A0 /* D: Do something after the loop */</div><div>}</div></d=
iv></code></div><div style=3D"text-align:center"><b>Code Snippet 1</b></div=
></div><div style=3D"font-family:georgia,serif"><br></div><div style=3D"fon=
t-family:georgia,serif">As far as I am concerned, here is the equivalent of=
the code that the compiler would automatically generate for the code above=
(with your method):<br></div><div style=3D"font-family:georgia,serif"><br>=
</div><div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-=
word;background-color:rgb(250,250,250)"><code><div><font color=3D"#660066">=
<div>template <class T></div><div>void bar(int i, int n, T x) {</div>=
<div>=C2=A0 /* C: Do some other things with x */</div><div>=C2=A0 ++i;</div=
><div>=C2=A0 if (i < n) {</div><div>=C2=A0 =C2=A0 /* B: Do something */<=
/div><div>=C2=A0 =C2=A0 if (runtime_condition()) {</div><div>=C2=A0 =C2=A0 =
=C2=A0 bar(i, n, A{});</div><div>=C2=A0 =C2=A0 } else {</div><div>=C2=A0 =
=C2=A0 =C2=A0 bar(i, n, B{});</div><div>=C2=A0 =C2=A0 }</div><div>=C2=A0 }<=
/div><div>}</div><div><br></div><div>void foo(int n) {</div><div>=C2=A0 /* =
A: Do something before the loop */</div><div>=C2=A0 if (0 < n) {</div><d=
iv>=C2=A0 =C2=A0 /* B: Do something */</div><div>=C2=A0 =C2=A0 if (runtime_=
condition()) {</div><div>=C2=A0 =C2=A0 =C2=A0 bar(1, n, A{});</div><div>=C2=
=A0 =C2=A0 } else {</div><div>=C2=A0 =C2=A0 =C2=A0 bar(1, n, B{});</div><di=
v>=C2=A0 =C2=A0 }</div><div>=C2=A0 }</div><div>=C2=A0 /* D: Do something af=
ter the loop */</div><div>}</div></font></div></code></div><div style=3D"te=
xt-align:center"><font face=3D"georgia, serif"><b>Code Snippet 2</b></font>=
</div><div><font face=3D"georgia, serif"><br></font></div><div><font face=
=3D"georgia, serif">It is too complicated! Moreover, as the recursive call =
of the "function template bar" is not able to be optimized, it wi=
ll possibly increase the runtime overhead.</font></div><div><font face=3D"g=
eorgia, serif"><br></font></div><div><font size=3D"4" face=3D"georgia, seri=
f"><b>Size</b></font></div><div><font face=3D"georgia, serif"><br></font></=
div><div><font face=3D"georgia, serif">Compilers may generate a lot of redu=
ndant code when the feature is used extensively, e.g.:</font></div></div><d=
iv><font face=3D"georgia, serif"><br></font></div><div><font face=3D"georgi=
a, serif"><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-w=
ord;background-color:rgb(250,250,250)"><code><div><div>auto x0 =3D runtime_=
condition_0() ? A0{} : B0{};</div><div>auto x1 =3D runtime_condition_1() ? =
A1{} : B1{};</div><div>// ...</div><div>auto xn =3D runtime_condition_n() ?=
An{} : Bn{};</div></div></code></div><div style=3D"text-align:center"><b>C=
ode Snippet 3</b></div><div><br></div><div>As you introduced, the compiler =
is supposed to generate code for every path! For the code above, it require=
s O(2^n) size for code generation, which is NOT acceptable in most cases.</=
div><div><br></div><div>In fact, the challenges above can be solved gracefu=
lly with the "proxies" and the "wrappers".</div><div><b=
r></div><div>As the condition is determined at runtime, the concrete type c=
annot be deduced at compile time. The only reason for us to save the return=
ed value is that <b>they have similar expressions and semantics</b>. We can=
simply extract the common expressions of the types which are used in the c=
ontext to a "proxy", and save the returned value with a "wra=
pper", e.g. Code Snippet 1 can be reconstructed as is shown below (wit=
h better performance and smaller size):</div></font></div><div><font face=
=3D"georgia, serif"><br></font></div></div><div><div style=3D"border:1px so=
lid rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)=
"><code><div><font color=3D"#660066"><div>/* Declares the common expression=
s required in the context */</div><div>proxy P {</div><div>=C2=A0 void f_0(=
);</div><div>=C2=A0 double f_1(int, int);</div><div>};</div><div><br></div>=
<div>void foo(int n) {</div><div>=C2=A0 /* A: Do something before the loop =
*/</div><div>=C2=A0 for (int i =3D 0; i < n; ++i) {</div><div>=C2=A0 =C2=
=A0 /* B: Do something */</div><div>=C2=A0 =C2=A0 Wrapper<P> x(runtim=
e_condition() ? Wrapper<P>(A{}) : Wrapper<P>(B{}));</div><div>=
=C2=A0 =C2=A0 P p =3D x.get_proxy();</div><div>=C2=A0 =C2=A0 /* C: Do some =
other things with p */</div><div>=C2=A0 }</div><div>=C2=A0 /* D: Do somethi=
ng after the loop */</div><div>}</div></font></div></code></div><div style=
=3D"text-align:center"><font face=3D"georgia, serif"><b>Code Snippet 4</b><=
/font></div></div><div style=3D"text-align:left"><font face=3D"georgia, ser=
if"><br></font></div><div style=3D"text-align:left"><font face=3D"georgia, =
serif">Mingxin Wang</font></div></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2798d4f2-09b1-4030-965d-0bbb36a5549b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2798d4f2-09b1-4030-965d-0bbb36a5549b=
%40isocpp.org</a>.<br />
------=_Part_2088_776051707.1495375873969--
------=_Part_2087_1742423123.1495375873967--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 21 May 2017 07:11:33 -0700 (PDT)
Raw View
------=_Part_2215_1340075161.1495375893454
Content-Type: multipart/alternative;
boundary="----=_Part_2216_420638624.1495375893454"
------=_Part_2216_420638624.1495375893454
Content-Type: text/plain; charset="UTF-8"
On Sunday, May 21, 2017 at 5:03:45 AM UTC-4, ma.ka...@web.de wrote:
>
> I revisited your statement, that this isn't possible, because the type
> would be determined at runtime. I have to disagree, now. It is possible at
> compile time.
>
I question whether the value of such a construct is worth the code
readability issues. You're effectively creating template code within
existing code, arbitrarily. You're making it difficult for a user to track
down the type of an object.
Since `auto` and `decltype` have become standard C++, there has been a move
away from easily being able to determine the type of an object. And in many
cases, it's fine that we don't see the type spelled out, because it's
obvious by inspection what it is. But once you start saying that an
object's type could be expression A or expression B or expression C, etc,
it becomes difficult to follow the logic of our code.
Considering the potential downside in making code easily follow-able, I
would like to see some evidence that people frequently use idioms like:
auto f = [&](auto x) { x.doit(); };
runtime_condition ? f(A{}) : f(B{});
Because if they don't, then the feature's motivation is weak.
Alternatively, I would say that it needs to be a *different* ternary
expression. Even if it's something as simple as `??` rather than `?`, it
would at least clue us in as to exactly *when* a user is going to do
something like that.
It should also be noted that this is coming very close to having full-on
language support for variant types. Which really means pattern matching and
such. Perhaps there's a better feature deeper down here that could handle
this in a different way.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/74822f32-cca8-44c4-bcc2-cc35f22e8d08%40isocpp.org.
------=_Part_2216_420638624.1495375893454
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, May 21, 2017 at 5:03:45 AM UTC-4, ma.ka...@web.=
de wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">I re=
visited your statement, that this isn't possible, because the type woul=
d be determined at runtime. I have to disagree, now.=C2=A0 It is possible a=
t compile time.<br></div></blockquote><div><br>I question whether the value=
of such a construct is worth the code readability issues. You're effec=
tively creating template code within existing code, arbitrarily. You're=
making it difficult for a user to track down the type of an object.<br><br=
>Since `auto` and `decltype` have become standard C++, there has been a mov=
e away from easily being able to determine the type of an object. And in ma=
ny cases, it's fine that we don't see the type spelled out, because=
it's obvious by inspection what it is. But once you start saying that =
an object's type could be expression A or expression B or expression C,=
etc, it becomes difficult to follow the logic of our code.<br><br>Consider=
ing the potential downside in making code easily follow-able, I would like =
to see some evidence that people frequently use idioms like:<br><br><div st=
yle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 18=
7); border-style: solid; border-width: 1px; overflow-wrap: break-word;" cla=
ss=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> f </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</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: #008;" =
class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"co=
lor: #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"sty=
led-by-prettify"><br>runtime_condition </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">?</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> f</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">A</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"> f</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">B</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{});</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span></div></code></div><br>Because if they don't, th=
en the feature's motivation is weak.<br><br>Alternatively, I would say =
that it needs to be a <i>different</i> ternary expression. Even if it's=
something as simple as `??` rather than `?`, it would at least clue us in =
as to exactly <i>when</i> a user is going to do something like that.<br><br=
>It should also be noted that this is coming very close to having full-on l=
anguage support for variant types. Which really means pattern matching and =
such. Perhaps there's a better feature deeper down here that could hand=
le this in a different way.<br></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/74822f32-cca8-44c4-bcc2-cc35f22e8d08%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/74822f32-cca8-44c4-bcc2-cc35f22e8d08=
%40isocpp.org</a>.<br />
------=_Part_2216_420638624.1495375893454--
------=_Part_2215_1340075161.1495375893454--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 21 May 2017 10:08:16 -0700
Raw View
On domingo, 21 de maio de 2017 02:03:45 PDT ma.kalbfuss@web.de wrote:
> The code, following the ternary statement is moved into a generic lambda.
> auto x = runtime_condition ? A{} : B{};
>
> The generic lambda is instantiated two times, for each branch. Depending on
> runtime_condition,
> only one instance is executed. The statement
You do realise this grows exponentially, right?
auto x = runtime_condition ? A{} : B{};
auto y = runtime_condition ? C{} : D{};
auto z = runtime_condition ? E{} : F{};
x.f() + y.f() + z.f();
There are 8 different branches there to make the above work.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/27694795.c6R7qxKFE5%40tjmaciei-mobl1.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 21 May 2017 10:16:59 -0700
Raw View
On domingo, 21 de maio de 2017 10:08:16 PDT Thiago Macieira wrote:
> You do realise this grows exponentially, right?
>
> auto x = runtime_condition ? A{} : B{};
> auto y = runtime_condition ? C{} : D{};
> auto z = runtime_condition ? E{} : F{};
I mean different runtime conditions here.
> x.f() + y.f() + z.f();
>
> There are 8 different branches there to make the above work.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1678895.0nQhqNqFQE%40tjmaciei-mobl1.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 21 May 2017 10:35:10 -0700 (PDT)
Raw View
------=_Part_303_894290855.1495388110516
Content-Type: multipart/alternative;
boundary="----=_Part_304_1952100850.1495388110517"
------=_Part_304_1952100850.1495388110517
Content-Type: text/plain; charset="UTF-8"
On Sunday, May 21, 2017 at 1:08:21 PM UTC-4, Thiago Macieira wrote:
>
> On domingo, 21 de maio de 2017 02:03:45 PDT ma.ka...@web.de <javascript:>
> wrote:
> > The code, following the ternary statement is moved into a generic
> lambda.
> > auto x = runtime_condition ? A{} : B{};
> >
> > The generic lambda is instantiated two times, for each branch. Depending
> on
> > runtime_condition,
> > only one instance is executed. The statement
>
> You do realise this grows exponentially, right?
>
> auto x = runtime_condition ? A{} : B{};
> auto y = runtime_condition ? C{} : D{};
> auto z = runtime_condition ? E{} : F{};
> x.f() + y.f() + z.f();
>
> There are 8 different branches there to make the above work.
>
This is one of the reasons why I think, if we're going to do this, then it
*needs* to be a different operator from ?:. Something where you can clearly
see that you're invoking this implicit template stuff.
And like I said elsewhere, I get the feeling that there is more to this
implicit template instantiation than there first appears. This seems almost
like pattern matching, but done implicitly via template instantiation,
rather than explicitly through some kind of switch statement.
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/734764c8-e502-4635-be76-a76cab6261a1%40isocpp.org.
------=_Part_304_1952100850.1495388110517
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Sunday, May 21, 2017 at 1:08:21 PM UTC-4, Thiago Maciei=
ra wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On domingo, 21 de mai=
o de 2017 02:03:45 PDT <a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"IHx54ZF6AwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:';return true;" onclick=3D"this.href=3D'javascript:&#=
39;;return true;">ma.ka...@web.de</a> wrote:
<br>> The code, following the ternary statement is moved into a generic =
lambda.
<br>> auto x =3D runtime_condition ? A{} : B{};
<br>>=20
<br>> The generic lambda is instantiated two times, for each branch. Dep=
ending on
<br>> runtime_condition,
<br>> only one instance is executed. The statement
<br>
<br>You do realise this grows exponentially, right?
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition ? A{} : B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
ition ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto z =3D runtime_cond=
ition ? E{} : F{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f() + y.f() + z.f();
<br>
<br>There are 8 different branches there to make the above work.
<br></blockquote><div><br>This is one of the reasons why I think, if we'=
;re going to do this, then it <i>needs</i> to be a different operator from =
?:. Something where you can clearly see that you're invoking this impli=
cit template stuff.<br><br>And like I said elsewhere, I get the feeling tha=
t there is more to this implicit template instantiation than there first ap=
pears. This seems almost like pattern matching, but done implicitly via tem=
plate instantiation, rather than explicitly through some kind of switch sta=
tement.<br></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/734764c8-e502-4635-be76-a76cab6261a1%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/734764c8-e502-4635-be76-a76cab6261a1=
%40isocpp.org</a>.<br />
------=_Part_304_1952100850.1495388110517--
------=_Part_303_894290855.1495388110516--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 13:54:51 -0700 (PDT)
Raw View
------=_Part_2482_558607628.1495400092089
Content-Type: multipart/alternative;
boundary="----=_Part_2483_121770391.1495400092089"
------=_Part_2483_121770391.1495400092089
Content-Type: text/plain; charset="UTF-8"
Yeah, i realize that. This is something you have to consider if you're
using templates extensively. This is not the right solution for everything.
I think in most cases, you use one or at most two ternary operators in one
place. For three or more ternary operators the runtime overhead is
assumably the lesser of two evils. But even if it grows exponentially, the
constants are pretty small. Normaly only a few instructions are involved.
Am Sonntag, 21. Mai 2017 19:17:03 UTC+2 schrieb Thiago Macieira:
>
> On domingo, 21 de maio de 2017 10:08:16 PDT Thiago Macieira wrote:
> > You do realise this grows exponentially, right?
> >
> > auto x = runtime_condition ? A{} : B{};
> > auto y = runtime_condition ? C{} : D{};
> > auto z = runtime_condition ? E{} : F{};
>
> I mean different runtime conditions here.
>
> > x.f() + y.f() + z.f();
> >
> > There are 8 different branches there to make the above work.
>
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b75d4532-bb6e-4b66-8f9b-a2a94b679e96%40isocpp.org.
------=_Part_2483_121770391.1495400092089
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yeah, i realize that. This is something you have to consid=
er if you're using templates extensively. This is not the right solutio=
n for everything. I think in most cases, you use one or at most two ternary=
operators in one place. For three or more ternary operators the runtime ov=
erhead is assumably the lesser of two evils. But even if it grows exponenti=
ally, the constants are pretty small. Normaly only a few instructions are i=
nvolved.<br><br>Am Sonntag, 21. Mai 2017 19:17:03 UTC+2 schrieb Thiago Maci=
eira:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;">On domingo, 21 de maio de=
2017 10:08:16 PDT Thiago Macieira wrote:
<br>> You do realise this grows exponentially, right?
<br>>=20
<br>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto x =3D runtime_condition ? A{} : B=
{};
<br>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto y =3D runtime_condition ? C{} : D=
{};
<br>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto z =3D runtime_condition ? E{} : F=
{};
<br>
<br>I mean different runtime conditions here.
<br>
<br>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 x.f() + y.f() + z.f();
<br>>=20
<br>> There are 8 different branches there to make the above work.
<br>
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b75d4532-bb6e-4b66-8f9b-a2a94b679e96%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b75d4532-bb6e-4b66-8f9b-a2a94b679e96=
%40isocpp.org</a>.<br />
------=_Part_2483_121770391.1495400092089--
------=_Part_2482_558607628.1495400092089--
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 14:03:05 -0700 (PDT)
Raw View
------=_Part_2211_1635247880.1495400585179
Content-Type: multipart/alternative;
boundary="----=_Part_2212_1983742866.1495400585180"
------=_Part_2212_1983742866.1495400585180
Content-Type: text/plain; charset="UTF-8"
Mabe you're right. Another operator could be a better choice. But I'm still
unsure about it. Another approach is to use an attribute to disallow
genericity.
auto x = runtime_condition [[non generic]] ? A{} : B{};
or vice versa
auto x = runtime_condition [[generic]] ? A{} : B{};
It would be interesting to know, if there are other places where the same
technique could be applied. Maybe for different return types of function
calls, depeding on the passed arguments. I have to explore that.
Am Sonntag, 21. Mai 2017 19:35:10 UTC+2 schrieb Nicol Bolas:
>
> On Sunday, May 21, 2017 at 1:08:21 PM UTC-4, Thiago Macieira wrote:
>>
>> On domingo, 21 de maio de 2017 02:03:45 PDT ma.ka...@web.de wrote:
>> > The code, following the ternary statement is moved into a generic
>> lambda.
>> > auto x = runtime_condition ? A{} : B{};
>> >
>> > The generic lambda is instantiated two times, for each branch.
>> Depending on
>> > runtime_condition,
>> > only one instance is executed. The statement
>>
>> You do realise this grows exponentially, right?
>>
>> auto x = runtime_condition ? A{} : B{};
>> auto y = runtime_condition ? C{} : D{};
>> auto z = runtime_condition ? E{} : F{};
>> x.f() + y.f() + z.f();
>>
>> There are 8 different branches there to make the above work.
>>
>
> This is one of the reasons why I think, if we're going to do this, then it
> *needs* to be a different operator from ?:. Something where you can
> clearly see that you're invoking this implicit template stuff.
>
> And like I said elsewhere, I get the feeling that there is more to this
> implicit template instantiation than there first appears. This seems almost
> like pattern matching, but done implicitly via template instantiation,
> rather than explicitly through some kind of switch statement.
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d23a44b3-3286-4e0b-b48e-c72b77f465a3%40isocpp.org.
------=_Part_2212_1983742866.1495400585180
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Mabe you're right. Another operator could be a better =
choice. But I'm still unsure about it. Another approach is to use an at=
tribute to disallow genericity.<br><br><br><div style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> runtime_condition </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">[[</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">non generic</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: #660;" class=3D"styled-by-prettify=
">?</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> A</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: #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></div></code></div><br>or vice versa<br=
><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(=
187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: brea=
k-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> runtime_condition </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[[</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">generic</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"> A</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{}</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </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></div></=
code></div><br><br><br>It would be interesting to know, if there are other =
places where the same technique could be applied. Maybe for different retur=
n types of function calls, depeding on the passed arguments. I have to expl=
ore that.<br><br>Am Sonntag, 21. Mai 2017 19:35:10 UTC+2 schrieb Nicol Bola=
s:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Sunday, =
May 21, 2017 at 1:08:21 PM UTC-4, Thiago Macieira wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex">On domingo, 21 de maio de 2017 02:03:45 PDT <a rel=
=3D"nofollow">ma.ka...@web.de</a> wrote:
<br>> The code, following the ternary statement is moved into a generic =
lambda.
<br>> auto x =3D runtime_condition ? A{} : B{};
<br>>=20
<br>> The generic lambda is instantiated two times, for each branch. Dep=
ending on
<br>> runtime_condition,
<br>> only one instance is executed. The statement
<br>
<br>You do realise this grows exponentially, right?
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition ? A{} : B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
ition ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto z =3D runtime_cond=
ition ? E{} : F{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f() + y.f() + z.f();
<br>
<br>There are 8 different branches there to make the above work.
<br></blockquote><div><br>This is one of the reasons why I think, if we'=
;re going to do this, then it <i>needs</i> to be a different operator from =
?:. Something where you can clearly see that you're invoking this impli=
cit template stuff.<br><br>And like I said elsewhere, I get the feeling tha=
t there is more to this implicit template instantiation than there first ap=
pears. This seems almost like pattern matching, but done implicitly via tem=
plate instantiation, rather than explicitly through some kind of switch sta=
tement.<br></div></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d23a44b3-3286-4e0b-b48e-c72b77f465a3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d23a44b3-3286-4e0b-b48e-c72b77f465a3=
%40isocpp.org</a>.<br />
------=_Part_2212_1983742866.1495400585180--
------=_Part_2211_1635247880.1495400585179--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Sun, 21 May 2017 17:12:16 -0700
Raw View
On domingo, 21 de maio de 2017 13:54:51 PDT ma.kalbfuss@web.de wrote:
> Yeah, i realize that. This is something you have to consider if you're
> using templates extensively.
No, it isn't. Today, the use of templates does not imply exponential growth of
generated code.
That is something completely new with your proposal.
> This is not the right solution for everything.
> I think in most cases, you use one or at most two ternary operators in one
> place. For three or more ternary operators the runtime overhead is
> assumably the lesser of two evils. But even if it grows exponentially, the
> constants are pretty small. Normaly only a few instructions are involved.
Not necessarily. Remember that you may not reevaluate the condition, so either
this generates completely separate code paths (and thus the exponential
expansion) or the result of the evaluation is stored in a hidden variable that
is evaluated every time you access that automatic variable.
That is, when you write:
auto x = runtime_condition1 ? A{} : B{};
auto y = runtime_conditoin2 ? C{} : D{};
x.f();
This expands to either:
if (runtime_condition1) {
auto x = A{};
if (runtime_condition2) {
auto y = C {};
x.f() + y.f();
} else {
auto y = D {};
x.f() + y.f();
}
} else {
auto x = B{};
if (runtime_condition2) {
auto y = C {};
x.f() + y.f();
} else {
auto y = D {};
x.f() + y.f();
}
}
or to:
variant<A, B> x;
variant<C, D> y;
bool hidden1 = runtime_condition1;
if (hidden1)
x.create<A>();
else
x.create<B>();
bool hidden2 = runtime_condition2;
if (hidden2)
y.create<C>();
else
y.create<D>();
if (hidden1) {
if (hidden2)
x.as<A>().f() + y.as<C>().f();
else
x.as<A>().f() + y.as<D>().f();
} else {
if (hidden2)
x.as<B>().f() + y.as<C>().f();
else
x.as<B>().f() + y.as<D>().f();
}
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1620864.HL4j5jKv18%40tjmaciei-mobl1.
.
Author: ma.kalbfuss@web.de
Date: Sun, 21 May 2017 23:33:32 -0700 (PDT)
Raw View
------=_Part_2490_786802544.1495434812839
Content-Type: multipart/alternative;
boundary="----=_Part_2491_1041723913.1495434812839"
------=_Part_2491_1041723913.1495434812839
Content-Type: text/plain; charset="UTF-8"
Sure, you don't have always exponential growth when using templates. But if
you simulating this case with template functions you end up having the same
problem.
So I wouldn't say, that this something completely new. It is the nature of
the problem we try to solve. You have either runtime overhad or exponential
growth.
Maybe there is a way to avoid exponential growth using optimization
techniques. Assumably in many cases the optimizer will reduce the amount of
code anyway.
There could be a guaranteed optimization. But I'm not sure which. I will
build up an example, where the code isn't completely optimized away.
I assume variant is an untagged union? Let's try to minimise our examples.
Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:
>
> On domingo, 21 de maio de 2017 13:54:51 PDT ma.ka...@web.de <javascript:>
> wrote:
> > Yeah, i realize that. This is something you have to consider if you're
> > using templates extensively.
>
> No, it isn't. Today, the use of templates does not imply exponential
> growth of
> generated code.
>
> That is something completely new with your proposal.
>
> > This is not the right solution for everything.
> > I think in most cases, you use one or at most two ternary operators in
> one
> > place. For three or more ternary operators the runtime overhead is
> > assumably the lesser of two evils. But even if it grows exponentially,
> the
> > constants are pretty small. Normaly only a few instructions are
> involved.
>
> Not necessarily. Remember that you may not reevaluate the condition, so
> either
> this generates completely separate code paths (and thus the exponential
> expansion) or the result of the evaluation is stored in a hidden variable
> that
> is evaluated every time you access that automatic variable.
>
> That is, when you write:
>
> auto x = runtime_condition1 ? A{} : B{};
> auto y = runtime_conditoin2 ? C{} : D{};
> x.f();
>
> This expands to either:
>
> if (runtime_condition1) {
> auto x = A{};
> if (runtime_condition2) {
> auto y = C {};
> x.f() + y.f();
> } else {
> auto y = D {};
> x.f() + y.f();
> }
> } else {
> auto x = B{};
> if (runtime_condition2) {
> auto y = C {};
> x.f() + y.f();
> } else {
> auto y = D {};
> x.f() + y.f();
> }
> }
>
> or to:
>
> variant<A, B> x;
> variant<C, D> y;
> bool hidden1 = runtime_condition1;
> if (hidden1)
> x.create<A>();
> else
> x.create<B>();
> bool hidden2 = runtime_condition2;
> if (hidden2)
> y.create<C>();
> else
> y.create<D>();
> if (hidden1) {
> if (hidden2)
> x.as<A>().f() + y.as<C>().f();
> else
> x.as<A>().f() + y.as<D>().f();
> } else {
> if (hidden2)
> x.as<B>().f() + y.as<C>().f();
> else
> x.as<B>().f() + y.as<D>().f();
> }
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d14bfe0d-8c72-49a0-bf08-8041998dd125%40isocpp.org.
------=_Part_2491_1041723913.1495434812839
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Sure, you don't have always exponential growth when us=
ing templates. But if you simulating this case with template functions you =
end up having the same problem.<br>So I wouldn't say, that this somethi=
ng completely new. It is the nature of the problem we try to solve. You hav=
e either runtime overhad or exponential growth.<br>Maybe there is a way to =
avoid exponential growth using optimization techniques. Assumably in many c=
ases the optimizer will reduce the amount of code anyway.<br>There could be=
a guaranteed optimization. But I'm not sure which. I will build up an =
example, where the code isn't completely optimized away.<br><br>I assum=
e variant is an untagged union? Let's try to minimise our examples.<br>=
<br><br>Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;">On domingo, 21 de maio de 2017 13:=
54:51 PDT <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"u-14zLSRAwAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascri=
pt:';return true;" onclick=3D"this.href=3D'javascript:';return =
true;">ma.ka...@web.de</a> wrote:
<br>> Yeah, i realize that. This is something you have to consider if yo=
u're
<br>> using templates extensively.=20
<br>
<br>No, it isn't. Today, the use of templates does not imply exponentia=
l growth of=20
<br>generated code.
<br>
<br>That is something completely new with your proposal.
<br>
<br>> This is not the right solution for everything.
<br>> I think in most cases, you use one or at most two ternary operator=
s in one
<br>> place. For three or more ternary operators the runtime overhead is
<br>> assumably the lesser of two evils. But even if it grows exponentia=
lly, the
<br>> constants are pretty small. Normaly only a few instructions are in=
volved.
<br>
<br>Not necessarily. Remember that you may not reevaluate the condition, so=
either=20
<br>this generates completely separate code paths (and thus the exponential=
=20
<br>expansion) or the result of the evaluation is stored in a hidden variab=
le that=20
<br>is evaluated every time you access that automatic variable.=20
<br>
<br>That is, when you write:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition1 ? A{} : B{};=20
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
itoin2 ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f();
<br>
<br>This expands to either:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition1)=
{
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D A{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>or to:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<A, B> x;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<C, D> y;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden1 =3D runtim=
e_condition1;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<A>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<B>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden2 =3D runtim=
e_condition2;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<C>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<D>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d14bfe0d-8c72-49a0-bf08-8041998dd125%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d14bfe0d-8c72-49a0-bf08-8041998dd125=
%40isocpp.org</a>.<br />
------=_Part_2491_1041723913.1495434812839--
------=_Part_2490_786802544.1495434812839--
.
Author: ma.kalbfuss@web.de
Date: Mon, 22 May 2017 00:03:17 -0700 (PDT)
Raw View
------=_Part_872_2104818417.1495436598016
Content-Type: multipart/alternative;
boundary="----=_Part_873_1716291772.1495436598017"
------=_Part_873_1716291772.1495436598017
Content-Type: text/plain; charset="UTF-8"
I've created a new example for looking at the optimizations.
struct W{ int doit(){ return 1; } };
struct X{ int doit(){ return 2; } };
struct Y{ int doit(){ return 3; } };
struct Z{ int doit(){ return 4; } };
int example(bool runtime_condition1, bool runtime_condition2) {
int result;
if(!runtime_condition1)
goto ternary_branch_1;
if(!runtime_condition2)
goto ternary_branch_2;
result = W{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_1:
if(!runtime_condition2);
goto ternary_branch_3;
result = X{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_2:
result = W{}.doit() + Z{}.doit();
goto ternary_end;
ternary_branch_3:
result = X{}.doit() + Z{}.doit();
ternary_end:
return result;
}
result with -O0
A::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
B::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
nop
pop rbp
ret
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov BYTE PTR [rbp-5], 1
mov DWORD PTR [rbp-4], 0
..L11:
cmp DWORD PTR [rbp-4], 99
jg .L4
cmp BYTE PTR [rbp-5], 0
je .L13
nop
lea rax, [rbp-6]
mov rdi, rax
call A::doit()
jmp .L9
..L13:
nop
lea rax, [rbp-7]
mov rdi, rax
call B::doit()
..L9:
lea rax, [rbp-6]
mov rdi, rax
call A::doit()
nop
add DWORD PTR [rbp-4], 1
jmp .L11
..L4:
mov eax, 0
leave
ret
result with -O1
example(bool, bool):
mov eax, 6
test dil, dil
je .L1
test sil, sil
sete al
movzx eax, al
add eax, 4
..L1:
rep ret
result with -O2 and higher
example(bool, bool):
test dil, dil
mov eax, 6
je .L1
xor eax, eax
test sil, sil
sete al
add eax, 4
..L1:
rep ret
Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:
>
> On domingo, 21 de maio de 2017 13:54:51 PDT ma.ka...@web.de <javascript:>
> wrote:
> > Yeah, i realize that. This is something you have to consider if you're
> > using templates extensively.
>
> No, it isn't. Today, the use of templates does not imply exponential
> growth of
> generated code.
>
> That is something completely new with your proposal.
>
> > This is not the right solution for everything.
> > I think in most cases, you use one or at most two ternary operators in
> one
> > place. For three or more ternary operators the runtime overhead is
> > assumably the lesser of two evils. But even if it grows exponentially,
> the
> > constants are pretty small. Normaly only a few instructions are
> involved.
>
> Not necessarily. Remember that you may not reevaluate the condition, so
> either
> this generates completely separate code paths (and thus the exponential
> expansion) or the result of the evaluation is stored in a hidden variable
> that
> is evaluated every time you access that automatic variable.
>
> That is, when you write:
>
> auto x = runtime_condition1 ? A{} : B{};
> auto y = runtime_conditoin2 ? C{} : D{};
> x.f();
>
> This expands to either:
>
> if (runtime_condition1) {
> auto x = A{};
> if (runtime_condition2) {
> auto y = C {};
> x.f() + y.f();
> } else {
> auto y = D {};
> x.f() + y.f();
> }
> } else {
> auto x = B{};
> if (runtime_condition2) {
> auto y = C {};
> x.f() + y.f();
> } else {
> auto y = D {};
> x.f() + y.f();
> }
> }
>
> or to:
>
> variant<A, B> x;
> variant<C, D> y;
> bool hidden1 = runtime_condition1;
> if (hidden1)
> x.create<A>();
> else
> x.create<B>();
> bool hidden2 = runtime_condition2;
> if (hidden2)
> y.create<C>();
> else
> y.create<D>();
> if (hidden1) {
> if (hidden2)
> x.as<A>().f() + y.as<C>().f();
> else
> x.as<A>().f() + y.as<D>().f();
> } else {
> if (hidden2)
> x.as<B>().f() + y.as<C>().f();
> else
> x.as<B>().f() + y.as<D>().f();
> }
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6774d9c5-4f38-474e-a0e9-955d55cd49ab%40isocpp.org.
------=_Part_873_1716291772.1495436598017
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I've created a new example for looking at the optimiza=
tions.<br><br><div style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-w=
rap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> W</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: #008;" class=3D"styled-by-prettify">int</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> doit</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">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">1</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 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: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">in=
t</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> doit</sp=
an><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: #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">2</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"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> Y</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">int</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(){</span><span style=3D"color: #000;" 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><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">3</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: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">str=
uct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Z</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> doit</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: #008;" class=3D"style=
d-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=
">4</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"><br><br><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> example</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> runtime_condition1</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: #008;" class=3D"styled-by-prettify">bool</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> runtime_cond=
ition2</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>=C2=A0 =C2=A0 </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> result</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">runtime_condition1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> ternary_branch_1</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">runtime_condition2</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_branch_2=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=
=A0 result </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> W</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">doit</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: #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"styl=
ed-by-prettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">goto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> t=
ernary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 <br>ternary_branch_1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">runtime_condition2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">goto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ternary_branch_3</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{}.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> ternary_end</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br><br>ternary_branch_2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> W</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{}.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doit</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-b=
y-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> Z</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_end</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ternary_branch_3</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 r=
esult </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</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: #000;" class=3D"sty=
led-by-prettify"> Z</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ter=
nary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> result=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><br>result with -O0<br><br><div style=3D"background-color: rgb(250, 250, =
250); border-color: rgb(187, 187, 187); border-style: solid; border-width: =
1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D=
"styled-by-prettify">A</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">8</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">],</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>B=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">():</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">8</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">],</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rdi<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0=
=C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>main</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=
=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">su=
b</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =
=C2=A0 rsp</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: #066;" class=3D"styled-by-prettify">16</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">5=
</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: #066;" class=3D"styled-by-prettify">1</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 DWORD PTR </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">4</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=
: #066;" class=3D"styled-by-prettify">0</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"style=
d-by-prettify">L11</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmp =C2=A0 =C2=A0 DWORD PTR </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">4</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">99=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
=C2=A0 =C2=A0 =C2=A0 jg =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">L4<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cmp =C2=A0 =C2=
=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rbp</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span=
style=3D"color: #066;" class=3D"styled-by-prettify">5</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: #066;" cl=
ass=3D"styled-by-prettify">0</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=A0 =C2=A0 =C2=A0</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">L13<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">6</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =
=C2=A0 =C2=A0A</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">L9<br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">L13</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax<=
/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"color=
: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">7</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
call =C2=A0 =C2=A0B</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">doit</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 styl=
e=3D"color: #000;" class=3D"styled-by-prettify">L9</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =
=C2=A0 rax</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">rbp</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">6</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 call =C2=A0 =C2=A0A</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0=
=C2=A0 DWORD PTR </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">r=
bp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">4</span><span sty=
le=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: #066=
;" class=3D"styled-by-prettify">1</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">L11<br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">L4</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0=
eax</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: #066;" class=3D"styled-by-prettify">0</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 l=
eave<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br></span></div></code></div><br>re=
sult with -O1<br><br><div style=3D"background-color: rgb(250, 250, 250); bo=
rder-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ove=
rflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-=
by-prettify">example</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: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">):</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">6</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 test =C2=A0 =C2=A0dil</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> dil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=A0 =C2=A0 =C2=A0=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">L1<br>=C2=A0 =C2=A0=
=C2=A0 =C2=A0 test =C2=A0 =C2=A0sil</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> sil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sete =C2=A0 =C2=A0al<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =
=C2=A0 eax</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: #066;" class=3D"styled-by-prettify">4</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><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">L1</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 rep ret<br></span></div></c=
ode></div><br>result with -O2 and higher<br><br><div style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><=
code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">example</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">bool</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: #008;" class=3D"styled-by-pret=
tify">bool</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
):</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0dil</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> dil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =
=C2=A0 eax</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: #066;" class=3D"styled-by-prettify">6</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 je =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">L1<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 xor =C2=A0 =C2=A0 eax</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 test =C2=A0 =C2=A0sil</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> sil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sete =C2=A0 =C2=A0al<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</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: #066;" class=3D"st=
yled-by-prettify">4</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L1</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 rep ret</span></div></code></div><br><br><br>Am Montag, 22. Mai =
2017 02:12:20 UTC+2 schrieb Thiago Macieira:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;">On domingo, 21 de maio de 2017 13:54:51 PDT <a href=3D"javasc=
ript:" target=3D"_blank" gdf-obfuscated-mailto=3D"u-14zLSRAwAJ" rel=3D"nofo=
llow" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">ma.ka...@web.de</a> wr=
ote:
<br>> Yeah, i realize that. This is something you have to consider if yo=
u're
<br>> using templates extensively.=20
<br>
<br>No, it isn't. Today, the use of templates does not imply exponentia=
l growth of=20
<br>generated code.
<br>
<br>That is something completely new with your proposal.
<br>
<br>> This is not the right solution for everything.
<br>> I think in most cases, you use one or at most two ternary operator=
s in one
<br>> place. For three or more ternary operators the runtime overhead is
<br>> assumably the lesser of two evils. But even if it grows exponentia=
lly, the
<br>> constants are pretty small. Normaly only a few instructions are in=
volved.
<br>
<br>Not necessarily. Remember that you may not reevaluate the condition, so=
either=20
<br>this generates completely separate code paths (and thus the exponential=
=20
<br>expansion) or the result of the evaluation is stored in a hidden variab=
le that=20
<br>is evaluated every time you access that automatic variable.=20
<br>
<br>That is, when you write:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition1 ? A{} : B{};=20
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
itoin2 ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f();
<br>
<br>This expands to either:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition1)=
{
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D A{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>or to:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<A, B> x;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<C, D> y;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden1 =3D runtim=
e_condition1;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<A>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<B>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden2 =3D runtim=
e_condition2;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<C>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<D>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return t=
rue;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH=
GRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'=
http://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a=
>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6774d9c5-4f38-474e-a0e9-955d55cd49ab%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6774d9c5-4f38-474e-a0e9-955d55cd49ab=
%40isocpp.org</a>.<br />
------=_Part_873_1716291772.1495436598017--
------=_Part_872_2104818417.1495436598016--
.
Author: ma.kalbfuss@web.de
Date: Mon, 22 May 2017 00:13:40 -0700 (PDT)
Raw View
------=_Part_2507_1148003169.1495437220471
Content-Type: multipart/alternative;
boundary="----=_Part_2508_366975323.1495437220473"
------=_Part_2508_366975323.1495437220473
Content-Type: text/plain; charset="UTF-8"
struct W{ int doit(){ return 1; } };
struct X{ int doit(){ return 2; } };
struct Y{ int doit(){ return 3; } };
struct Z{ int doit(){ return 4; } };
int example(bool runtime_condition1, bool runtime_condition2) {
int result;
if(!runtime_condition1)
goto ternary_branch_1;
if(!runtime_condition2)
goto ternary_branch_2;
result = W{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_1:
if(!runtime_condition2);
goto ternary_branch_3;
result = X{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_2:
result = W{}.doit() + Z{}.doit();
goto ternary_end;
ternary_branch_3:
result = X{}.doit() + Z{}.doit();
ternary_end:
return result;
}
With -O0
W::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 1
pop rbp
ret
X::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 2
pop rbp
ret
Y::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 3
pop rbp
ret
Z::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 4
pop rbp
ret
example(bool, bool):
push rbp
mov rbp, rsp
push rbx
sub rsp, 40
mov edx, edi
mov eax, esi
mov BYTE PTR [rbp-36], dl
mov BYTE PTR [rbp-40], al
movzx eax, BYTE PTR [rbp-36]
xor eax, 1
test al, al
jne .L19
movzx eax, BYTE PTR [rbp-40]
xor eax, 1
test al, al
jne .L20
lea rax, [rbp-28]
mov rdi, rax
call W::doit()
mov ebx, eax
lea rax, [rbp-27]
mov rdi, rax
call Y::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
jmp .L14
..L19:
nop
nop
lea rax, [rbp-22]
mov rdi, rax
call X::doit()
mov ebx, eax
lea rax, [rbp-21]
mov rdi, rax
call Z::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
jmp .L14
..L20:
nop
lea rax, [rbp-24]
mov rdi, rax
call W::doit()
mov ebx, eax
lea rax, [rbp-23]
mov rdi, rax
call Z::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
nop
..L14:
mov eax, DWORD PTR [rbp-20]
add rsp, 40
pop rbx
pop rbp
ret
With -O3
example(bool, bool):
test dil, dil
mov eax, 6
je .L1
xor eax, eax
test sil, sil
sete al
add eax, 4
..L1:
rep ret
Am Montag, 22. Mai 2017 08:33:33 UTC+2 schrieb ma.ka...@web.de:
>
> Sure, you don't have always exponential growth when using templates. But
> if you simulating this case with template functions you end up having the
> same problem.
> So I wouldn't say, that this something completely new. It is the nature of
> the problem we try to solve. You have either runtime overhad or exponential
> growth.
> Maybe there is a way to avoid exponential growth using optimization
> techniques. Assumably in many cases the optimizer will reduce the amount of
> code anyway.
> There could be a guaranteed optimization. But I'm not sure which. I will
> build up an example, where the code isn't completely optimized away.
>
> I assume variant is an untagged union? Let's try to minimise our examples.
>
>
> Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:
>>
>> On domingo, 21 de maio de 2017 13:54:51 PDT ma.ka...@web.de wrote:
>> > Yeah, i realize that. This is something you have to consider if you're
>> > using templates extensively.
>>
>> No, it isn't. Today, the use of templates does not imply exponential
>> growth of
>> generated code.
>>
>> That is something completely new with your proposal.
>>
>> > This is not the right solution for everything.
>> > I think in most cases, you use one or at most two ternary operators in
>> one
>> > place. For three or more ternary operators the runtime overhead is
>> > assumably the lesser of two evils. But even if it grows exponentially,
>> the
>> > constants are pretty small. Normaly only a few instructions are
>> involved.
>>
>> Not necessarily. Remember that you may not reevaluate the condition, so
>> either
>> this generates completely separate code paths (and thus the exponential
>> expansion) or the result of the evaluation is stored in a hidden variable
>> that
>> is evaluated every time you access that automatic variable.
>>
>> That is, when you write:
>>
>> auto x = runtime_condition1 ? A{} : B{};
>> auto y = runtime_conditoin2 ? C{} : D{};
>> x.f();
>>
>> This expands to either:
>>
>> if (runtime_condition1) {
>> auto x = A{};
>> if (runtime_condition2) {
>> auto y = C {};
>> x.f() + y.f();
>> } else {
>> auto y = D {};
>> x.f() + y.f();
>> }
>> } else {
>> auto x = B{};
>> if (runtime_condition2) {
>> auto y = C {};
>> x.f() + y.f();
>> } else {
>> auto y = D {};
>> x.f() + y.f();
>> }
>> }
>>
>> or to:
>>
>> variant<A, B> x;
>> variant<C, D> y;
>> bool hidden1 = runtime_condition1;
>> if (hidden1)
>> x.create<A>();
>> else
>> x.create<B>();
>> bool hidden2 = runtime_condition2;
>> if (hidden2)
>> y.create<C>();
>> else
>> y.create<D>();
>> if (hidden1) {
>> if (hidden2)
>> x.as<A>().f() + y.as<C>().f();
>> else
>> x.as<A>().f() + y.as<D>().f();
>> } else {
>> if (hidden2)
>> x.as<B>().f() + y.as<C>().f();
>> else
>> x.as<B>().f() + y.as<D>().f();
>> }
>>
>> --
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>> Software Architect - Intel Open Source Technology Center
>>
>>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/50267964-19d0-4bb2-ba27-f018b58b8aa8%40isocpp.org.
------=_Part_2508_366975323.1495437220473
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflo=
w-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div=
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> W</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: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> doit</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: #008;" cla=
ss=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">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><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: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">struct</span><span 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"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> doi=
t</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: #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">2</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">};</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> Y</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">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retu=
rn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">3</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"> </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: #008;" class=3D"styled-by-prettify"=
>struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Z<=
/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: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> doit</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: #008;" class=3D"s=
tyled-by-prettify">return</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">4</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: #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><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> example</span><span style=3D"color: #660;" 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"> runtime_condition1</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: #008;" class=3D"styled-by-prettify">=
bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> runti=
me_condition2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> result</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">runtime_condition1</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> ternary_branch_1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">runtime_condition2</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">goto</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_bra=
nch_2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0=
=C2=A0 result </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> W=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">doit</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;" cla=
ss=3D"styled-by-prettify"> Y</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">goto</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
ternary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 <br>ternary_branch_1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">runtime_condition2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">goto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ternary_branch_3</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{}.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> ternary_end</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br><br>ternary_branch_2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> W</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{}.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doit</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-b=
y-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> Z</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_end</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ternary_branch_3</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 r=
esult </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</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: #000;" class=3D"sty=
led-by-prettify"> Z</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ter=
nary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> result=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><br><br><br>With -O0<br><div style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">W</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">():</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 m=
ov =C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;=
" class=3D"styled-by-prettify">8</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">],</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</=
span><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: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =
=C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>X</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">():</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=
=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
mov =C2=A0 =C2=A0 QWORD PTR </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">8</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-pre=
ttify">2</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 ret<br>Y</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">do=
it</span><span style=3D"color: #660;" class=3D"styled-by-prettify">():</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
sp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">8</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">3</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =
=C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>Z</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">():</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 QWORD PTR </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">8</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-prettify">=
4</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 ret<br>example</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">b=
ool</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: #008;" class=3D"styled-by-prettify">bool</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">):</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =
=C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 push =C2=A0 =C2=A0rbx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">sub</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 rsp</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=
: #066;" class=3D"styled-by-prettify">40</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =
=C2=A0 edx</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> edi<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> esi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">36</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> dl<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 mov =C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">40</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">],</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0=
=C2=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">36</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 xor =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0al</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jne =C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">L19<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> BYTE PTR </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">40</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 xor =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-prettify"=
>1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0al</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jne =C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">L20<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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"style=
d-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">28</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0W</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0=
=C2=A0 ebx</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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: #660;" class=3D=
"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">27</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0Y</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =
=C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e=
bx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 DWORD PTR </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">L14<br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">L19</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">22</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =
=C2=A0 =C2=A0X</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 mov =C2=A0 =C2=A0 ebx</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</=
span><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: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">21</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">]</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 call =C2=A0 =C2=A0Z</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> ebx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =
=C2=A0 DWORD PTR </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rb=
p</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">20</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 jmp =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">L14<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L20</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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;" cla=
ss=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">24</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =
=C2=A0W</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 ebx</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</span><s=
pan 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">rbp</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">23</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">]</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =
=C2=A0 =C2=A0Z</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> ebx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 DWORD=
PTR </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">20</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">],</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">L14</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> D=
WORD PTR </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">rbp</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span sty=
le=3D"color: #066;" class=3D"styled-by-prettify">20</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =
=C2=A0 rsp</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: #066;" class=3D"styled-by-prettify">40</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 pop =C2=A0 =C2=A0 rbx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=
=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret</span></div></code></div><br>Wit=
h -O3<br><br><div style=3D"background-color: rgb(250, 250, 250); border-col=
or: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflow-wr=
ap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">example</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</s=
pan><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: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">):</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =
=C2=A0dil</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> dil<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=3D=
"styled-by-prettify">6</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=A0 =C2=A0 =C2=A0</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">L1<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 xor =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0sil</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> sil<br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 sete =C2=A0 =C2=A0al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=
=A0 eax</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: #066;" class=3D"styled-by-prettify">4</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">L1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 rep ret</span></div></code><=
/div><br><br><br><br><br>Am Montag, 22. Mai 2017 08:33:33 UTC+2 schrieb ma.=
ka...@web.de:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
Sure, you don't have always exponential growth when using templates. Bu=
t if you simulating this case with template functions you end up having the=
same problem.<br>So I wouldn't say, that this something completely new=
.. It is the nature of the problem we try to solve. You have either runtime =
overhad or exponential growth.<br>Maybe there is a way to avoid exponential=
growth using optimization techniques. Assumably in many cases the optimize=
r will reduce the amount of code anyway.<br>There could be a guaranteed opt=
imization. But I'm not sure which. I will build up an example, where th=
e code isn't completely optimized away.<br><br>I assume variant is an u=
ntagged union? Let's try to minimise our examples.<br><br><br>Am Montag=
, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:<blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex">On domingo, 21 de maio de 2017 13:54:51 PDT <a rel=3D"no=
follow">ma.ka...@web.de</a> wrote:
<br>> Yeah, i realize that. This is something you have to consider if yo=
u're
<br>> using templates extensively.=20
<br>
<br>No, it isn't. Today, the use of templates does not imply exponentia=
l growth of=20
<br>generated code.
<br>
<br>That is something completely new with your proposal.
<br>
<br>> This is not the right solution for everything.
<br>> I think in most cases, you use one or at most two ternary operator=
s in one
<br>> place. For three or more ternary operators the runtime overhead is
<br>> assumably the lesser of two evils. But even if it grows exponentia=
lly, the
<br>> constants are pretty small. Normaly only a few instructions are in=
volved.
<br>
<br>Not necessarily. Remember that you may not reevaluate the condition, so=
either=20
<br>this generates completely separate code paths (and thus the exponential=
=20
<br>expansion) or the result of the evaluation is stored in a hidden variab=
le that=20
<br>is evaluated every time you access that automatic variable.=20
<br>
<br>That is, when you write:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition1 ? A{} : B{};=20
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
itoin2 ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f();
<br>
<br>This expands to either:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition1)=
{
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D A{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>or to:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<A, B> x;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<C, D> y;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden1 =3D runtim=
e_condition1;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<A>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<B>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden2 =3D runtim=
e_condition2;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<C>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<D>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.googl=
e.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3=
dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return tru=
e;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofol=
low" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.co=
m/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGR=
Jdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/50267964-19d0-4bb2-ba27-f018b58b8aa8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/50267964-19d0-4bb2-ba27-f018b58b8aa8=
%40isocpp.org</a>.<br />
------=_Part_2508_366975323.1495437220473--
------=_Part_2507_1148003169.1495437220471--
.
Author: ma.kalbfuss@web.de
Date: Mon, 22 May 2017 00:19:35 -0700 (PDT)
Raw View
------=_Part_2422_1294656618.1495437575818
Content-Type: multipart/alternative;
boundary="----=_Part_2423_1574741073.1495437575821"
------=_Part_2423_1574741073.1495437575821
Content-Type: text/plain; charset="UTF-8"
struct W{ int doit(){ return 1; } };
struct X{ int doit(){ return 2; } };
struct Y{ int doit(){ return 3; } };
struct Z{ int doit(){ return 4; } };
int example(bool runtime_condition1, bool runtime_condition2) {
int result;
if(!runtime_condition1)
goto ternary_branch_1;
if(!runtime_condition2)
goto ternary_branch_2;
result = W{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_1:
if(!runtime_condition2)
goto ternary_branch_3;
result = X{}.doit() + Y{}.doit();
goto ternary_end;
ternary_branch_2:
result = W{}.doit() + Z{}.doit();
goto ternary_end;
ternary_branch_3:
result = X{}.doit() + Z{}.doit();
ternary_end:
return result;
}
with -O0:
W::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 1
pop rbp
ret
X::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 2
pop rbp
ret
Y::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 3
pop rbp
ret
Z::doit():
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov eax, 4
pop rbp
ret
example(bool, bool):
push rbp
mov rbp, rsp
push rbx
sub rsp, 40
mov edx, edi
mov eax, esi
mov BYTE PTR [rbp-36], dl
mov BYTE PTR [rbp-40], al
movzx eax, BYTE PTR [rbp-36]
xor eax, 1
test al, al
jne .L21
movzx eax, BYTE PTR [rbp-40]
xor eax, 1
test al, al
jne .L22
lea rax, [rbp-28]
mov rdi, rax
call W::doit()
mov ebx, eax
lea rax, [rbp-27]
mov rdi, rax
call Y::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
jmp .L14
..L21:
nop
movzx eax, BYTE PTR [rbp-40]
xor eax, 1
test al, al
jne .L23
lea rax, [rbp-26]
mov rdi, rax
call X::doit()
mov ebx, eax
lea rax, [rbp-25]
mov rdi, rax
call Y::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
jmp .L14
..L22:
nop
lea rax, [rbp-24]
mov rdi, rax
call W::doit()
mov ebx, eax
lea rax, [rbp-23]
mov rdi, rax
call Z::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
jmp .L14
..L23:
nop
lea rax, [rbp-22]
mov rdi, rax
call X::doit()
mov ebx, eax
lea rax, [rbp-21]
mov rdi, rax
call Z::doit()
add eax, ebx
mov DWORD PTR [rbp-20], eax
..L14:
mov eax, DWORD PTR [rbp-20]
add rsp, 40
pop rbx
pop rbp
ret
with -O3:
example(bool, bool):
xor eax, eax
test sil, sil
sete al
test dil, dil
je .L2
add eax, 4
ret
..L2:
add eax, 5
ret
Am Montag, 22. Mai 2017 08:33:33 UTC+2 schrieb ma.ka...@web.de:
>
> Sure, you don't have always exponential growth when using templates. But
> if you simulating this case with template functions you end up having the
> same problem.
> So I wouldn't say, that this something completely new. It is the nature of
> the problem we try to solve. You have either runtime overhad or exponential
> growth.
> Maybe there is a way to avoid exponential growth using optimization
> techniques. Assumably in many cases the optimizer will reduce the amount of
> code anyway.
> There could be a guaranteed optimization. But I'm not sure which. I will
> build up an example, where the code isn't completely optimized away.
>
> I assume variant is an untagged union? Let's try to minimise our examples.
>
>
> Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:
>>
>> On domingo, 21 de maio de 2017 13:54:51 PDT ma.ka...@web.de wrote:
>> > Yeah, i realize that. This is something you have to consider if you're
>> > using templates extensively.
>>
>> No, it isn't. Today, the use of templates does not imply exponential
>> growth of
>> generated code.
>>
>> That is something completely new with your proposal.
>>
>> > This is not the right solution for everything.
>> > I think in most cases, you use one or at most two ternary operators in
>> one
>> > place. For three or more ternary operators the runtime overhead is
>> > assumably the lesser of two evils. But even if it grows exponentially,
>> the
>> > constants are pretty small. Normaly only a few instructions are
>> involved.
>>
>> Not necessarily. Remember that you may not reevaluate the condition, so
>> either
>> this generates completely separate code paths (and thus the exponential
>> expansion) or the result of the evaluation is stored in a hidden variable
>> that
>> is evaluated every time you access that automatic variable.
>>
>> That is, when you write:
>>
>> auto x = runtime_condition1 ? A{} : B{};
>> auto y = runtime_conditoin2 ? C{} : D{};
>> x.f();
>>
>> This expands to either:
>>
>> if (runtime_condition1) {
>> auto x = A{};
>> if (runtime_condition2) {
>> auto y = C {};
>> x.f() + y.f();
>> } else {
>> auto y = D {};
>> x.f() + y.f();
>> }
>> } else {
>> auto x = B{};
>> if (runtime_condition2) {
>> auto y = C {};
>> x.f() + y.f();
>> } else {
>> auto y = D {};
>> x.f() + y.f();
>> }
>> }
>>
>> or to:
>>
>> variant<A, B> x;
>> variant<C, D> y;
>> bool hidden1 = runtime_condition1;
>> if (hidden1)
>> x.create<A>();
>> else
>> x.create<B>();
>> bool hidden2 = runtime_condition2;
>> if (hidden2)
>> y.create<C>();
>> else
>> y.create<D>();
>> if (hidden1) {
>> if (hidden2)
>> x.as<A>().f() + y.as<C>().f();
>> else
>> x.as<A>().f() + y.as<D>().f();
>> } else {
>> if (hidden2)
>> x.as<B>().f() + y.as<C>().f();
>> else
>> x.as<B>().f() + y.as<D>().f();
>> }
>>
>> --
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>> Software Architect - Intel Open Source Technology Center
>>
>>
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a61766a4-0b37-44b0-91eb-0f6f697dae00%40isocpp.org.
------=_Part_2423_1574741073.1495437575821
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflo=
w-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div=
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> W</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: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> doit</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: #008;" cla=
ss=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">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><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: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">struct</span><span 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"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> doi=
t</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: #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">2</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">};</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> Y</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">int</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> doit</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retu=
rn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">3</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"> </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: #008;" class=3D"styled-by-prettify"=
>struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Z<=
/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: #008;" class=3D"styled-by-prettify">int</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> doit</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: #008;" class=3D"s=
tyled-by-prettify">return</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">4</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: #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><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> example</span><span style=3D"color: #660;" 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"> runtime_condition1</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: #008;" class=3D"styled-by-prettify">=
bool</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> runti=
me_condition2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> result</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">runtime_condition1</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> ternary_branch_1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">runtime_condition2</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">goto</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_bra=
nch_2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0=
=C2=A0 result </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> W=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">doit</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;" cla=
ss=3D"styled-by-prettify"> Y</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">goto</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
ternary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 <br>ternary_branch_1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">runtime_condition2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">goto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ternary_branch_3</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> X</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">{}.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">+<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> Y</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">goto</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> ternary_end</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br><br>ternary_branch_2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 result </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> W</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{}.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doit</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-b=
y-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> Z</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{}.</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">goto</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> ternary_end</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ternary_branch_3</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 r=
esult </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> X</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{}.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">doit</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: #000;" class=3D"sty=
led-by-prettify"> Z</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{}.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">doit</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>ter=
nary_end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> result=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><br>with -O0:<br><div style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overf=
low-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>W</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">do=
it</span><span style=3D"color: #660;" class=3D"styled-by-prettify">():</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
sp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">8</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">1</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =
=C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>X</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">():</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 QWORD PTR </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">8</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-prettify">=
2</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 ret<br>Y</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">doit</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">():</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 rbp</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rsp<=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 QWORD PTR </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">8</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</span><spa=
n 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=
: #066;" class=3D"styled-by-prettify">3</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=
=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br>Z</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">():</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =C2=A0 =C2=A0rbp<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 QWORD PTR </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">8</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> rdi<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-prettify">=
4</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 ret<br>example</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">b=
ool</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: #008;" class=3D"styled-by-prettify">bool</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">):</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 push =
=C2=A0 =C2=A0rbp<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rbp</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> rsp<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 push =C2=A0 =C2=A0rbx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">sub</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=A0 rsp</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=
: #066;" class=3D"styled-by-prettify">40</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =
=C2=A0 edx</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> edi<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 eax</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> esi<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=
=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">36</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> dl<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 mov =C2=A0 =C2=A0 BYTE PTR </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">40</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">],</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0=
=C2=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">36</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 xor =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0al</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jne =C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">L21<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> BYTE PTR </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">40</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0=
=C2=A0 xor =C2=A0 =C2=A0 eax</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: #066;" class=3D"styled-by-prettify"=
>1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0al</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jne =C2=A0 =C2=
=A0 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">L22<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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"style=
d-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">28</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0W</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0=
=C2=A0 ebx</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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: #660;" class=3D=
"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">27</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">]</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0Y</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">doit</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =
=C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> e=
bx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 DWORD PTR </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">20</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">],</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">L14<br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">L21</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 movzx =C2=A0 eax</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> BYTE PTR </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">[</span><span style=3D"color: #000;" class=3D"styled-by-prettify">r=
bp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">40</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 xo=
r =C2=A0 =C2=A0 eax</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 test =C2=A0 =C2=A0al</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> al<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jne =C2=A0 =C2=A0 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">L23<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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: #000;" class=3D"styled-by-prettify">rbp=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">26</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =
=C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
ax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0X</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 ebx<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 lea =C2=A0 =C2=A0 rax</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=
">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">25</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
mov =C2=A0 =C2=A0 rdi</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> rax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0Y</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">doit</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0=
eax</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> ebx<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 DWORD PTR </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">rbp</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">-</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">20</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">],</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">L14<br></span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">L22</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
lea =C2=A0 =C2=A0 rax</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">rbp</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"=
color: #066;" class=3D"styled-by-prettify">24</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0=
rdi</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0W</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 ebx</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 lea =C2=A0 =C2=A0 rax</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">rbp</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">-</span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">23</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>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0=
=C2=A0 rdi</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0Z</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">doit</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> ebx<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 mov =C2=A0 =C2=A0 DWORD PTR </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">rbp</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">20</span><span style=3D"color: #660;" class=3D"styled-by-prettify">],</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 jmp =C2=A0 =C2=A0 </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">L14<br></span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">L23</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 nop<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=A0 =
=C2=A0 rax</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">rbp</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">22</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 call =C2=A0 =C2=A0X</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 ebx</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 lea =C2=
=A0 =C2=A0 rax</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">rbp</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">21</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 rdi<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> rax<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 call =C2=A0 =C2=A0Z</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">doit</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> ebx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
mov =C2=A0 =C2=A0 DWORD PTR </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">[</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">rbp</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">-</span><span style=3D"color: #066;" class=3D"styled-by-prettify">20</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> eax<br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">L14</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 mov =C2=A0 =C2=A0 =
eax</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> DWORD PTR </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">rbp</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">-</span><span style=3D"color: #=
066;" class=3D"styled-by-prettify">20</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">]</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 rsp</sp=
an><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: #066;" class=3D"styled-by-prettify">40</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=
=A0 =C2=A0 rbx<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pop =C2=A0 =C2=A0 rbp<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 ret</span></div></code></div><br>with -O3:<br><div=
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" =
class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>example<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">bool</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: #008;=
" class=3D"styled-by-prettify">bool</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">):</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 xor =C2=A0 =C2=A0 eax</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> eax<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 test =C2=A0 =C2=A0sil</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> sil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 sete =C2=A0 =C2=A0al<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 test =C2=A0 =C2=A0dil</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> dil<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 je =C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">L2=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">4</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret<br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">L2</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 add =C2=A0 =C2=A0 eax<=
/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: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret</=
span></div></code></div><br><br><br><br>Am Montag, 22. Mai 2017 08:33:33 UT=
C+2 schrieb ma.ka...@web.de:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">Sure, you don't have always exponential growth when usin=
g templates. But if you simulating this case with template functions you en=
d up having the same problem.<br>So I wouldn't say, that this something=
completely new. It is the nature of the problem we try to solve. You have =
either runtime overhad or exponential growth.<br>Maybe there is a way to av=
oid exponential growth using optimization techniques. Assumably in many cas=
es the optimizer will reduce the amount of code anyway.<br>There could be a=
guaranteed optimization. But I'm not sure which. I will build up an ex=
ample, where the code isn't completely optimized away.<br><br>I assume =
variant is an untagged union? Let's try to minimise our examples.<br><b=
r><br>Am Montag, 22. Mai 2017 02:12:20 UTC+2 schrieb Thiago Macieira:<block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex">On domingo, 21 de maio de 2017 13:54:51 P=
DT <a rel=3D"nofollow">ma.ka...@web.de</a> wrote:
<br>> Yeah, i realize that. This is something you have to consider if yo=
u're
<br>> using templates extensively.=20
<br>
<br>No, it isn't. Today, the use of templates does not imply exponentia=
l growth of=20
<br>generated code.
<br>
<br>That is something completely new with your proposal.
<br>
<br>> This is not the right solution for everything.
<br>> I think in most cases, you use one or at most two ternary operator=
s in one
<br>> place. For three or more ternary operators the runtime overhead is
<br>> assumably the lesser of two evils. But even if it grows exponentia=
lly, the
<br>> constants are pretty small. Normaly only a few instructions are in=
volved.
<br>
<br>Not necessarily. Remember that you may not reevaluate the condition, so=
either=20
<br>this generates completely separate code paths (and thus the exponential=
=20
<br>expansion) or the result of the evaluation is stored in a hidden variab=
le that=20
<br>is evaluated every time you access that automatic variable.=20
<br>
<br>That is, when you write:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D runtime_cond=
ition1 ? A{} : B{};=20
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0auto y =3D runtime_cond=
itoin2 ? C{} : D{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0x.f();
<br>
<br>This expands to either:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition1)=
{
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D A{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0auto x =3D B{};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (runtime_condition2) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D C {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
auto y =3D D {};
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
x.f() + y.f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>or to:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<A, B> x;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0variant<C, D> y;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden1 =3D runtim=
e_condition1;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<A>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0x.create<B>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bool hidden2 =3D runtim=
e_condition2;
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<C>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0y.create<D>();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden1) {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>A>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} else {
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0if (hidden2)
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<C>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0else
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
<a href=3D"http://x.as" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"t=
his.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fx.as\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg';return true=
;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
x.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF_RgZBHEjoHC6BbryEAu7_i-OuOg&#=
39;;return true;">x.as</a><<wbr>B>().f() + <a href=3D"http://y.as" re=
l=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www=
..google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAF=
QjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;" onclick=3D"this.href=3D=
'http://www.google.com/url?q\x3dhttp%3A%2F%2Fy.as\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEuQstsnF5olzl8yADHUQunU-gAnw';return true;">y.as</a>=
<D>().f();
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0}
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"n=
ofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.googl=
e.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3dD\x26sntz\x3d1\x26usg\x3=
dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fmacieira.info\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return tru=
e;">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" rel=3D"nofol=
low" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.co=
m/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHGR=
Jdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fkde.org\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>
<br></blockquote></div></blockquote></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a61766a4-0b37-44b0-91eb-0f6f697dae00%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a61766a4-0b37-44b0-91eb-0f6f697dae00=
%40isocpp.org</a>.<br />
------=_Part_2423_1574741073.1495437575821--
------=_Part_2422_1294656618.1495437575818--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 22 May 2017 08:19:04 -0700
Raw View
On segunda-feira, 22 de maio de 2017 00:19:35 PDT ma.kalbfuss@web.de wrote:
> example(bool, bool):
> xor eax, eax
> test sil, sil
> sete al
> test dil, dil
> je .L2
> add eax, 4
> ret
> .L2:
> add eax, 5
> ret
You're showing that it is possible to inline functions. We already knew that.
Now try this with non-inline doit() functions. Just remove the function bodies
from your example.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1996408.ZYmak0RsWz%40tjmaciei-mobl1.
.
Author: mechaxcrash@gmail.com
Date: Wed, 30 Aug 2017 07:13:13 -0700 (PDT)
Raw View
------=_Part_9659_960297681.1504102393638
Content-Type: multipart/alternative;
boundary="----=_Part_9660_293199867.1504102393638"
------=_Part_9660_293199867.1504102393638
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Sorry for the necropost, but I feel like this should be discussed further.
With C++17 and what's been accepted into 2a so far, we can achieve some=20
very powerful code - but it's also unnecessarily complex.
with the removal of trigraphs in C++17, maybe something like ??: could be a=
=20
terse solution, or as the ternary operator only applies to expressions it=
=20
could be constexpr "where possible" (contextually aware) - I don't think=20
this would change the meaning of pre-existing code in any way.
As an example, with C++2a we can achieve something similar to this:=20
(creates constexpr heterogeneous list and returns a copy with a specified=
=20
element removed from it)
https://godbolt.org/g/p6TWFp
while with a constexpr ternary it could be shortened to:
https://godbolt.org/g/zNyb6q
For the relevant code, you're removing 7 lines of rather ugly code,=20
removing the reliance of inferred value passing (though this could be=20
achieve similarly with .operator()<> - GCC doesn't support this however)=20
and reducing template instantiations.
I think this is a big deal, and definitely something people would find a=20
use for moving forwards.
On Saturday, 20 May 2017 18:41:57 UTC+1, ma.ka...@web.de wrote:
>
> Hi Guys,
>
> I had the following situation:
>
> I have a Group of StaticSet classes with a compatible interface but=20
> distinct in there concrete type. empty_set is not an intervall!
> I tried the following:
>
>
> auto dec_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_BASE) =
-=20
> 1);
> auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interval('A', 'A' + (b=
ase=20
> - 1 - DECIMAL_BASE)) : empty_set;
> auto lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', 'a' + (b=
ase=20
> - 1 - DECIMAL_BASE)) : empty_set;
>
>
> Wouldn't it be possible to allow such code, especially in conjunction wit=
h=20
> concepts?
>
> MFG
>
> Martin Kalbfu=C3=9F
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/aa3f0ad3-d95b-4937-9264-5924a31a84f2%40isocpp.or=
g.
------=_Part_9660_293199867.1504102393638
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Sorry for the necropost, but I feel like this should be di=
scussed further.<br><br>With C++17 and what's been accepted into 2a so =
far, we can achieve some very powerful code - but it's also unnecessari=
ly complex.<br><br>with the removal of trigraphs in C++17, maybe something =
like ??: could be a terse solution, or as the ternary operator only applies=
to expressions it could be constexpr "where possible" (contextua=
lly aware) - I don't think this would change the meaning of pre-existin=
g code in any way.<div><br></div><div>As an example, with C++2a we can achi=
eve something similar to this: (creates constexpr heterogeneous list and re=
turns a copy with a specified element removed from it)</div><div>https://go=
dbolt.org/g/p6TWFp</div><div>while with a constexpr ternary it could be sho=
rtened to:</div><div>https://godbolt.org/g/zNyb6q</div><div><br></div><div>=
For the relevant code, you're removing 7 lines of rather ugly code, rem=
oving the reliance of inferred value passing (though this could be achieve =
similarly with .operator()<> - GCC doesn't support this however) =
and reducing template instantiations.</div><div><br></div><div>I think this=
is a big deal, and definitely something people would find a use for moving=
forwards.<br><br>On Saturday, 20 May 2017 18:41:57 UTC+1, ma.ka...@web.de =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi Guy=
s,<br><br>I had the following situation:<br><br>I have a Group of StaticSet=
classes with a compatible interface but distinct in there concrete type. e=
mpty_set is not an intervall!<br>I tried the following:<br><br><br>auto dec=
_digit =3D make_interval('0', '0' + std::min(base, DECIMAL_=
BASE) - 1);<br>auto upper_digit =3D (base > DECIMAL_DIGIT) ? make_interv=
al('A', 'A' + (base - 1 - DECIMAL_BASE)) : empty_set;<br>au=
to lower_digit =3D (base > DECIMAL_DIGIT) ? make_interval('a', &=
#39;a' + (base - 1 - DECIMAL_BASE)) : empty_set;<br><br><br>Wouldn'=
t it be possible to allow such code, especially in conjunction with concept=
s?<br><br>MFG<br><br>Martin Kalbfu=C3=9F<br></div></blockquote></div></div>
<p></p>
-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/aa3f0ad3-d95b-4937-9264-5924a31a84f2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/aa3f0ad3-d95b-4937-9264-5924a31a84f2=
%40isocpp.org</a>.<br />
------=_Part_9660_293199867.1504102393638--
------=_Part_9659_960297681.1504102393638--
.