Topic: switch constexpr
Author: Elias Kosunen <elias.kosunen@gmail.com>
Date: Mon, 10 Jul 2017 09:00:42 -0700 (PDT)
Raw View
------=_Part_5893_1334720634.1499702442963
Content-Type: multipart/alternative;
boundary="----=_Part_5894_799713852.1499702442964"
------=_Part_5894_799713852.1499702442964
Content-Type: text/plain; charset="UTF-8"
With the introduction of if constexpr in C++17, I was wondering if we could
also extend the same behavior to switch-statements. I think it would fit
well in the language and simplify complicated compile-time branching.
It would also enable compile-time usage of the C++ Core Guideline ES.70
<https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-switch-if>
(Prefer a switch-statement to an if-statement when there is a choice)
For example:
template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
int do_integer() {
// if constexpr
if constexpr (sizeof(T) == 1) {
return do_i8();
} else if constexpr (sizeof(T) == 2) {
return do_i16();
} else if constexpr (sizeof(T) == 4) {
return do_i32();
} else if constexpr (sizeof(T) == 8) {
return do_i64();
} else {
// We *shouldn't* get here
}
// Simplified with switch constexpr
switch constexpr (sizeof(T)) {
case 1: return do_i8();
case 2: return do_i16();
case 4: return do_i32();
case 8: return do_i64();
default: // Is there any architecture with other-sized integers?
}
}
Even in that relatively simple example, the switch-method, in my opinion,
is clearer and more expressive.
Surprisingly, I couldn't find any discussion in this regard. Should there
be any, please point me to it.
- Elias
--
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/acb63c8d-7009-41e5-99c6-715b4f812b35%40isocpp.org.
------=_Part_5894_799713852.1499702442964
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">With the introduction of<code> <font face=3D"courier new,m=
onospace">if constexpr <font face=3D"arial,sans-serif">in C++17, I was wond=
ering if we could also extend the same behavior to <font face=3D"courier ne=
w,monospace">switch<font face=3D"arial,sans-serif">-statements. I think it =
would fit well in the language and simplify complicated compile-time branch=
ing.<br>It would also enable compile-time usage of the <a href=3D"https://g=
ithub.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Res-swi=
tch-if">C++ Core Guideline ES.70</a> (</font></font></font></font></code>Pr=
efer a <span style=3D"font-family: courier new,monospace;">switch</span>-st=
atement to an <span style=3D"font-family: courier new,monospace;">if</span>=
-statement when there is a choice<code><font face=3D"courier new,monospace"=
><font face=3D"arial,sans-serif"><font face=3D"courier new,monospace"><font=
face=3D"arial,sans-serif">)<br><br>For example:<br></font></font><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;" c=
lass=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</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: #008;" class=3D"styled-by-prettify">typename</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T</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">typename</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">enable_if_t=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span 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"co=
lor: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">>>></span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> do_integer</span><span style=3D"color: #660;" class=
=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"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// if constexpr</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">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 style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #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">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> do_i8</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>=C2=A0 =C2=A0 </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">else</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">constexpr</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">sizeof<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">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 style=3D"color: #660;" =
class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styl=
ed-by-prettify">2</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><sp=
an 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">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
do_i16</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: #660;" class=3D"styled-by-prettify">}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">else</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">constexpr</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: #008;" class=3D"styled-by-pret=
tify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">T</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">=3D=3D</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" c=
lass=3D"styled-by-prettify">4</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"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> do_i32</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 </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">else</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">sizeof</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">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: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=
=3D"color: #000;" 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"> </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">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> do_i64</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0 =C2=A0 </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">=
else</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 =C2=A0=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
We *shouldn't* get here</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>=C2=A0 =C2=A0 </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><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// Simplified with switch constexpr</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">switch</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">constexpr</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: #008;"=
class=3D"styled-by-prettify">sizeof</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">T</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>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">case</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</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=
: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> do_i8</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">case</span><span style=3D"co=
lor: #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"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> do_i16</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"style=
d-by-prettify">case</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: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> do_i32</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">case</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #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"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> do_i64</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 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">default</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: #800;" class=3D"styled-by-prettif=
y">// Is there any architecture with other-sized integers?</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><s=
pan 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></div></code></div><br>Eve=
n in that relatively simple example, the <font face=3D"courier new,monospac=
e">switch<font face=3D"arial,sans-serif">-method, in my opinion, is clearer=
and more expressive.<br><br>Surprisingly, I couldn't find any discussi=
on in this regard. Should there be any, please point me to it.<br><br>- Eli=
as<br></font></font></font></font></code></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/acb63c8d-7009-41e5-99c6-715b4f812b35%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/acb63c8d-7009-41e5-99c6-715b4f812b35=
%40isocpp.org</a>.<br />
------=_Part_5894_799713852.1499702442964--
------=_Part_5893_1334720634.1499702442963--
.
Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 10 Jul 2017 13:30:40 -0500
Raw View
--94eb2c04315aacfeb20553fac716
Content-Type: text/plain; charset="UTF-8"
On Mon, Jul 10, 2017 at 11:00 AM, Elias Kosunen <elias.kosunen@gmail.com>
wrote:
> template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
> int do_integer() {
> // if constexpr
> if constexpr (sizeof(T) == 1) {
> return do_i8();
> } else if constexpr (sizeof(T) == 2) {
> return do_i16();
> } else if constexpr (sizeof(T) == 4) {
> return do_i32();
> } else if constexpr (sizeof(T) == 8) {
> return do_i64();
> } else {
> // We *shouldn't* get here
> }
>
> // Simplified with switch constexpr
> switch constexpr (sizeof(T)) {
> case 1: return do_i8();
> case 2: return do_i16();
> case 4: return do_i32();
> case 8: return do_i64();
> default: // Is there any architecture with other-sized integers?
> }
> }
>
> Even in that relatively simple example, the switch-method, in my opinion,
> is clearer and more expressive.
>
Selectively instantiating overlapping scopes are
unnessasrily complex, since switch statements
support fallthrough. Beyond that, switch statements
doesn't support examining user-defined literal types,
making `switch constexpr` less useful.
>
> Surprisingly, I couldn't find any discussion in this regard. Should there
> be any, please point me to it.
>
Read this proposal:
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0404r0.html
The idea here is simple if you understand C11
generic selection expressions.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________
--
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/CAGsORuATMX%3D5ieqh5X042tu61KB5NY7%3D5sBqqPyXvNJ1CvS2mA%40mail.gmail.com.
--94eb2c04315aacfeb20553fac716
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Mon, Jul 10, 2017 at 11:00 AM, Elias Kosunen <span dir=
=3D"ltr"><<a href=3D"mailto:elias.kosunen@gmail.com" target=3D"_blank">e=
lias.kosunen@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra">=
<div class=3D"gmail_quote"><br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex"><div dir=3D"ltr"><code><font face=3D"courier new,monospace"><font fac=
e=3D"arial,sans-serif"><br><div style=3D"background-color:rgb(250,250,250);=
border-color:rgb(187,187,187);border-style:solid;border-width:1px" class=3D=
"gmail-m_7222025129221966434prettyprint"><code class=3D"gmail-m_72220251292=
21966434prettyprint"><div class=3D"gmail-m_7222025129221966434subprettyprin=
t"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434s=
tyled-by-prettify">template</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_7222025129221966434styled-by-prettify"> </span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">&=
lt;</span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221=
966434styled-by-prettify">typename</span><span style=3D"color:rgb(0,0,0)" c=
lass=3D"gmail-m_7222025129221966434styled-by-prettify"> T</span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-pre=
ttify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129=
221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" cla=
ss=3D"gmail-m_7222025129221966434styled-by-prettify">typename</span><span s=
tyle=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-pre=
ttify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_722202=
5129221966434styled-by-prettify">=3D</span><span style=3D"color:rgb(0,0,0)"=
class=3D"gmail-m_7222025129221966434styled-by-prettify"> std</span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by=
-prettify">::</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_72220=
25129221966434styled-by-prettify">enable_if_t</span><span style=3D"color:rg=
b(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify">std</span><span style=3D"color:rgb(102,102,0)" class=3D=
"gmail-m_7222025129221966434styled-by-prettify">::</span><span style=3D"col=
or:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">is_<=
wbr>integral_v</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
7222025129221966434styled-by-prettify"><</span><span style=3D"color:rgb(=
0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">T</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434style=
d-by-prettify">>>></span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_7222025129221966434styled-by-prettify"><br></span><span style=3D"c=
olor:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify">=
int</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202512922196=
6434styled-by-prettify"> do_integer</span><span style=3D"color:rgb(102,102,=
0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">()</span><span =
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-pr=
ettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_72220=
25129221966434styled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_72220251292219664=
34styled-by-prettify">// if constexpr</span><span style=3D"color:rgb(0,0,0)=
" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0=
</span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_722202512922196=
6434styled-by-prettify">if</span><span style=3D"color:rgb(0,0,0)" class=3D"=
gmail-m_7222025129221966434styled-by-prettify"> </span><span style=3D"color=
:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify">cons=
texpr</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221=
966434styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" clas=
s=3D"gmail-m_7222025129221966434styled-by-prettify">(</span><span style=3D"=
color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify"=
>sizeof</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025=
129221966434styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-m_7222025129221966434styled-by-prettify">T</span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-pre=
ttify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129=
221966434styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" c=
lass=3D"gmail-m_7222025129221966434styled-by-prettify">=3D=3D</span><span s=
tyle=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-pre=
ttify"> </span><span style=3D"color:rgb(0,102,102)" class=3D"gmail-m_722202=
5129221966434styled-by-prettify">1</span><span style=3D"color:rgb(102,102,0=
)" class=3D"gmail-m_7222025129221966434styled-by-prettify">)</span><span st=
yle=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-pret=
tify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025=
129221966434styled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_72220=
25129221966434styled-by-prettify">return</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> do_i8</span><=
span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434sty=
led-by-prettify">();</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-p=
rettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_72220251=
29221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" c=
lass=3D"gmail-m_7222025129221966434styled-by-prettify">else</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prett=
ify"> </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129=
221966434styled-by-prettify">if</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"gmail-m_7222025129221966434styled-by-prettify"> </span><span style=3D"=
color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify"=
>constexpr</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_72220251=
29221966434styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)"=
class=3D"gmail-m_7222025129221966434styled-by-prettify">(</span><span styl=
e=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-pret=
tify">sizeof</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_72=
22025129221966434styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_7222025129221966434styled-by-prettify">T</span><span st=
yle=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-=
prettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025=
129221966434styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)=
" class=3D"gmail-m_7222025129221966434styled-by-prettify">=3D=3D</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-=
prettify"> </span><span style=3D"color:rgb(0,102,102)" class=3D"gmail-m_722=
2025129221966434styled-by-prettify">2</span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">)</span><span=
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-p=
rettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222=
025129221966434styled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)"=
class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_72=
22025129221966434styled-by-prettify">return</span><span style=3D"color:rgb(=
0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> do_i16</sp=
an><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_722202512922196643=
4styled-by-prettify">();</span><span style=3D"color:rgb(0,0,0)" class=3D"gm=
ail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span=
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-=
by-prettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222=
025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136=
)" class=3D"gmail-m_7222025129221966434styled-by-prettify">else</span><span=
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-p=
rettify"> </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_722202=
5129221966434styled-by-prettify">if</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_7222025129221966434styled-by-prettify"> </span><span style=
=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prett=
ify">constexpr</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222=
025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(102,102=
,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">(</span><span =
style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-=
prettify">sizeof</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify">(</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">T</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled=
-by-prettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722=
2025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">=3D=3D</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled=
-by-prettify"> </span><span style=3D"color:rgb(0,102,102)" class=3D"gmail-m=
_7222025129221966434styled-by-prettify">4</span><span style=3D"color:rgb(10=
2,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">)</span><=
span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-=
by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
7222025129221966434styled-by-prettify">{</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify">return</span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> do_i32=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_72220251292219=
66434styled-by-prettify">();</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434s=
tyled-by-prettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(0=
,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify">else</span=
><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434style=
d-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_=
7222025129221966434styled-by-prettify">if</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> </span><span=
style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by=
-prettify">constexpr</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">(</span>=
<span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styl=
ed-by-prettify">sizeof</span><span style=3D"color:rgb(102,102,0)" class=3D"=
gmail-m_7222025129221966434styled-by-prettify">(</span><span style=3D"color=
:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">T</spa=
n><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_7222025129221966434styled-by-prettify"> </span><span style=3D"color:rgb(=
102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">=3D=3D<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify"> </span><span style=3D"color:rgb(0,102,102)" class=3D"g=
mail-m_7222025129221966434styled-by-prettify">8</span><span style=3D"color:=
rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">)</=
span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434s=
tyled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gm=
ail-m_7222025129221966434styled-by-prettify">{</span><span style=3D"color:r=
gb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D=
"gmail-m_7222025129221966434styled-by-prettify">return</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">=
do_i64</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025=
129221966434styled-by-prettify">();</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_722202512922196=
6434styled-by-prettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"g=
mail-m_7222025129221966434styled-by-prettify"> </span><span style=3D"color:=
rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify">else<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"g=
mail-m_7222025129221966434styled-by-prettify">{</span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0)" class=3D=
"gmail-m_7222025129221966434styled-by-prettify">// We *shouldn't* get h=
ere</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202512922196=
6434styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">}</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled=
-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,0,0=
)" class=3D"gmail-m_7222025129221966434styled-by-prettify">// Simplified wi=
th switch constexpr</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span styl=
e=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-pret=
tify">switch</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202=
5129221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)"=
class=3D"gmail-m_7222025129221966434styled-by-prettify">constexpr</span><s=
pan style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-b=
y-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7=
222025129221966434styled-by-prettify">(</span><span style=3D"color:rgb(0,0,=
136)" class=3D"gmail-m_7222025129221966434styled-by-prettify">sizeof</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434st=
yled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_7222025129221966434styled-by-prettify">T</span><span style=3D"color:rgb(10=
2,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">))</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled=
-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_7222025129221966434styled-by-prettify">{</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gma=
il-m_7222025129221966434styled-by-prettify">case</span><span style=3D"color=
:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> </spa=
n><span style=3D"color:rgb(0,102,102)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify">1</span><span style=3D"color:rgb(102,102,0)" class=3D"g=
mail-m_7222025129221966434styled-by-prettify">:</span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> </span=
><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434sty=
led-by-prettify">return</span><span style=3D"color:rgb(0,0,0)" class=3D"gma=
il-m_7222025129221966434styled-by-prettify"> do_i8</span><span style=3D"col=
or:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">=
();</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202512922196=
6434styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prett=
ify">case</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202512=
9221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,102,102)" =
class=3D"gmail-m_7222025129221966434styled-by-prettify">2</span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-pre=
ttify">:</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129=
221966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" cla=
ss=3D"gmail-m_7222025129221966434styled-by-prettify">return</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prett=
ify"> do_i16</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_72=
22025129221966434styled-by-prettify">();</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify">case</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> </span><=
span style=3D"color:rgb(0,102,102)" class=3D"gmail-m_7222025129221966434sty=
led-by-prettify">4</span><span style=3D"color:rgb(102,102,0)" class=3D"gmai=
l-m_7222025129221966434styled-by-prettify">:</span><span style=3D"color:rgb=
(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify"> </span><s=
pan style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled=
-by-prettify">return</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify"> do_i32</span><span style=3D"color=
:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">()=
;</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_72220251292219664=
34styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D=
"color:rgb(0,0,136)" class=3D"gmail-m_7222025129221966434styled-by-prettify=
">case</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_722202512922=
1966434styled-by-prettify"> </span><span style=3D"color:rgb(0,102,102)" cla=
ss=3D"gmail-m_7222025129221966434styled-by-prettify">8</span><span style=3D=
"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-pretti=
fy">:</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221=
966434styled-by-prettify"> </span><span style=3D"color:rgb(0,0,136)" class=
=3D"gmail-m_7222025129221966434styled-by-prettify">return</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434styled-by-prettif=
y"> do_i64</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222=
025129221966434styled-by-prettify">();</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-=
m_7222025129221966434styled-by-prettify">default</span><span style=3D"color=
:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">:<=
/span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222025129221966434=
styled-by-prettify"> </span><span style=3D"color:rgb(136,0,0)" class=3D"gma=
il-m_7222025129221966434styled-by-prettify">// Is there any architecture wi=
th other-sized integers?</span><span style=3D"color:rgb(0,0,0)" class=3D"gm=
ail-m_7222025129221966434styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span=
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7222025129221966434styled-=
by-prettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7222=
025129221966434styled-by-prettify"><br></span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7222025129221966434styled-by-prettify">}</span></d=
iv></code></div><br>Even in that relatively simple example, the <font face=
=3D"courier new,monospace">switch<font face=3D"arial,sans-serif">-method, i=
n my opinion, is clearer and more expressive.<br></font></font></font></fon=
t></code></div></blockquote><div><br></div><div>Selectively instantiating o=
verlapping scopes are<br>unnessasrily complex, since switch statements<br>s=
upport fallthrough.=C2=A0 Beyond that, switch statements<br>doesn't sup=
port examining user-defined literal types,<br>making `switch constexpr` les=
s useful.<br></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div dir=3D"ltr"><code><font face=3D"courier new,monospace"><fon=
t face=3D"arial,sans-serif"><font face=3D"courier new,monospace"><font face=
=3D"arial,sans-serif"><br>Surprisingly, I couldn't find any discussion =
in this regard. Should there be any, please point me to it.<span class=3D"g=
mail-HOEnZb"></span></font></font></font></font></code><br></div></blockquo=
te></div><br></div><div class=3D"gmail_extra">Read this proposal: <a href=
=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0404r0.html">h=
ttp://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0404r0.html</a><br>=
</div><div class=3D"gmail_extra">The idea here is simple if you understand =
C11<br>generic selection expressions.<br></div><div class=3D"gmail_extra"><=
br>-- <br><div class=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"=
ltr"><div><div dir=3D"ltr"><div>Zhihao Yuan, ID lichray<br>The best way to =
predict the future is to invent it.<br>____________________________________=
___________<br></div></div></div></div></div></div></div>
</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/CAGsORuATMX%3D5ieqh5X042tu61KB5NY7%3D=
5sBqqPyXvNJ1CvS2mA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuATMX%3=
D5ieqh5X042tu61KB5NY7%3D5sBqqPyXvNJ1CvS2mA%40mail.gmail.com</a>.<br />
--94eb2c04315aacfeb20553fac716--
.
Author: Ray Hamel <rayghamel@gmail.com>
Date: Mon, 10 Jul 2017 15:04:53 -0700 (PDT)
Raw View
------=_Part_6803_1747429081.1499724293756
Content-Type: multipart/alternative;
boundary="----=_Part_6804_621522836.1499724293756"
------=_Part_6804_621522836.1499724293756
Content-Type: text/plain; charset="UTF-8"
For consistency and flexibility's sake, perhaps constexpr versions of for,
while, and do-while statements should also be added at the same time?
--
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/25e84110-5b8b-471d-a72b-2ed5b63f4865%40isocpp.org.
------=_Part_6804_621522836.1499724293756
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">For consistency and flexibility's sake, perh<font face=
=3D"arial, sans-serif">aps constexpr=C2=A0versions of for, while, and do-wh=
ile statements should also be added at the same time?</font></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/25e84110-5b8b-471d-a72b-2ed5b63f4865%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/25e84110-5b8b-471d-a72b-2ed5b63f4865=
%40isocpp.org</a>.<br />
------=_Part_6804_621522836.1499724293756--
------=_Part_6803_1747429081.1499724293756--
.
Author: =?UTF-8?Q?Micha=C5=82_Dominiak?= <griwes@griwes.info>
Date: Mon, 10 Jul 2017 23:41:49 +0000
Raw View
--f4030436191c1053710553ff2118
Content-Type: text/plain; charset="UTF-8"
Those have a very different compile time complexities and will be handled
separately by SG7.
On Mon, Jul 10, 2017 at 6:04 PM Ray Hamel <rayghamel@gmail.com> wrote:
> For consistency and flexibility's sake, perhaps constexpr versions of
> for, while, and do-while statements should also be added at the same time?
>
> --
> 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/25e84110-5b8b-471d-a72b-2ed5b63f4865%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/25e84110-5b8b-471d-a72b-2ed5b63f4865%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
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/CAPCFJdSeUSu4d950NPvycy3auCkoK9WZJJeZmr7epESQCG%3Dp8A%40mail.gmail.com.
--f4030436191c1053710553ff2118
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Those have a very different compile time complexities and =
will be handled separately by SG7.</div><br><div class=3D"gmail_quote"><div=
dir=3D"ltr">On Mon, Jul 10, 2017 at 6:04 PM Ray Hamel <<a href=3D"mailt=
o:rayghamel@gmail.com">rayghamel@gmail.com</a>> wrote:<br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">For consistency and flexibility'=
;s sake, perh<font face=3D"arial, sans-serif">aps constexpr=C2=A0versions o=
f for, while, and do-while statements should also be added at the same time=
?</font></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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/25e84110-5b8b-471d-a72b-2ed5b63f4865%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/25e84110-5b8b-=
471d-a72b-2ed5b63f4865%40isocpp.org</a>.<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/CAPCFJdSeUSu4d950NPvycy3auCkoK9WZJJeZ=
mr7epESQCG%3Dp8A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdSeUSu4d9=
50NPvycy3auCkoK9WZJJeZmr7epESQCG%3Dp8A%40mail.gmail.com</a>.<br />
--f4030436191c1053710553ff2118--
.
Author: Elias Kosunen <elias.kosunen@gmail.com>
Date: Wed, 12 Jul 2017 11:39:44 -0700 (PDT)
Raw View
------=_Part_157_1868236414.1499884784327
Content-Type: multipart/alternative;
boundary="----=_Part_158_791734336.1499884784327"
------=_Part_158_791734336.1499884784327
Content-Type: text/plain; charset="UTF-8"
I considered them as well, but I think their semantics wouldn't be as
obvious as it is for if and switch.
On Tuesday, July 11, 2017 at 1:04:53 AM UTC+3, Ray Hamel wrote:
>
> For consistency and flexibility's sake, perhaps constexpr versions of
> for, while, and do-while statements should also be added at the same time?
>
--
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/cf6c1919-9545-4cbb-a419-4ec40f4c1ed9%40isocpp.org.
------=_Part_158_791734336.1499884784327
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I considered them as well, but I think their semantics wou=
ldn't be as obvious as it is for <font face=3D"courier new,monospace">i=
f <font face=3D"arial,sans-serif">and <font face=3D"courier new,monospace">=
switch<font face=3D"arial,sans-serif">.</font></font></font></font><br><br>=
On Tuesday, July 11, 2017 at 1:04:53 AM UTC+3, Ray Hamel wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">For consistency and flexi=
bility's sake, perh<font face=3D"arial, sans-serif">aps constexpr=C2=A0=
versions of for, while, and do-while statements should also be added at the=
same time?</font></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/cf6c1919-9545-4cbb-a419-4ec40f4c1ed9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cf6c1919-9545-4cbb-a419-4ec40f4c1ed9=
%40isocpp.org</a>.<br />
------=_Part_158_791734336.1499884784327--
------=_Part_157_1868236414.1499884784327--
.
Author: Ray Hamel <rayghamel@gmail.com>
Date: Wed, 12 Jul 2017 12:58:39 -0700 (PDT)
Raw View
------=_Part_37_1170830719.1499889519108
Content-Type: multipart/alternative;
boundary="----=_Part_38_979481818.1499889519108"
------=_Part_38_979481818.1499889519108
Content-Type: text/plain; charset="UTF-8"
Yes, thinking about it a little more it's a tricky subset of the halting
problem to determine at compile time whether a loop is (or might be)
infinite. Although I think this capability might already be required of
conforming implementations?
constexpr void loop(int i) {while (i++);}
// GCC, VS & ICC currently return true if loop provably finite, false
otherwise
// Clang always returns false
noexcept(loop(foo))
-Ray
On Wednesday, July 12, 2017 at 2:39:44 PM UTC-4, Elias Kosunen wrote:
>
> I considered them as well, but I think their semantics wouldn't be as
> obvious as it is for if and switch.
>
> On Tuesday, July 11, 2017 at 1:04:53 AM UTC+3, Ray Hamel wrote:
>>
>> For consistency and flexibility's sake, perhaps constexpr versions of
>> for, while, and do-while statements should also be added at the same time?
>>
>
--
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/213472b3-e725-4cef-9667-66cd80cbec18%40isocpp.org.
------=_Part_38_979481818.1499889519108
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Yes, thinking about it a little more it's a trick=
y subset of the halting problem to determine at compile time whether a loop=
is (or might be) infinite. Although I think this capability might already =
be required of conforming implementations?</div><div><br></div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px=
solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> loop</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><sp=
an 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"styled-by-prettify">{</span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">while</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">i</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">++);}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// GCC, VS & ICC cu=
rrently return true if loop provably finite, false otherwise</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// Clang always returns false</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>noexcept=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">loop</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">foo</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">))</span></div></code></div><div><br></di=
v><div>-Ray</div><br>On Wednesday, July 12, 2017 at 2:39:44 PM UTC-4, Elias=
Kosunen 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 considered them as well, but I think their semantics wouldn't be as=
obvious as it is for <font face=3D"courier new,monospace">if <font face=3D=
"arial,sans-serif">and <font face=3D"courier new,monospace">switch<font fac=
e=3D"arial,sans-serif">.</font></font></font></font><br><br>On Tuesday, Jul=
y 11, 2017 at 1:04:53 AM UTC+3, Ray Hamel wrote:<blockquote class=3D"gmail_=
quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddi=
ng-left:1ex"><div dir=3D"ltr">For consistency and flexibility's sake, p=
erh<font face=3D"arial, sans-serif">aps constexpr=C2=A0versions of for, whi=
le, and do-while statements should also be added at the same time?</font></=
div></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/213472b3-e725-4cef-9667-66cd80cbec18%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/213472b3-e725-4cef-9667-66cd80cbec18=
%40isocpp.org</a>.<br />
------=_Part_38_979481818.1499889519108--
------=_Part_37_1170830719.1499889519108--
.