Topic: constexpr only functions: arbitrary literal types for
Author: Bastien Penavayre <swac31@gmail.com>
Date: Thu, 31 Aug 2017 11:43:27 -0700 (PDT)
Raw View
------=_Part_1591_1795418109.1504205007664
Content-Type: multipart/alternative;
boundary="----=_Part_1592_697479766.1504205007666"
------=_Part_1592_697479766.1504205007666
Content-Type: text/plain; charset="UTF-8"
Hi,
So let me pressent the current state of affairs.
There are a bunch of proposals floating around, that, I think, are
interesting but have issues implementation-wise or are a bit clunky.
*N3413* (arbitrary literal types for non-type) for instance requires that a
bunch of controversial questions to be answered to be accepted (mangling,
operator== or bitwise, ...).
Because of that this proposal will not come around any time soon.
At the same time demands to check or enforce constexpr-ness in functions
were made through the ideas of *forced constexpr arguments* and*
is_constexpr()*.
- The first has the same issues as *N3413* as it requires said
constexpr arguments be integrated into the mangling of the function, making
this proposal syntax sugar to *N3413*.
//this
template<Literal l> void func();
//differs only through call syntax from this
void func(constexpr Literal l);
//yet this would allow to get rid of atrocious code like this
template<auto I>
constexpr auto func(std:integral_constant<decltype(I), I>); //only uses I
- The latter (*is_constexpr*) aims to allow a runtime or compile-time
specialization through a constexpr expression with a variant value. It
would requires long *if constexpr *blocks as, if runtime specialization
is required, we can assume that the runtime and compile-time version will
share very little code. It would also mean that, despite the
confirmation by the compiler that we are in constexpr context with
arguments being compile-time evaluated, we would still be incapable to use
those as such or would require that *if constexp(is_constexpr()) *have
side-effects (big no-no).
constexpr auto func(int i)
{
if constexpr (is_constexpr())
{
//i is still not usable as a constexpr
//long piece of code or call to other function that handles the
compile-time version
...
}
else
{
//long piece of code or call to other function that handles the
runtime version
....
}
}
Now that the context has been presented here is my proposal with a detailed
and commented exemple.
My goal is to allow a big chunk of what the other proposal aimed to allow
without all their issues and in one proposal.
It is to allow constexpr-only specialization by borrowing the *noexcept*
syntax.
As the function may only be constexpr it will not have linkage and therefor
no mangling nor all the issues associated with it.
Now here is a *detailed exemple*.
//compile-time only function
//it will never have linkage
//all its arguments are constexpr
//a non-constexpr expression usage in its definition will cause an error
instead of a fallback like normal constexpr
//is only called in an explicit constexpr context unlike normal constexpr
constexpr(true) auto func(Literal r);
//runtime specialization of func
/*constexpr(false)*/ auto func(Literal r); //constexpr(false) is the
default for functions and methods
//error redefinition of 'constexpr(false) void func(Literal)'
constexpr void func();
constexpr(true) auto func2();
//allowed
//constexpr is ignored, retains inline side effect
constexpr auto func2();
constexpr auto func3();
constexpr auto error_0 = func3();
//constexpr specialization of 'func3' after instanciation
constexpr(true) auto func3();
//addresses demands for partially constexpr argument-list
constexpr(true) void partial_constexpr(int constant)
{
return [&](auto&&... runtime_args) constexpr /*this lambda has the
default constexpr behavior*/ {
//runtime code
//can use 'constant' as a constexpr here
};
}
int main()
{
constexpr auto r_0 = func(Literal{}); //constexpr(true) version called
auto r_1 = func(Literal{}); //constexpr(false) version called
partial_constexpr(42/*compile-time args*/)(/*runtime args*/);
auto r_2 = constexpr func(Literal{}); //also proposed unary constexpr
operator for explicit selection, error if the expression is not constexpr
//is equivalent to
auto r_3 = []() { constexpr auto __ret__ = func(Literal{}); return __ret__
; }();
}
//replacing of gnu's operator"" extension
constexpr(true) auto operator""_string_literal(const char *str, size_t len)
{
return [&]<size_t... Indexs>(std::index_sequence<Indexs...>&&)
{
return TemplateCharSeq<str[Indexs]...>{};
}(std::make_index_sequence<len>{});
}
//operator[] for std::tuple
template <class... Args>
struct tuple
{
...
constexpr(true) auto& operator[](size_t i) const
{
static_assert(i < sizeof...(Args));
return std::get<i>(*this);
}
constexpr(true) auto& operator[](size_t i)
{
static_assert(i < sizeof...(Args));
return std::get<i>(*this);
}
....
};
template <class... Args> struct Select : Args... { using Args::operator
()...; };
template <class... Args> Select(Args&&...) -> Select<Args...>;
//for lambdas
void func_3()
{
constexpr auto f_0 = []() {}; //operator() is constexpr /*fallback on
runtime*/, no changes
constexpr auto f_1 = []() constexpr(false) {}; //operator() cannot be
called at compile-time
constexpr auto f_2 = []() constexpr(true) {}; //operator() can only be
called a compile-time and explicitly
constexpr Select f_3 = { f_1, f_2 };
constexpr auto r_4 = f_3(); //f_2
auto r_5 = f_3(); //f_1
}
Here is the summary:
- extend constexpr specifier to allow it to take a constexpr explicit bool
(no a constexpr expression unless if there are good use-cases for it) where:
- constexpr(false) is the default specifier of a function/method
- optional for functions/method.
- if specified with lambdas allows not-constexpr lambda as lambdas
are by default constexpr.
- constexpr(true) is a constexpr only function.
- no Assembly representation (no linkage nor mangling).
- all arguments are constexpr.
- error if non-constexpr expression is used (a constexpr fallback to
runtime because of an overflow for instance).
- only used in explicit constexpr context.
- cannot be called before its specialization if specialization or
else error.
- constexpr
- keeps all its properties and definition.
- will still trigger redefinition error if previous constexpr(false)
version previously defined.
- constexpr attribute ignored if previous constexpr(true) is defined.
- unary constexpr operator to request a constexpr expression explicitly:
auto t = constexpr expr; //might error if expr is no a constexpr
expression
The reason why I believe in this proposal:
- no new keyword.
- zero runtime impact.
- maintains backward compatibility.
- solves, at least partially, a lot of different proposals.
Thanks in advance,
Bastien Penavayre,
bastienPenava@gmail.com
--
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/17e156a0-0368-4ec0-a087-e8b4bc8d9f62%40isocpp.org.
------=_Part_1592_697479766.1504205007666
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,=C2=A0<div><div><br></div><div>So let me pressent the c=
urrent state of affairs.</div><div><br></div><div>There are a bunch of prop=
osals floating around, that, I think, are interesting but have issues imple=
mentation-wise or are a bit clunky.</div><div><font style=3D"font-family: a=
rial, sans-serif; color: rgb(0, 0, 0);" size=3D"2"><b style=3D"font-style: =
italic;">N3413</b> (</font><font color=3D"#000000" face=3D"arial, sans-seri=
f"><font size=3D"2">arbitrary literal types for non-type)</font><font size=
=3D"2" style=3D"font-style: italic; font-weight: bold;">=C2=A0</font><font =
size=3D"2">f</font></font><font style=3D"font-family: arial, sans-serif;"><=
font color=3D"#000000">or instance requires=C2=A0that a bunch of controvers=
ial questions to be answered to be accepted (mangling, operator=3D=3D or bi=
twise, ...).</font></font></div><div>Because of that this proposal will not=
come around any time soon.<br></div><div><font color=3D"#000000" face=3D"a=
rial, sans-serif" size=3D"2">At the same time demands to check or enforce c=
onstexpr-ness in functions were made through the ideas of <b><i>forced cons=
texpr arguments</i></b> and<i><b> is_constexpr()</b></i>.</font></div><div>=
<ul><li>=C2=A0 =C2=A0The first has the same issues as <b><i>N3413</i></b> a=
s it requires said constexpr arguments be integrated into the mangling of t=
he function, making this proposal syntax sugar to <b><i>N3413</i></b>.</li>=
</ul></div><div><div class=3D"prettyprint" style=3D"background-color: rgb(2=
50, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; borde=
r-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div clas=
s=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//this</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">templa=
te</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Literal</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> l</span><span st=
yle=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-prettify"> func</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">();</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">//differs only through call syntax from this</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> func</span><span style=3D"color: #660;"=
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: #606;" class=3D"styled-by=
-prettify">Literal</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> l</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: #800;" class=3D"styled-by-prettify">//yet this=
would allow to get rid of atrocious code like this</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">auto</span><font color=3D"#000088"><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: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> func</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">integral_constant</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">decltype</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"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: #800;" class=3D"styled-by=
-prettify">//only uses I</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br></span></font></div></code></div></div><div><ul><li>=C2=
=A0 =C2=A0The latter (<i><b>is_constexpr</b></i>) aims to allow a runtime o=
r compile-time specialization<font color=3D"#000000" face=3D"arial, sans-se=
rif">=C2=A0through a constexpr expression with a variant value. It would re=
quires long </font><i style=3D"font-size: small; color: rgb(0, 0, 0); font-=
family: arial, sans-serif;">if constexpr </i><span style=3D"font-size: smal=
l; color: rgb(0, 0, 0); font-family: arial, sans-serif;">blocks</span><i st=
yle=3D"font-size: small; color: rgb(0, 0, 0); font-family: arial, sans-seri=
f;">=C2=A0</i><span style=3D"font-size: small; color: rgb(0, 0, 0); font-fa=
mily: arial, sans-serif;">as, if runtime specialization is required, we can=
assume that the runtime and compile-time version will share very little co=
de. It=C2=A0</span><font color=3D"#000000" face=3D"arial, sans-serif">would=
also mean that, despite the confirmation by the compiler that we are in co=
nstexpr context with arguments being compile-time evaluated, we would still=
be incapable=C2=A0to use those as such or would require that <i><b>if cons=
texp(is_constexpr()) </b></i>have side-effects (big no-no).</font><br></li>=
</ul></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wid=
th: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
onstexpr</span><span style=3D"color: #000;" 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"> func</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
#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: #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 </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">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: #000;" class=3D"styled-by-prettify">is_constexpr</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 =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"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//i is still not usable as a constexpr</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//l=
ong piece of code or call to other function that handles the compile-time v=
ersion</span><span 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: #660;=
" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 </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 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">else</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =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>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify"=
>//long piece of code or call to other function that handles the runtime ve=
rsion</span><span 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: #660;=
" class=3D"styled-by-prettify">....</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><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"><br></span></div></code></div><div><br></div><div>Now that =
the context has been presented here is my proposal with a detailed and comm=
ented exemple.</div><div>My goal is to allow a big chunk of what the other =
proposal aimed to allow without all their issues and in one proposal.</div>=
<div>It is to allow constexpr-only specialization by borrowing the <i><b>no=
except</b></i> syntax.</div><div>As the function may only be constexpr it w=
ill not have linkage and therefor no mangling nor all the issues associated=
with it.</div><div>Now here is a <b>detailed exemple</b>.</div><div><br></=
div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #800;" class=3D"styled-by-prettify">//compil=
e-time only function</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//it will never have linkage</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//all its arguments are constexpr</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">//a non-constexpr expression usage in it=
s definition will cause an error instead of a fallback like normal constexp=
r</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//is only calle=
d in an explicit constexpr context unlike normal constexpr</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">true</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Literal</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> r</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><font color=3D"=
#000000"><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
</font><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">//runtime sp=
ecialization of func</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">/*constexpr(false)*/</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><font color=3D"#000088"><span style=3D"color: #008;" =
class=3D"styled-by-prettify">auto</span></font><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> func</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Literal</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> r</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">//constexpr(=
false) is the default for functions and methods</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">//error redefinition of 'constexpr(f=
alse) void func(Literal)'</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> fu=
nc</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">true</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">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> func2</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">()</span><font color=3D"#000000"><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"style=
d-by-prettify">//allowed</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">//constexpr is ignored, retains inline side effect</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font><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: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> func2</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">()</span><font color=3D"#000000"><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">constexpr</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> func3</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">constexpr</span><span style=3D"color: #000;" 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"> error_0 </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> func3</span><span st=
yle=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">//constexpr specialization of 'fun=
c3' after instanciation</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">constexpr</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>true</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span style=3D"color: #000;" 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"> func3</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span></font><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//addresses demands for partially =
constexpr argument-list</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">constexpr</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">tru=
e</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">void</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> partial_constexpr</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</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"> constant</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><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[&](</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>auto</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
&...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r=
untime_args</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">constexpr</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">/*this lambda has the defau=
lt constexpr behavior*/</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">//runtime code</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0</span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">//can use 'constant' as a=
constexpr here</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>=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-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></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"> main</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> r_0 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">Literal</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">{});</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #800;" class=3D"styled-by-prettify">//constexpr(true) version called=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> r_1 </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> func</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><font color=3D"#000000">=
<span style=3D"color: #606;" class=3D"styled-by-prettify">Literal</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">{});</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">//constexpr(false) version called</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></sp=
an></font><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =
partial_constexpr</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">42=
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*compile-=
time args*/</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)(</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/*runti=
me args*/</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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> r_2 </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n 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"> func</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Literal</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">{});</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//also proposed unary constexpr operator for explicit select=
ion, error if the expression is not constexpr</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">//is equivalent to</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> r_3 </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: #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-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</sp=
an><span style=3D"color: #000;" 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"> __ret__ </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> func</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">Literal</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{});</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">return</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> __ret__</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><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> <br></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></span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//replacing of gnu's operator&quo=
t;" extension</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">constexpr</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">true</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: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">operator</span><span style=3D"color: #080;" cla=
ss=3D"styled-by-prettify">""</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">_string_literal</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">char</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">str</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> size_t len</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></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 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">[&]<</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">size_t</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Indexs</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 s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">index_sequence</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Indexs</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 </=
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</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><font color=3D"#660066"><span style=3D"color: #606;" class=3D"styled-by=
-prettify">TemplateCharSeq</span></font><font color=3D"#666600"><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span></font><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">str</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Indexs</span><span style=3D"color: #660;" c=
lass=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">std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">make_index_sequence</span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify"><len></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{});</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">//operator[] for std::tuple</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">template</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y"><</span><span style=3D"color: #008;" class=3D"styled-by-prettify">cla=
ss</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: #606;" class=3D"styled-by-prettify">Args</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> tuple<br></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"><br>=C2=A0 =C2=A0</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">true</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">aut=
o</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">operator</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">[](</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">size_t i</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: #008;" class=
=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=3D"s=
tyled-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>=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">static_assert</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">i </span><span style=3D"color: #660;" class=3D"st=
yled-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">sizeof</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.=
...(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Args</s=
pan><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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ret=
urn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">get</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify"><i></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(*</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">this</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" clas=
s=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"><br><br>=C2=A0 =C2=A0</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">constexpr</span><font color=3D"#000000">=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">true</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">auto</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: #008;" class=3D"styled-by-prett=
ify">operator</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">[](</span><span style=3D"color: #000;" class=3D"styled-by-prettify">size=
_t i</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></fo=
nt><span style=3D"color: #000;" class=3D"styled-by-prettify">=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"><br>=C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">sta=
tic_assert</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: #008;" class=3D"styled-by-prettify">sizeof</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">...(</span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Args</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">));</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br>=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"> std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">get</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify"><i></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(*</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>this</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> =C2=A0 =C2=
=A0 =C2=A0<br>=C2=A0 =C2=A0</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</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">....</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"><br><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Args</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Sel=
ect</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><font color=3D"#666600"><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: #606;" class=3D"styled-by-prettify">Args</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">ope=
rator</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 sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></font><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">template</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: #00=
8;" class=3D"styled-by-prettify">class</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Args</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: #606;" class=3D"styled-by-prettify">Select</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><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:=
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">Select</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">...>;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">//for lambdas</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
func</span><font color=3D"#666600"><span style=3D"color: #000;" class=3D"st=
yled-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></span></font><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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">con=
stexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> f_0 </span><span s=
tyle=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: #=
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: #800;" class=3D"styled-by-pretti=
fy">//operator() is constexpr /*fallback on runtime*/, no changes</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> f_1 </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: #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-prett=
ify">constexpr</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">false=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">//operator() cannot be called at compile-tim=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">conste=
xpr</span><span style=3D"color: #000;" 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"> f_2 </span><font colo=
r=3D"#666600"><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">[]()</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">constexpr</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">true</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: #800;" class=3D"styled-by-prettify">//operato=
r() can only be called a compile-time and explicitly</span></font><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><font color=3D=
"#000088"><span style=3D"color: #606;" class=3D"styled-by-prettify">Select<=
/span></font><span style=3D"color: #000;" class=3D"styled-by-prettify"> f_3=
</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 st=
yle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> f_1</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> f_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 </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">constexpr</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> r_4 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</spa=
n><font color=3D"#666600"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">_3</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//f_2</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> r_5 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> f_3</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: #800;" class=3D"st=
yled-by-prettify">//f_1</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span></font></div></code></div><div><br></div><div>Here is the su=
mmary:</div><div><br></div><div>- extend constexpr specifier to allow it to=
take a constexpr explicit bool (no a constexpr expression unless if there =
are good use-cases for it) where:</div><div><ul><li>constexpr(false) is the=
default specifier of a function/method</li><ul><li>optional for functions/=
method.</li><li>if specified with lambdas allows not-constexpr lambda as la=
mbdas are by default constexpr.</li></ul><li>constexpr(true) is a constexpr=
only function.</li><ul><li>no Assembly representation (no linkage nor mang=
ling).</li><li>all arguments are constexpr.</li><li>error if non-constexpr =
expression is used (a constexpr fallback to runtime because of an overflow =
for instance).</li><li>only used in explicit constexpr context.</li><li>can=
not be called before its specialization if specialization or else error.<br=
></li></ul><li>constexpr</li><ul><li>keeps all its properties and definitio=
n.</li><li>will still trigger redefinition error if previous constexpr(fals=
e) version previously defined.</li><li>constexpr attribute ignored if previ=
ous constexpr(true) is defined.</li></ul></ul></div><div>- unary constexpr =
operator to request a constexpr expression explicitly:</div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> t </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">constexpr</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> expr</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">//might error if expr is no a constexpr expression</span></div></code></=
div><br>The reason why I believe in this proposal:</div><div><ul><li>no new=
keyword.</li><li>zero runtime impact.</li><li>maintains backward compatibi=
lity.</li><li>solves, at least partially, a lot of different proposals.</li=
></ul><div>Thanks in advance,</div><div><br></div><div>Bastien Penavayre,</=
div></div></div><div>bastienPenava@gmail.com</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/17e156a0-0368-4ec0-a087-e8b4bc8d9f62%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/17e156a0-0368-4ec0-a087-e8b4bc8d9f62=
%40isocpp.org</a>.<br />
------=_Part_1592_697479766.1504205007666--
------=_Part_1591_1795418109.1504205007664--
.