Topic: constexpr if, and a little bit more control
Author: Andrei L <aendaerel@gmail.com>
Date: Wed, 30 Mar 2016 20:20:46 +0500
Raw View
--089e013cb802a35f9c052f45b062
Content-Type: text/plain; charset=UTF-8
2016-03-30 14:04 GMT+05:00 <bruno.manga95@gmail.com>:
> Would that be allowed to work on constexpr function parameters?
I think it's not, because its purpose is to *request* a guarantee that
there will be no run-time.
constexpr int foo (int x)
{
constexpr int j = constexpr (x);
return bar(j);
}
In this case, it is impossible to guarantee that 'x' always will be
constexpr, and i don't think that this is the right way to specify
constexpr-only function.
--
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/CANaLnBrZFUKbUD_90-9O_OX7waZpa1N9YtA_pNOnux00H8qUCw%40mail.gmail.com.
--089e013cb802a35f9c052f45b062
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
2016-03-30 14:04 GMT+05:00 <span dir=3D"ltr"><<a href=3D"mailto:bruno.m=
anga95@gmail.com" target=3D"_blank">bruno.manga95@gmail.com</a>></span>:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left:1px solid rgb(204,204,204);padding-left:1ex">Would that be allowed=
to work on constexpr function parameters?</blockquote></div><br></div><div=
class=3D"gmail_extra">I think it's not, because its purpose is to <i>r=
equest</i> a guarantee that there will be no run-time.<br><br><div style=3D=
"margin-left:40px"><code><span style=3D"color:rgb(0,0,136)">constexpr</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)=
">int</span><span style=3D"color:rgb(0,0,0)"> foo </span><span style=3D"col=
or:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">int</span><sp=
an style=3D"color:rgb(0,0,0)"> x</span><span style=3D"color:rgb(102,102,0)"=
>)</span><span style=3D"color:rgb(0,0,0)"></span></code><br><code><span sty=
le=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(102,102,0)">{</span=
><span style=3D"color:rgb(0,0,0)"></span></code><br><code><span style=3D"co=
lor:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136=
)">constexpr</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,0,0)"> j </span><s=
pan style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0=
)"> </span><span style=3D"color:rgb(0,0,136)">constexpr</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">(</span>=
<span style=3D"color:rgb(0,0,0)">x</span><span style=3D"color:rgb(102,102,0=
)">)</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"colo=
r:rgb(0,0,0)"></span></code><br><code><span style=3D"color:rgb(0,0,0)">=C2=
=A0 =C2=A0 =C2=A0</span><span style=3D"color:rgb(0,0,136)">return</span><sp=
an style=3D"color:rgb(0,0,0)"> bar</span><span style=3D"color:rgb(102,102,0=
)">(</span><span style=3D"color:rgb(0,0,0)">j</span><span style=3D"color:rg=
b(102,102,0)">);</span><span style=3D"color:rgb(0,0,0)"></span></code><br><=
code><span style=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(102,1=
02,0)">}</span><span style=3D"color:rgb(0,0,0)"></span></code><br></div><di=
v style=3D"margin-left:40px"><code><span style=3D"color:rgb(0,0,0)"></span>=
</code></div><br></div><div class=3D"gmail_extra">In this case, it is impos=
sible to guarantee that 'x' always will be constexpr, and i don'=
;t think that this is the right way to specify constexpr-only function.<br>=
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CANaLnBrZFUKbUD_90-9O_OX7waZpa1N9YtA_=
pNOnux00H8qUCw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANaLnBrZFUKbUD_9=
0-9O_OX7waZpa1N9YtA_pNOnux00H8qUCw%40mail.gmail.com</a>.<br />
--089e013cb802a35f9c052f45b062--
.