Topic: Implicit constexpr parameter to template


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Sat, 10 Sep 2016 10:46:00 -0700 (PDT)
Raw View
------=_Part_1016_1459853841.1473529560409
Content-Type: multipart/alternative;
 boundary="----=_Part_1017_488423789.1473529560409"

------=_Part_1017_488423789.1473529560409
Content-Type: text/plain; charset=UTF-8



>
> template<typename ...Ts>
> auto get_tuple(std::tuple<Ts...> &&tpl, constexpr int index)
> {
>   return std::get<index>(std::forward(tpl));
> }
>
>
Why not just:

template <int I>
using int_ = std::integral_constant<int, I>;

template <typename... Ts, int I>
auto get_tuple(std::tuple<Ts...> tpl, int_<I> )
{
    return std::get<I>(tpl);
}

get_tuple(tpl, int_<index>{} );

 Works today, and lets you put your arguments in the order you want.

--
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/d41dac62-5def-4ffc-af4e-30c1482bfd5e%40isocpp.org.

------=_Part_1017_488423789.1473529560409
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><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"><br><div =
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code><div><span st=
yle=3D"color:#008">template</span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#008">typename</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">...</span><span style=3D"color:#606">Ts</span><sp=
an style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">auto</span><span style=3D"color:#000"> get_tuple</=
span><span style=3D"color:#660">(</span><span style=3D"color:#000">std</spa=
n><span style=3D"color:#660">::</span><span style=3D"color:#000">tuple</spa=
n><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">Ts</span=
><span style=3D"color:#660">...&gt;</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000">tp=
l</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">constexpr</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#008">int</span><span style=3D"color:#000"> inde=
x</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=
=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:#00=
0"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#008=
">get</span><span style=3D"color:#080">&lt;index&gt;</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">std</span><span style=3D"colo=
r:#660">::</span><span style=3D"color:#000">forward</span><span style=3D"co=
lor:#660">(</span><span style=3D"color:#000">t<wbr>pl</span><span style=3D"=
color:#660">));</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#660">}</span></div></code></div><br></div></blockquote><div><br></di=
v><div>Why not just:</div><div><br></div><div><div class=3D"prettyprint" st=
yle=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgro=
und-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"s=
ubprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">te=
mplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> I</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">using</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> int_ </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">i=
ntegral_constant</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
int</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> I</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">&gt;;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">typename</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: #606;" class=3D"style=
d-by-prettify">Ts</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: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> I</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> get_tuple</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"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">tuple</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&lt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Ts=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> tpl</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> int_</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">I</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><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: #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: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">I</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&gt;(</span><font color=3D"#000000"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">tpl</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br><br>get_tuple</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">tpl</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> int_</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&l=
t;index&gt;</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></font>=
</div></code></div><br>=C2=A0Works today, and lets you put your arguments i=
n the order you want.=C2=A0</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/d41dac62-5def-4ffc-af4e-30c1482bfd5e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d41dac62-5def-4ffc-af4e-30c1482bfd5e=
%40isocpp.org</a>.<br />

------=_Part_1017_488423789.1473529560409--

------=_Part_1016_1459853841.1473529560409--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 10 Sep 2016 11:07:34 -0700 (PDT)
Raw View
------=_Part_3364_558312152.1473530854288
Content-Type: multipart/alternative;
 boundary="----=_Part_3365_1551633329.1473530854289"

------=_Part_3365_1551633329.1473530854289
Content-Type: text/plain; charset=UTF-8



On Saturday, September 10, 2016 at 1:46:00 PM UTC-4, Barry Revzin wrote:
>
>
>
>> template<typename ...Ts>
>> auto get_tuple(std::tuple<Ts...> &&tpl, constexpr int index)
>> {
>>   return std::get<index>(std::forward(tpl));
>> }
>>
>>
> Why not just:
>
> template <int I>
> using int_ = std::integral_constant<int, I>;
>
> template <typename... Ts, int I>
> auto get_tuple(std::tuple<Ts...> tpl, int_<I> )
> {
>     return std::get<I>(tpl);
> }
>
> get_tuple(tpl, int_<index>{} );
>
>  Works today, and lets you put your arguments in the order you want.
>

The whole point of the idea is to allow you to use `get_tuple(tpl, 1)`. Or
`get_tuple(tpl, some_constexpr_value)`. If the caller has to know that
you're passing a template parameter, then you've failed. If the function
using the parameter has to treat it in any way differently from any other
constexpr variable, then you've failed.

I'm trying to solve the problem which is at the core of the hack-fix you've
suggested.

Furthermore, the real solution would be more general, extensible to any
type which can be a non-type template parameter. For example, there's an
idea of extending non-type template parameters to any literal type. My idea
would instantly mesh with that. Yours would require a generalized form of
`integral_constant`.

--
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/c32292b6-f829-4641-a631-ed662bb4359f%40isocpp.org.

------=_Part_3365_1551633329.1473530854289
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, September 10, 2016 at 1:46:00 PM UTC-=
4, Barry Revzin wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div style=3D"back=
ground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:so=
lid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:=
#008">template</span><span style=3D"color:#660">&lt;</span><span style=3D"c=
olor:#008">typename</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">...</span><span style=3D"color:#606">Ts</span><span style=3D"c=
olor:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"=
color:#008">auto</span><span style=3D"color:#000"> get_tuple</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#000">std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">tuple</span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#606">Ts</span><span style=
=3D"color:#660">...&gt;</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">&amp;&amp;</span><span style=3D"color:#000">tpl</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">int</span><span style=3D"color:#000"> index</span><spa=
n style=3D"color:#660">)</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 </span><=
span style=3D"color:#008">return</span><span style=3D"color:#000"> std</spa=
n><span style=3D"color:#660">::</span><span style=3D"color:#008">get</span>=
<span style=3D"color:#080">&lt;index&gt;</span><span style=3D"color:#660">(=
</span><span style=3D"color:#000">std</span><span style=3D"color:#660">::</=
span><span style=3D"color:#000">forward</span><span style=3D"color:#660">(<=
/span><span style=3D"color:#000">t<wbr>pl</span><span style=3D"color:#660">=
));</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">=
}</span></div></code></div><br></div></blockquote><div><br></div><div>Why n=
ot just:</div><div><br></div><div><div style=3D"border:1px solid rgb(187,18=
7,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><div><=
span style=3D"color:#008">template</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> I</span><span style=3D"color:#660">&gt;</span>=
<span style=3D"color:#000"><br></span><span style=3D"color:#008">using</spa=
n><span style=3D"color:#000"> int_ </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">integral_constant</span><span style=3D"color:=
#660">&lt;</span><span style=3D"color:#008">int</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"> I</span><span style=3D"color:#660=
">&gt;;</span><span style=3D"color:#000"><br><br></span><span style=3D"colo=
r:#008">template</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#660">...</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Ts</span><span style=3D"color:#660">,</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> I</span><span style=3D"color:#660">&gt;</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#008">auto</span><span style=3D"color:=
#000"> get_tuple</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000">std</span><span style=3D"color:#660">::</span><span style=3D"colo=
r:#000">tuple</span><span style=3D"color:#660">&lt;</span><span style=3D"co=
lor:#606">Ts</span><span style=3D"color:#660">...&gt;</span><span style=3D"=
color:#000"> tpl</span><span style=3D"color:#660">,</span><span style=3D"co=
lor:#000"> int_</span><span style=3D"color:#660">&lt;</span><span style=3D"=
color:#000">I</span><span style=3D"color:#660">&gt;</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#660">)</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#00=
0"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><span s=
tyle=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span st=
yle=3D"color:#008">get</span><span style=3D"color:#660">&lt;</span><span st=
yle=3D"color:#000">I</span><span style=3D"color:#660">&gt;(</span><font col=
or=3D"#000000"><span style=3D"color:#000">tpl</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br></span><span style=3D"color:#66=
0">}</span><span style=3D"color:#000"><br><br>get_tuple</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">tpl</span><span style=3D=
"color:#660">,</span><span style=3D"color:#000"> int_</span><span style=3D"=
color:#080">&lt;index&gt;</span><span style=3D"color:#660">{}</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#660">);</span></font></di=
v></code></div><br>=C2=A0Works today, and lets you put your arguments in th=
e order you want.=C2=A0</div></blockquote><div><br>The whole point of the i=
dea is to allow you to use `get_tuple(tpl, 1)`. Or `get_tuple(tpl, some_con=
stexpr_value)`. If the caller has to know that you&#39;re passing a templat=
e parameter, then you&#39;ve failed. If the function using the parameter ha=
s to treat it in any way differently from any other constexpr variable, the=
n you&#39;ve failed.<br><br>I&#39;m trying to solve the problem which is at=
 the core of the hack-fix you&#39;ve suggested.<br><br>Furthermore, the rea=
l solution would be more general, extensible to any type which can be a non=
-type template parameter. For example, there&#39;s an idea of extending non=
-type template parameters to any literal type. My idea would instantly mesh=
 with that. Yours would require a generalized form of `integral_constant`.<=
br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/c32292b6-f829-4641-a631-ed662bb4359f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c32292b6-f829-4641-a631-ed662bb4359f=
%40isocpp.org</a>.<br />

------=_Part_3365_1551633329.1473530854289--

------=_Part_3364_558312152.1473530854288--

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Mon, 12 Sep 2016 14:46:37 -0700
Raw View
--001a114dd0e842ac79053c566e81
Content-Type: text/plain; charset=UTF-8

On Sat, Sep 10, 2016 at 7:56 AM, Nicol Bolas <jmckesson@gmail.com> wrote:

> Consider the following code:
>
> template<typename ...Ts>
> auto get_tuple(std::tuple<Ts...> &&tpl, int index)
> {
>   return std::get<index>(std::forward(tpl));
> }
>
> This is, of course, not legal. And for good reason: the return value of
> this function would have to be able to *change* based on the parameter
> you pass. That's very un-function-like behavior.
>
> But we do have a way to do that. We instead make `index` a non-type
> template parameter:
>
> template<int index, typename ...Ts>
> auto get_tuple(std::tuple<Ts...> &&tpl)
> {
>   return std::get<index>(std::forward(tpl));
> }
>
> However, this forces us to call the function via `get_tuple<index>(tpl)`.
> And while this obviously works, it's sub-optimal visually.
>
> So I suggest making the following possible:
>
> template<typename ...Ts>
> auto get_tuple(std::tuple<Ts...> &&tpl, constexpr int index)
> {
>   return std::get<index>(std::forward(tpl));
> }
>

I remember from various conferences that this has been desired/requested
even since before C++11 was finalized -- a certain population in the C++
community would very much like to see *something* akin to this, myself
included. I wasn't participating in the committee back then and I don't
know the exact rationale for why it wasn't pursued, though it could end up
getting hairy once you get into the details of it. How would this play with
overload resolution (the existence of ADL might make this a question that
needs to be addressed somehow rather than strictly disallowed)? Would it be
possible to somehow perfect-forward to such a function? Would it be
possible to form a pointer or reference to a specific instantiation of such
a function? There are certainly answers to these questions, though they are
not necessarily obvious. It might also just be that there hasn't been a
proposal that hammered out the details, in which case I'd encourage you to
write such a paper.

Another thing to consider -- using constexpr in the parameter list seems to
somewhat imply an implicit template, which a lot of people don't like. By
that I mean each different int value in your example would imply a
different function being instantiated, whether we call it a template or
not. Maybe modules will change people's feelings about that, though.

Anyway, please investigate further. I would very much like to see a
proposal for something like this, especially if it would allow me to
overload as follows:

void foo( int );
void foo( constexpr int );

I have a feeling that it would be very difficult for this to get through
committee, though.

--
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/CANh8DE%3DN0C2n7%3DPRn-_xB2CqL1qK2zfu4ON6bt-zki9CO732Kw%40mail.gmail.com.

--001a114dd0e842ac79053c566e81
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
at, Sep 10, 2016 at 7:56 AM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</s=
pan> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Consider the=
 following code:<br><br><div class=3D"m_-7898042140200578273prettyprint" st=
yle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bord=
er-style:solid;border-width:1px;word-wrap:break-word"><code class=3D"m_-789=
8042140200578273prettyprint"><div class=3D"m_-7898042140200578273subprettyp=
rint"><span style=3D"color:#008" class=3D"m_-7898042140200578273styled-by-p=
rettify">template</span><span style=3D"color:#660" class=3D"m_-789804214020=
0578273styled-by-prettify">&lt;</span><span style=3D"color:#008" class=3D"m=
_-7898042140200578273styled-by-prettify">typename</span><span style=3D"colo=
r:#000" class=3D"m_-7898042140200578273styled-by-prettify"> </span><span st=
yle=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">...</=
span><span style=3D"color:#606" class=3D"m_-7898042140200578273styled-by-pr=
ettify">Ts</span><span style=3D"color:#660" class=3D"m_-7898042140200578273=
styled-by-prettify">&gt;</span><span style=3D"color:#000" class=3D"m_-78980=
42140200578273styled-by-prettify"><br></span><span style=3D"color:#008" cla=
ss=3D"m_-7898042140200578273styled-by-prettify">auto</span><span style=3D"c=
olor:#000" class=3D"m_-7898042140200578273styled-by-prettify"> get_tuple</s=
pan><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-pre=
ttify">(</span><span style=3D"color:#000" class=3D"m_-7898042140200578273st=
yled-by-prettify">std</span><span style=3D"color:#660" class=3D"m_-78980421=
40200578273styled-by-prettify">::</span><span style=3D"color:#000" class=3D=
"m_-7898042140200578273styled-by-prettify">tuple</span><span style=3D"color=
:#660" class=3D"m_-7898042140200578273styled-by-prettify">&lt;</span><span =
style=3D"color:#606" class=3D"m_-7898042140200578273styled-by-prettify">Ts<=
/span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-p=
rettify">...&gt;</span><span style=3D"color:#000" class=3D"m_-7898042140200=
578273styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-78=
98042140200578273styled-by-prettify">&amp;&amp;</span><span style=3D"color:=
#000" class=3D"m_-7898042140200578273styled-by-prettify">tpl</span><span st=
yle=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">,</sp=
an><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-pret=
tify"> </span><span style=3D"color:#008" class=3D"m_-7898042140200578273sty=
led-by-prettify">int</span><span style=3D"color:#000" class=3D"m_-789804214=
0200578273styled-by-prettify"> index</span><span style=3D"color:#660" class=
=3D"m_-7898042140200578273styled-by-prettify">)</span><span style=3D"color:=
#000" class=3D"m_-7898042140200578273styled-by-prettify"><br></span><span s=
tyle=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">{</s=
pan><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-pre=
ttify"><br>=C2=A0 </span><span style=3D"color:#008" class=3D"m_-78980421402=
00578273styled-by-prettify">return</span><span style=3D"color:#000" class=
=3D"m_-7898042140200578273styled-by-prettify"> std</span><span style=3D"col=
or:#660" class=3D"m_-7898042140200578273styled-by-prettify">::</span><span =
style=3D"color:#008" class=3D"m_-7898042140200578273styled-by-prettify">get=
</span><span style=3D"color:#080" class=3D"m_-7898042140200578273styled-by-=
prettify">&lt;index&gt;</span><span style=3D"color:#660" class=3D"m_-789804=
2140200578273styled-by-prettify">(</span><span style=3D"color:#000" class=
=3D"m_-7898042140200578273styled-by-prettify">std</span><span style=3D"colo=
r:#660" class=3D"m_-7898042140200578273styled-by-prettify">::</span><span s=
tyle=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify">forw=
ard</span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-=
by-prettify">(</span><span style=3D"color:#000" class=3D"m_-789804214020057=
8273styled-by-prettify">t<wbr>pl</span><span style=3D"color:#660" class=3D"=
m_-7898042140200578273styled-by-prettify">));</span><span style=3D"color:#0=
00" class=3D"m_-7898042140200578273styled-by-prettify"><br></span><span sty=
le=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">}</spa=
n></div></code></div><br>This is, of course, not legal. And for good reason=
: the return value of this function would have to be able to <i>change</i> =
based on the parameter you pass. That&#39;s very un-function-like behavior.=
<br><br>But we do have a way to do that. We instead make `index` a non-type=
 template parameter:<br><br><div class=3D"m_-7898042140200578273prettyprint=
" 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"m_=
-7898042140200578273prettyprint"><div class=3D"m_-7898042140200578273subpre=
ttyprint"><span style=3D"color:#008" class=3D"m_-7898042140200578273styled-=
by-prettify">template</span><span style=3D"color:#660" class=3D"m_-78980421=
40200578273styled-by-prettify">&lt;</span><span style=3D"color:#008" class=
=3D"m_-7898042140200578273styled-by-prettify">int</span><span style=3D"colo=
r:#000" class=3D"m_-7898042140200578273styled-by-prettify"> index</span><sp=
an style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">=
,</span><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by=
-prettify"> </span><span style=3D"color:#008" class=3D"m_-78980421402005782=
73styled-by-prettify">typename</span><span style=3D"color:#000" class=3D"m_=
-7898042140200578273styled-by-prettify"> </span><span style=3D"color:#660" =
class=3D"m_-7898042140200578273styled-by-prettify">...</span><span style=3D=
"color:#606" class=3D"m_-7898042140200578273styled-by-prettify">Ts</span><s=
pan style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify"=
>&gt;</span><span style=3D"color:#000" class=3D"m_-7898042140200578273style=
d-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_-7898042140=
200578273styled-by-prettify">auto</span><span style=3D"color:#000" class=3D=
"m_-7898042140200578273styled-by-prettify"> get_tuple</span><span style=3D"=
color:#660" class=3D"m_-7898042140200578273styled-by-prettify">(</span><spa=
n style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify">s=
td</span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-b=
y-prettify">::</span><span style=3D"color:#000" class=3D"m_-789804214020057=
8273styled-by-prettify">tuple</span><span style=3D"color:#660" class=3D"m_-=
7898042140200578273styled-by-prettify">&lt;</span><span style=3D"color:#606=
" class=3D"m_-7898042140200578273styled-by-prettify">Ts</span><span style=
=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">...&gt;<=
/span><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-p=
rettify"> </span><span style=3D"color:#660" class=3D"m_-7898042140200578273=
styled-by-prettify">&amp;&amp;</span><span style=3D"color:#000" class=3D"m_=
-7898042140200578273styled-by-prettify">tpl</span><span style=3D"color:#660=
" class=3D"m_-7898042140200578273styled-by-prettify">)</span><span style=3D=
"color:#000" class=3D"m_-7898042140200578273styled-by-prettify"><br></span>=
<span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettif=
y">{</span><span style=3D"color:#000" class=3D"m_-7898042140200578273styled=
-by-prettify"><br>=C2=A0 </span><span style=3D"color:#008" class=3D"m_-7898=
042140200578273styled-by-prettify">return</span><span style=3D"color:#000" =
class=3D"m_-7898042140200578273styled-by-prettify"> std</span><span style=
=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">::</span=
><span style=3D"color:#008" class=3D"m_-7898042140200578273styled-by-pretti=
fy">get</span><span style=3D"color:#080" class=3D"m_-7898042140200578273sty=
led-by-prettify">&lt;index&gt;</span><span style=3D"color:#660" class=3D"m_=
-7898042140200578273styled-by-prettify">(</span><span style=3D"color:#000" =
class=3D"m_-7898042140200578273styled-by-prettify">std</span><span style=3D=
"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">::</span><s=
pan style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify"=
>forward</span><span style=3D"color:#660" class=3D"m_-7898042140200578273st=
yled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_-7898042140=
200578273styled-by-prettify">t<wbr>pl</span><span style=3D"color:#660" clas=
s=3D"m_-7898042140200578273styled-by-prettify">));</span><span style=3D"col=
or:#000" class=3D"m_-7898042140200578273styled-by-prettify"><br></span><spa=
n style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">}=
</span></div></code></div><br>However, this forces us to call the function =
via `get_tuple&lt;index&gt;(tpl)`. And while this obviously works, it&#39;s=
 sub-optimal visually.<br><br>So I suggest making the following possible:<b=
r><br><div class=3D"m_-7898042140200578273prettyprint" style=3D"background-=
color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bor=
der-width:1px;word-wrap:break-word"><code class=3D"m_-7898042140200578273pr=
ettyprint"><div class=3D"m_-7898042140200578273subprettyprint"><span style=
=3D"color:#008" class=3D"m_-7898042140200578273styled-by-prettify">template=
</span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-=
prettify">&lt;</span><span style=3D"color:#008" class=3D"m_-789804214020057=
8273styled-by-prettify">typename</span><span style=3D"color:#000" class=3D"=
m_-7898042140200578273styled-by-prettify"> </span><span style=3D"color:#660=
" class=3D"m_-7898042140200578273styled-by-prettify">...</span><span style=
=3D"color:#606" class=3D"m_-7898042140200578273styled-by-prettify">Ts</span=
><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-pretti=
fy">&gt;</span><span style=3D"color:#000" class=3D"m_-7898042140200578273st=
yled-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_-7898042=
140200578273styled-by-prettify">auto</span><span style=3D"color:#000" class=
=3D"m_-7898042140200578273styled-by-prettify"> get_tuple</span><span style=
=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">(</span>=
<span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettif=
y">std</span><span style=3D"color:#660" class=3D"m_-7898042140200578273styl=
ed-by-prettify">::</span><span style=3D"color:#000" class=3D"m_-78980421402=
00578273styled-by-prettify">tuple</span><span style=3D"color:#660" class=3D=
"m_-7898042140200578273styled-by-prettify">&lt;</span><span style=3D"color:=
#606" class=3D"m_-7898042140200578273styled-by-prettify">Ts</span><span sty=
le=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">...&gt=
;</span><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by=
-prettify"> </span><span style=3D"color:#660" class=3D"m_-78980421402005782=
73styled-by-prettify">&amp;&amp;</span><span style=3D"color:#000" class=3D"=
m_-7898042140200578273styled-by-prettify">tpl</span><span style=3D"color:#6=
60" class=3D"m_-7898042140200578273styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify"> </span>=
<span style=3D"color:#008" class=3D"m_-7898042140200578273styled-by-prettif=
y">constexpr</span><span style=3D"color:#000" class=3D"m_-78980421402005782=
73styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-789804=
2140200578273styled-by-prettify">int</span><span style=3D"color:#000" class=
=3D"m_-7898042140200578273styled-by-prettify"> index</span><span style=3D"c=
olor:#660" class=3D"m_-7898042140200578273styled-by-prettify">)</span><span=
 style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify"><b=
r></span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-b=
y-prettify">{</span><span style=3D"color:#000" class=3D"m_-7898042140200578=
273styled-by-prettify"><br>=C2=A0 </span><span style=3D"color:#008" class=
=3D"m_-7898042140200578273styled-by-prettify">return</span><span style=3D"c=
olor:#000" class=3D"m_-7898042140200578273styled-by-prettify"> std</span><s=
pan style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify"=
>::</span><span style=3D"color:#008" class=3D"m_-7898042140200578273styled-=
by-prettify">get</span><span style=3D"color:#080" class=3D"m_-7898042140200=
578273styled-by-prettify">&lt;index&gt;</span><span style=3D"color:#660" cl=
ass=3D"m_-7898042140200578273styled-by-prettify">(</span><span style=3D"col=
or:#000" class=3D"m_-7898042140200578273styled-by-prettify">std</span><span=
 style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-prettify">::=
</span><span style=3D"color:#000" class=3D"m_-7898042140200578273styled-by-=
prettify">forward</span><span style=3D"color:#660" class=3D"m_-789804214020=
0578273styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_-7=
898042140200578273styled-by-prettify">t<wbr>pl</span><span style=3D"color:#=
660" class=3D"m_-7898042140200578273styled-by-prettify">));</span><span sty=
le=3D"color:#000" class=3D"m_-7898042140200578273styled-by-prettify"><br></=
span><span style=3D"color:#660" class=3D"m_-7898042140200578273styled-by-pr=
ettify">}</span></div></code></div></div></blockquote></div><br></div><div =
class=3D"gmail_extra">I remember from various conferences that this has bee=
n desired/requested even since before C++11 was finalized -- a certain popu=
lation in the C++ community would very much like to see *something* akin to=
 this, myself included. I wasn&#39;t participating in the committee back th=
en and I don&#39;t know the exact rationale for why it wasn&#39;t pursued, =
though it could end up getting hairy once you get into the details of it. H=
ow would this play with overload resolution (the existence of ADL might mak=
e this a question that needs to be addressed somehow rather than strictly d=
isallowed)? Would it be possible to somehow perfect-forward to such a funct=
ion? Would it be possible to form a pointer or reference to a specific inst=
antiation of such a function? There are certainly answers to these question=
s, though they are not necessarily obvious. It might also just be that ther=
e hasn&#39;t been a proposal that hammered out the details, in which case I=
&#39;d encourage you to write such a paper.</div><div class=3D"gmail_extra"=
><br></div><div class=3D"gmail_extra">Another thing to consider -- using co=
nstexpr in the parameter list seems to somewhat imply an implicit template,=
 which a lot of people don&#39;t like. By that I mean each different int va=
lue in your example would imply a different function being instantiated, wh=
ether we call it a template or not. Maybe modules will change people&#39;s =
feelings about that, though.</div><div class=3D"gmail_extra"><br></div><div=
 class=3D"gmail_extra">Anyway, please investigate further. I would very muc=
h like to see a proposal for something like this, especially if it would al=
low me to overload as follows:</div><div class=3D"gmail_extra"><br></div><d=
iv class=3D"gmail_extra">void foo( int );</div><div class=3D"gmail_extra">v=
oid foo( constexpr int );</div><div class=3D"gmail_extra"><br></div><div cl=
ass=3D"gmail_extra">I have a feeling that it would be very difficult for th=
is to get through committee, though.</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/CANh8DE%3DN0C2n7%3DPRn-_xB2CqL1qK2zfu=
4ON6bt-zki9CO732Kw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh8DE%3DN0C=
2n7%3DPRn-_xB2CqL1qK2zfu4ON6bt-zki9CO732Kw%40mail.gmail.com</a>.<br />

--001a114dd0e842ac79053c566e81--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 12 Sep 2016 14:54:16 -0700
Raw View
--001a1146cf46a17ad9053c56897f
Content-Type: text/plain; charset=UTF-8

On Mon, Sep 12, 2016 at 2:46 PM, 'Matt Calabrese' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

> On Sat, Sep 10, 2016 at 7:56 AM, Nicol Bolas <jmckesson@gmail.com> wrote:
>
>> Consider the following code:
>>
>> template<typename ...Ts>
>> auto get_tuple(std::tuple<Ts...> &&tpl, int index)
>> {
>>   return std::get<index>(std::forward(tpl));
>> }
>>
>> This is, of course, not legal. And for good reason: the return value of
>> this function would have to be able to *change* based on the parameter
>> you pass. That's very un-function-like behavior.
>>
>> But we do have a way to do that. We instead make `index` a non-type
>> template parameter:
>>
>> template<int index, typename ...Ts>
>> auto get_tuple(std::tuple<Ts...> &&tpl)
>> {
>>   return std::get<index>(std::forward(tpl));
>> }
>>
>> However, this forces us to call the function via `get_tuple<index>(tpl)`.
>> And while this obviously works, it's sub-optimal visually.
>>
>> So I suggest making the following possible:
>>
>> template<typename ...Ts>
>> auto get_tuple(std::tuple<Ts...> &&tpl, constexpr int index)
>> {
>>   return std::get<index>(std::forward(tpl));
>> }
>>
>
> I remember from various conferences that this has been desired/requested
> even since before C++11 was finalized -- a certain population in the C++
> community would very much like to see *something* akin to this, myself
> included. I wasn't participating in the committee back then and I don't
> know the exact rationale for why it wasn't pursued, though it could end up
> getting hairy once you get into the details of it. How would this play with
> overload resolution (the existence of ADL might make this a question that
> needs to be addressed somehow rather than strictly disallowed)? Would it be
> possible to somehow perfect-forward to such a function? Would it be
> possible to form a pointer or reference to a specific instantiation of such
> a function? There are certainly answers to these questions, though they are
> not necessarily obvious. It might also just be that there hasn't been a
> proposal that hammered out the details, in which case I'd encourage you to
> write such a paper.
>
> Another thing to consider -- using constexpr in the parameter list seems
> to somewhat imply an implicit template, which a lot of people don't like.
> By that I mean each different int value in your example would imply a
> different function being instantiated, whether we call it a template or
> not. Maybe modules will change people's feelings about that, though.
>
> Anyway, please investigate further. I would very much like to see a
> proposal for something like this, especially if it would allow me to
> overload as follows:
>
> void foo( int );
> void foo( constexpr int );
>
> I have a feeling that it would be very difficult for this to get through
> committee, though.
>

If you go forward with a paper on this, I'd like to see discussion of
examples like the following:

int *f(constexpr int n) {
  static int k[n];
  return &k;
}

Do f(0) and f(1) return the same pointer? Likewise:

auto g(constexpr int n) {
  struct S { int arr[n]; };
  return S{};
}

Do g(0) and g(1) have the same return type? Do these answers change if 'n'
is not used in the formation of the type?

And here:

template<int n> struct X { template<typename T> struct Y {}; };
void h(constexpr int n) {
  X<n>::Y<int> xy; // 'template' keyword required here?
}

Essentially, the question is: to what extent are these
functions-with-constexpr-parameters like function templates, and to what
extent are they like regular functions?

--
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/CAOfiQqmj2FY%3Dx2Ocd8DO8zKtqjFK7zQi2JqAOg8UZdb32U2V4A%40mail.gmail.com.

--001a1146cf46a17ad9053c56897f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Sep 12, 2016 at 2:46 PM, &#39;Matt Calabrese&#39; via ISO C++ Standard =
- Future Proposals <span dir=3D"ltr">&lt;<a href=3D"mailto:std-proposals@is=
ocpp.org" target=3D"_blank">std-proposals@isocpp.org</a>&gt;</span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D""><div cl=
ass=3D"gmail_extra"><div class=3D"gmail_quote">On Sat, Sep 10, 2016 at 7:56=
 AM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto:jmckesson@gmail.co=
m" target=3D"_blank">jmckesson@gmail.com</a>&gt;</span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex"><div dir=3D"ltr">Consider the following code:<br><br>=
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">template</span><span style=3D"color:#660">&lt;</spa=
n><span style=3D"color:#008">typename</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#660">...</span><span style=3D"color:#606">Ts</spa=
n><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></sp=
an><span style=3D"color:#008">auto</span><span style=3D"color:#000"> get_tu=
ple</span><span style=3D"color:#660">(</span><span style=3D"color:#000">std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#000">tuple=
</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">Ts<=
/span><span style=3D"color:#660">...&gt;</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#00=
0">tpl</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
 </span><span style=3D"color:#008">int</span><span style=3D"color:#000"> in=
dex</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=
=C2=A0 </span><span style=3D"color:#008">return</span><span style=3D"color:=
#000"> std</span><span style=3D"color:#660">::</span><span style=3D"color:#=
008">get</span><span style=3D"color:#080">&lt;index&gt;</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">std</span><span style=3D=
"color:#660">::</span><span style=3D"color:#000">forward</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">t<wbr>pl</span><span sty=
le=3D"color:#660">));</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#660">}</span></div></code></div><br>This is, of course, not le=
gal. And for good reason: the return value of this function would have to b=
e able to <i>change</i> based on the parameter you pass. That&#39;s very un=
-function-like behavior.<br><br>But we do have a way to do that. We instead=
 make `index` a non-type template parameter:<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;b=
order-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008"=
>template</span><span style=3D"color:#660">&lt;</span><span style=3D"color:=
#008">int</span><span style=3D"color:#000"> index</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#00=
8">typename</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">...</span><span style=3D"color:#606">Ts</span><span style=3D"color:#66=
0">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">auto</span><span style=3D"color:#000"> get_tuple</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">std</span><span style=3D"colo=
r:#660">::</span><span style=3D"color:#000">tuple</span><span style=3D"colo=
r:#660">&lt;</span><span style=3D"color:#606">Ts</span><span style=3D"color=
:#660">...&gt;</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">&amp;&amp;</span><span style=3D"color:#000">tpl</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 </span><span =
style=3D"color:#008">return</span><span style=3D"color:#000"> std</span><sp=
an style=3D"color:#660">::</span><span style=3D"color:#008">get</span><span=
 style=3D"color:#080">&lt;index&gt;</span><span style=3D"color:#660">(</spa=
n><span style=3D"color:#000">std</span><span style=3D"color:#660">::</span>=
<span style=3D"color:#000">forward</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000">t<wbr>pl</span><span style=3D"color:#660">));</=
span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</sp=
an></div></code></div><br>However, this forces us to call the function via =
`get_tuple&lt;index&gt;(tpl)`. And while this obviously works, it&#39;s sub=
-optimal visually.<br><br>So I suggest making the following possible:<br><b=
r><div 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><div><=
span style=3D"color:#008">template</span><span style=3D"color:#660">&lt;</s=
pan><span style=3D"color:#008">typename</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">...</span><span style=3D"color:#606">Ts</s=
pan><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></=
span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> get_=
tuple</span><span style=3D"color:#660">(</span><span style=3D"color:#000">s=
td</span><span style=3D"color:#660">::</span><span style=3D"color:#000">tup=
le</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#606">T=
s</span><span style=3D"color:#660">...&gt;</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">&amp;&amp;</span><span style=3D"color:#=
000">tpl</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">constexpr</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000=
"> index</span><span style=3D"color:#660">)</span><span style=3D"color:#000=
"><br></span><span style=3D"color:#660">{</span><span style=3D"color:#000">=
<br>=C2=A0 </span><span style=3D"color:#008">return</span><span style=3D"co=
lor:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#008">get</span><span style=3D"color:#080">&lt;index&gt;</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">forward</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">t<wbr>pl</span><span s=
tyle=3D"color:#660">));</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#660">}</span></div></code></div></div></blockquote></div><br=
></div></span><div class=3D"gmail_extra">I remember from various conference=
s that this has been desired/requested even since before C++11 was finalize=
d -- a certain population in the C++ community would very much like to see =
*something* akin to this, myself included. I wasn&#39;t participating in th=
e committee back then and I don&#39;t know the exact rationale for why it w=
asn&#39;t pursued, though it could end up getting hairy once you get into t=
he details of it. How would this play with overload resolution (the existen=
ce of ADL might make this a question that needs to be addressed somehow rat=
her than strictly disallowed)? Would it be possible to somehow perfect-forw=
ard to such a function? Would it be possible to form a pointer or reference=
 to a specific instantiation of such a function? There are certainly answer=
s to these questions, though they are not necessarily obvious. It might als=
o just be that there hasn&#39;t been a proposal that hammered out the detai=
ls, in which case I&#39;d encourage you to write such a paper.</div><div cl=
ass=3D"gmail_extra"><br></div><div class=3D"gmail_extra">Another thing to c=
onsider -- using constexpr in the parameter list seems to somewhat imply an=
 implicit template, which a lot of people don&#39;t like. By that I mean ea=
ch different int value in your example would imply a different function bei=
ng instantiated, whether we call it a template or not. Maybe modules will c=
hange people&#39;s feelings about that, though.</div><div class=3D"gmail_ex=
tra"><br></div><div class=3D"gmail_extra">Anyway, please investigate furthe=
r. I would very much like to see a proposal for something like this, especi=
ally if it would allow me to overload as follows:</div><div class=3D"gmail_=
extra"><br></div><div class=3D"gmail_extra">void foo( int );</div><div clas=
s=3D"gmail_extra">void foo( constexpr int );</div><div class=3D"gmail_extra=
"><br></div><div class=3D"gmail_extra">I have a feeling that it would be ve=
ry difficult for this to get through committee, though.</div></div></blockq=
uote><div><br></div><div>If you go forward with a paper on this, I&#39;d li=
ke to see discussion of examples like the following:</div><div><br></div><d=
iv>int *f(constexpr int n) {</div><div>=C2=A0 static int k[n];</div><div>=
=C2=A0 return &amp;k;</div><div>}</div><div><br></div><div>Do f(0) and f(1)=
 return the same pointer? Likewise:</div><div><br></div><div>auto g(constex=
pr int n) {</div><div>=C2=A0 struct S { int arr[n]; };</div><div>=C2=A0 ret=
urn S{};</div><div>}</div><div><br></div><div>Do g(0) and g(1) have the sam=
e return type? Do these answers change if &#39;n&#39; is not used in the fo=
rmation of the type?</div><div><br></div><div>And here:</div><div><br></div=
><div>template&lt;int n&gt; struct X { template&lt;typename T&gt; struct Y =
{}; };</div><div>void h(constexpr int n) {</div><div>=C2=A0 X&lt;n&gt;::Y&l=
t;int&gt; xy; // &#39;template&#39; keyword required here?</div><div>}</div=
><div><br></div><div>Essentially, the question is: to what extent are these=
 functions-with-constexpr-parameters like function templates, and to what e=
xtent are they like regular functions?</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&quot; 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/CAOfiQqmj2FY%3Dx2Ocd8DO8zKtqjFK7zQi2J=
qAOg8UZdb32U2V4A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmj2FY%3D=
x2Ocd8DO8zKtqjFK7zQi2JqAOg8UZdb32U2V4A%40mail.gmail.com</a>.<br />

--001a1146cf46a17ad9053c56897f--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 12 Sep 2016 16:59:43 -0700 (PDT)
Raw View
------=_Part_1346_1031544636.1473724783730
Content-Type: multipart/alternative;
 boundary="----=_Part_1347_249304175.1473724783730"

------=_Part_1347_249304175.1473724783730
Content-Type: text/plain; charset=UTF-8

On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>
> Essentially, the question is: to what extent are these
> functions-with-constexpr-parameters like function templates, and to what
> extent are they like regular functions?
>

They should be in every way like template functions. That's the basis of
the idea: it's pure syntactic sugar.

Though I realize that it's probably better for the transformation to be
from this:

void f(int x, constexpr int y);

to this:

template<int y> void f(int x, int = int());

This way, the declaration looks like a function of two parameters, so the
transformation should be as well. But if you call it without specifying
that template parameter, then template argument deduction takes over and
hijacks it. If you specify the template parameter directly, then the second
parameter is ignored by the implementation.

--
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/53c0c762-b39a-4b99-8a68-68d7591cbc87%40isocpp.org.

------=_Part_1347_249304175.1473724783730
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard=
 Smith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div><div class=3D"gmail_quote"><div>Essentially, the question is: to what =
extent are these functions-with-constexpr-<wbr>parameters like function tem=
plates, and to what extent are they like regular functions?</div></div></di=
v></div></blockquote><div><br>They should be in every way like template fun=
ctions. That&#39;s the basis of the idea: it&#39;s pure syntactic sugar.<br=
><br>Though I realize that it&#39;s probably better for the transformation =
to be from this:<br><br><div class=3D"prettyprint" style=3D"background-colo=
r: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: soli=
d; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> f</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"> x</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span></div></code></div><br>to this:<br><br><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"subprettyprint"><span style=3D"color: =
#008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> y</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">vo=
id</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> f</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">());</span></div></cod=
e></div><br>This way, the declaration looks like a function of two paramete=
rs, so the transformation should be as well. But if you call it without spe=
cifying that template parameter, then template argument deduction takes ove=
r and hijacks it. If you specify the template parameter directly, then the =
second parameter is ignored by the implementation.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/53c0c762-b39a-4b99-8a68-68d7591cbc87%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/53c0c762-b39a-4b99-8a68-68d7591cbc87=
%40isocpp.org</a>.<br />

------=_Part_1347_249304175.1473724783730--

------=_Part_1346_1031544636.1473724783730--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 12 Sep 2016 17:44:33 -0700
Raw View
--94eb2c0853709d25a9053c58ea89
Content-Type: text/plain; charset=UTF-8

On Mon, Sep 12, 2016 at 4:59 PM, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>
>> Essentially, the question is: to what extent are these
>> functions-with-constexpr-parameters like function templates, and to what
>> extent are they like regular functions?
>>
>
> They should be in every way like template functions. That's the basis of
> the idea: it's pure syntactic sugar.
>

I expect you'll see some resistance over this. There's already been
resistance to the concepts TS for the same reason ('auto' parameters
implicitly turning functions into function templates, and particularly
concept-names doing the same with no syntactic marker at all). But we'll
see.

Do you intend to relax the restrictions on non-type template parameter
types for this? That would reopen a can of worms...

Though I realize that it's probably better for the transformation to be
> from this:
>
> void f(int x, constexpr int y);
>
> to this:
>
> template<int y> void f(int x, int = int());
>
> This way, the declaration looks like a function of two parameters, so the
> transformation should be as well. But if you call it without specifying
> that template parameter, then template argument deduction takes over and
> hijacks it. If you specify the template parameter directly, then the second
> parameter is ignored by the implementation.
>
> --
> 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/53c0c762-b39a-4b99-
> 8a68-68d7591cbc87%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/53c0c762-b39a-4b99-8a68-68d7591cbc87%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/CAOfiQqnRLdJyRDphcNm2xMhQhj%3DvvsM1f-eB%3DxDax6aV%3D3Hp5w%40mail.gmail.com.

--94eb2c0853709d25a9053c58ea89
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On M=
on, Sep 12, 2016 at 4:59 PM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</s=
pan> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=
=3D"">On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=
=3D"gmail_quote"><div>Essentially, the question is: to what extent are thes=
e functions-with-constexpr-param<wbr>eters like function templates, and to =
what extent are they like regular functions?</div></div></div></div></block=
quote></span><div><br>They should be in every way like template functions. =
That&#39;s the basis of the idea: it&#39;s pure syntactic sugar.<br></div><=
/div></blockquote><div><br></div><div>I expect you&#39;ll see some resistan=
ce over this. There&#39;s already been resistance to the concepts TS for th=
e same reason (&#39;auto&#39; parameters implicitly turning functions into =
function templates, and particularly concept-names doing the same with no s=
yntactic marker at all). But we&#39;ll see.</div><div><br></div><div>Do you=
 intend to relax the restrictions on non-type template parameter types for =
this? That would reopen a can of worms...</div><div><br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div dir=3D"ltr"><div>Though I realize that it&#39;s prob=
ably better for the transformation to be from this:<br><br><div style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"colo=
r:#008">void</span><span style=3D"color:#000"> f</span><span style=3D"color=
:#660">(</span><span style=3D"color:#008">int</span><span style=3D"color:#0=
00"> x</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
 </span><span style=3D"color:#008">constexpr</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000">=
 y</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br=
></span></div></code></div><br>to this:<br><br><div style=3D"background-col=
or:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border=
-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">temp=
late</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008"=
>int</span><span style=3D"color:#000"> y</span><span style=3D"color:#660">&=
gt;</span><span style=3D"color:#000"> </span><span style=3D"color:#008">voi=
d</span><span style=3D"color:#000"> f</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#008">int</span><span style=3D"color:#000"> x</spa=
n><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">int</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#008">int</span><span style=3D"color:#660">());</span></div></c=
ode></div><br>This way, the declaration looks like a function of two parame=
ters, so the transformation should be as well. But if you call it without s=
pecifying that template parameter, then template argument deduction takes o=
ver and hijacks it. If you specify the template parameter directly, then th=
e second parameter is ignored by the implementation.<br></div></div><span c=
lass=3D"">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/53c0c762-b39a-4b99-8a68-68d7591cbc87%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/53c0=
c762-b39a-4b99-<wbr>8a68-68d7591cbc87%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/CAOfiQqnRLdJyRDphcNm2xMhQhj%3DvvsM1f-=
eB%3DxDax6aV%3D3Hp5w%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqnRLd=
JyRDphcNm2xMhQhj%3DvvsM1f-eB%3DxDax6aV%3D3Hp5w%40mail.gmail.com</a>.<br />

--94eb2c0853709d25a9053c58ea89--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 12 Sep 2016 22:44:00 -0700 (PDT)
Raw View
------=_Part_1412_1828485317.1473745440632
Content-Type: multipart/alternative;
 boundary="----=_Part_1413_1024332849.1473745440632"

------=_Part_1413_1024332849.1473745440632
Content-Type: text/plain; charset=UTF-8



On Monday, September 12, 2016 at 8:44:36 PM UTC-4, Richard Smith wrote:
>
> On Mon, Sep 12, 2016 at 4:59 PM, Nicol Bolas <jmck...@gmail.com
> <javascript:>> wrote:
>
>> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>>
>>> Essentially, the question is: to what extent are these
>>> functions-with-constexpr-parameters like function templates, and to what
>>> extent are they like regular functions?
>>>
>>
>> They should be in every way like template functions. That's the basis of
>> the idea: it's pure syntactic sugar.
>>
>
> I expect you'll see some resistance over this. There's already been
> resistance to the concepts TS for the same reason ('auto' parameters
> implicitly turning functions into function templates, and particularly
> concept-names doing the same with no syntactic marker at all). But we'll
> see.
>

There's already a thread about providing a specific syntax for terse
templates
<https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/TXpr3f03-BI>,
presumably in reaction to these concerns. My idea can piggy back off of
that just as effectively as it does off of Concepts TS's terse templates.

I don't mind if I have to write `template<> void foo(constexpr int x);`.
What matters is that when I call it, I can use `foo(5)` rather than
`foo<5>()`.

Sure, if neither happens and there's no template form that implicitly adds
template arguments from a parameter list, then obviously this form of that
wouldn't be allowed either.

Do you intend to relax the restrictions on non-type template parameter
> types for this? That would reopen a can of worms...
>

The idea is merely a syntactic transform. Therefore, the limits of the
final form are what define the limits on the initial form. If we expand the
permitted types for non-type template parameters, then they'll work just as
well with this syntax.

--
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/45ac77c5-f6c3-4205-8137-95ab1fbea590%40isocpp.org.

------=_Part_1413_1024332849.1473745440632
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, September 12, 2016 at 8:44:36 PM UTC-4,=
 Richard Smith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><div class=3D"gmail_quote">On Mon, Sep 12, 2016 at 4:59 PM, N=
icol Bolas <span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" =
gdf-obfuscated-mailto=3D"WMhl5B03FgAJ" rel=3D"nofollow" onmousedown=3D"this=
..href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;">jmck...@gmail.com</a>&gt;</span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><span>On Monday, September 12, =
2016 at 5:54:19 PM UTC-4, Richard Smith wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>Essentiall=
y, the question is: to what extent are these functions-with-constexpr-<wbr>=
parameters like function templates, and to what extent are they like regula=
r functions?</div></div></div></div></blockquote></span><div><br>They shoul=
d be in every way like template functions. That&#39;s the basis of the idea=
: it&#39;s pure syntactic sugar.<br></div></div></blockquote><div><br></div=
><div>I expect you&#39;ll see some resistance over this. There&#39;s alread=
y been resistance to the concepts TS for the same reason (&#39;auto&#39; pa=
rameters implicitly turning functions into function templates, and particul=
arly concept-names doing the same with no syntactic marker at all). But we&=
#39;ll see.</div></div></div></div></blockquote><div><br>There&#39;s alread=
y a thread about <a href=3D"https://groups.google.com/a/isocpp.org/forum/#!=
topic/std-proposals/TXpr3f03-BI">providing a specific syntax for terse temp=
lates</a>, presumably in reaction to these concerns. My idea can piggy back=
 off of that just as effectively as it does off of Concepts TS&#39;s terse =
templates.<br><br>I don&#39;t mind if I have to write `template&lt;&gt; voi=
d foo(constexpr int x);`. What matters is that when I call it, I can use `f=
oo(5)` rather than `foo&lt;5&gt;()`.<br><br>Sure, if neither happens and th=
ere&#39;s no template form that implicitly adds template arguments from a p=
arameter list, then obviously this form of that wouldn&#39;t be allowed eit=
her.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><div><div class=3D"gmail_quote"><div></div><div>Do you intend to relax=
 the restrictions on non-type template parameter types for this? That would=
 reopen a can of worms...</div></div></div></div></blockquote><div><br>The =
idea is merely a syntactic transform. Therefore, the limits of the final fo=
rm are what define the limits on the initial form. If we expand the permitt=
ed types for non-type template parameters, then they&#39;ll work just as we=
ll with this syntax.</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/45ac77c5-f6c3-4205-8137-95ab1fbea590%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/45ac77c5-f6c3-4205-8137-95ab1fbea590=
%40isocpp.org</a>.<br />

------=_Part_1413_1024332849.1473745440632--

------=_Part_1412_1828485317.1473745440632--

.


Author: inkwizytoryankes@gmail.com
Date: Tue, 13 Sep 2016 05:35:10 -0700 (PDT)
Raw View
------=_Part_406_919760418.1473770110973
Content-Type: multipart/alternative;
 boundary="----=_Part_407_168803409.1473770110974"

------=_Part_407_168803409.1473770110974
Content-Type: text/plain; charset=UTF-8



On Tuesday, September 13, 2016 at 7:44:01 AM UTC+2, Nicol Bolas wrote:
>
>
>
> On Monday, September 12, 2016 at 8:44:36 PM UTC-4, Richard Smith wrote:
>>
>> On Mon, Sep 12, 2016 at 4:59 PM, Nicol Bolas <jmck...@gmail.com> wrote:
>>
>>> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>>>
>>>> Essentially, the question is: to what extent are these
>>>> functions-with-constexpr-parameters like function templates, and to what
>>>> extent are they like regular functions?
>>>>
>>>
>>> They should be in every way like template functions. That's the basis of
>>> the idea: it's pure syntactic sugar.
>>>
>>
>> I expect you'll see some resistance over this. There's already been
>> resistance to the concepts TS for the same reason ('auto' parameters
>> implicitly turning functions into function templates, and particularly
>> concept-names doing the same with no syntactic marker at all). But we'll
>> see.
>>
>
> There's already a thread about providing a specific syntax for terse
> templates
> <https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/TXpr3f03-BI>,
> presumably in reaction to these concerns. My idea can piggy back off of
> that just as effectively as it does off of Concepts TS's terse templates.
>
> I don't mind if I have to write `template<> void foo(constexpr int x);`.
> What matters is that when I call it, I can use `foo(5)` rather than
> `foo<5>()`.
>
> Sure, if neither happens and there's no template form that implicitly adds
> template arguments from a parameter list, then obviously this form of that
> wouldn't be allowed either.
>
> Do you intend to relax the restrictions on non-type template parameter
>> types for this? That would reopen a can of worms...
>>
>
> The idea is merely a syntactic transform. Therefore, the limits of the
> final form are what define the limits on the initial form. If we expand the
> permitted types for non-type template parameters, then they'll work just as
> well with this syntax.
>

I think better would be use of UDL:

template<int I>
int foo(std::value_t<I>, int b)
{
  static int tab[I] = { };
  return tab[b]++;
}
template<int I>
void bar(std::value_t<I> a)
{
    auto t = 15v + 5v * a; // or `std::value_v<15 + 5 * I>`.
    foo(t, a + 10); //type of second arg is `int`.
}

int main()
{
    auto x = foo(10v, 5);
    bar(3v);
}


--
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/20a1a8f1-05db-4d62-afb5-63bbf6634f3e%40isocpp.org.

------=_Part_407_168803409.1473770110974
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, September 13, 2016 at 7:44:01 AM UTC+2=
, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><br><br>On Monday, September 12, 2016 at 8:44:36 PM UTC-4, Richard=
 Smith wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-lef=
t:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>=
<div class=3D"gmail_quote">On Mon, Sep 12, 2016 at 4:59 PM, Nicol Bolas <sp=
an dir=3D"ltr">&lt;<a rel=3D"nofollow">jmck...@gmail.com</a>&gt;</span> wro=
te:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span>On Monday, Sep=
tember 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><di=
v>Essentially, the question is: to what extent are these functions-with-con=
stexpr-<wbr>parameters like function templates, and to what extent are they=
 like regular functions?</div></div></div></div></blockquote></span><div><b=
r>They should be in every way like template functions. That&#39;s the basis=
 of the idea: it&#39;s pure syntactic sugar.<br></div></div></blockquote><d=
iv><br></div><div>I expect you&#39;ll see some resistance over this. There&=
#39;s already been resistance to the concepts TS for the same reason (&#39;=
auto&#39; parameters implicitly turning functions into function templates, =
and particularly concept-names doing the same with no syntactic marker at a=
ll). But we&#39;ll see.</div></div></div></div></blockquote><div><br>There&=
#39;s already a thread about <a href=3D"https://groups.google.com/a/isocpp.=
org/forum/#!topic/std-proposals/TXpr3f03-BI" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org=
/forum/#!topic/std-proposals/TXpr3f03-BI&#39;;return true;" onclick=3D"this=
..href=3D&#39;https://groups.google.com/a/isocpp.org/forum/#!topic/std-propo=
sals/TXpr3f03-BI&#39;;return true;">providing a specific syntax for terse t=
emplates</a>, presumably in reaction to these concerns. My idea can piggy b=
ack off of that just as effectively as it does off of Concepts TS&#39;s ter=
se templates.<br><br>I don&#39;t mind if I have to write `template&lt;&gt; =
void foo(constexpr int x);`. What matters is that when I call it, I can use=
 `foo(5)` rather than `foo&lt;5&gt;()`.<br><br>Sure, if neither happens and=
 there&#39;s no template form that implicitly adds template arguments from =
a parameter list, then obviously this form of that wouldn&#39;t be allowed =
either.<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><div><div class=3D"gmail_quote"><div></div><div>Do you intend to relax t=
he restrictions on non-type template parameter types for this? That would r=
eopen a can of worms...</div></div></div></div></blockquote><div><br>The id=
ea is merely a syntactic transform. Therefore, the limits of the final form=
 are what define the limits on the initial form. If we expand the permitted=
 types for non-type template parameters, then they&#39;ll work just as well=
 with this syntax.</div></div></blockquote><div><br>I think better would be=
 use of UDL:<br><br><div class=3D"prettyprint" style=3D"background-color: r=
gb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; b=
order-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">template</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> I</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">value_t</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">I</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">static</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tab=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span><s=
pan 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">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </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 =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> tab</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">[</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">]++;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">template</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> I</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> bar</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</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: #000;" class=3D"sty=
led-by-prettify">value_t</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">I</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =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"> t </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"st=
yled-by-prettify">15v</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: #066;" class=3D"styled-by-prettify">5v</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> a</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: #800;" class=3D"styled-by-pre=
ttify">// or `std::value_v&lt;15 + 5 * I&gt;`.</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 foo</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"> a </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">+</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">10</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">//type of second arg is `int=
`.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">10v</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">5</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 bar</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">3v</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span></div></code></div><br><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/20a1a8f1-05db-4d62-afb5-63bbf6634f3e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/20a1a8f1-05db-4d62-afb5-63bbf6634f3e=
%40isocpp.org</a>.<br />

------=_Part_407_168803409.1473770110974--

------=_Part_406_919760418.1473770110973--

.


Author: Giovanni Piero Deretta <gpderetta@gmail.com>
Date: Tue, 13 Sep 2016 05:44:46 -0700 (PDT)
Raw View
------=_Part_317_1856969568.1473770686130
Content-Type: multipart/alternative;
 boundary="----=_Part_318_2124604105.1473770686130"

------=_Part_318_2124604105.1473770686130
Content-Type: text/plain; charset=UTF-8

On Tuesday, September 13, 2016 at 12:59:44 AM UTC+1, Nicol Bolas wrote:
>
> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>
>> Essentially, the question is: to what extent are these
>> functions-with-constexpr-parameters like function templates, and to what
>> extent are they like regular functions?
>>
>
> They should be in every way like template functions. That's the basis of
> the idea: it's pure syntactic sugar.
>
>
The idea is nice, the problem is that only a small subset of literal types
can be used as non-type template parameters. As generalizing non type
template parameters to any literal type has been shot down multiple times
by the committee, defining this feature as pure syntactic sugar would
hinder further evolution.

-- gpd

--
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/83112bb7-90b3-4e9f-960d-a919077978df%40isocpp.org.

------=_Part_318_2124604105.1473770686130
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, September 13, 2016 at 12:59:44 AM UTC+1, Nicol=
 Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gma=
il_quote"><div>Essentially, the question is: to what extent are these funct=
ions-with-constexpr-<wbr>parameters like function templates, and to what ex=
tent are they like regular functions?</div></div></div></div></blockquote><=
div><br>They should be in every way like template functions. That&#39;s the=
 basis of the idea: it&#39;s pure syntactic sugar.<br><br></div></div></blo=
ckquote><div><br>The idea is nice, the problem is that only a small subset =
of literal types can be used as non-type template parameters. As generalizi=
ng non type template parameters to any literal type has been shot down mult=
iple times by the committee, defining this feature as pure syntactic sugar =
would hinder further evolution.<br><br>-- gpd<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/83112bb7-90b3-4e9f-960d-a919077978df%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/83112bb7-90b3-4e9f-960d-a919077978df=
%40isocpp.org</a>.<br />

------=_Part_318_2124604105.1473770686130--

------=_Part_317_1856969568.1473770686130--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 13 Sep 2016 07:14:57 -0700 (PDT)
Raw View
------=_Part_191_341218757.1473776097952
Content-Type: multipart/alternative;
 boundary="----=_Part_192_71392631.1473776097952"

------=_Part_192_71392631.1473776097952
Content-Type: text/plain; charset=UTF-8

On Tuesday, September 13, 2016 at 8:44:46 AM UTC-4, Giovanni Piero Deretta
wrote:
>
> On Tuesday, September 13, 2016 at 12:59:44 AM UTC+1, Nicol Bolas wrote:
>>
>> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>>
>>> Essentially, the question is: to what extent are these
>>> functions-with-constexpr-parameters like function templates, and to what
>>> extent are they like regular functions?
>>>
>>
>> They should be in every way like template functions. That's the basis of
>> the idea: it's pure syntactic sugar.
>>
>>
> The idea is nice, the problem is that only a small subset of literal types
> can be used as non-type template parameters. As generalizing non type
> template parameters to any literal type has been shot down multiple times
> by the committee, defining this feature as pure syntactic sugar would
> hinder further evolution.
>

But that's the only way to make a constexpr parameter work. The behavior of
a function, including the static types it uses, can change depending on the
constexpr parameter it uses. That's the whole point. And doing that
requires either invoking template machinery or defining a whole new kind of
template-like construct.

So whatever reasons the committee had for preventing the use of general
literal types as non-type template parameters would apply just as well for
`constexpr` parameters.

--
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/04cd8448-8bf6-4dc5-a057-56354e045786%40isocpp.org.

------=_Part_192_71392631.1473776097952
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, September 13, 2016 at 8:44:46 AM UTC-4, Giovan=
ni Piero Deretta wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr">On Tuesday, September 13, 2016 at 12:59:44 AM UTC+1, Nicol Bolas =
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">On Monday, S=
eptember 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><d=
iv>Essentially, the question is: to what extent are these functions-with-co=
nstexpr-<wbr>parameters like function templates, and to what extent are the=
y like regular functions?</div></div></div></div></blockquote><div><br>They=
 should be in every way like template functions. That&#39;s the basis of th=
e idea: it&#39;s pure syntactic sugar.<br><br></div></div></blockquote><div=
><br>The idea is nice, the problem is that only a small subset of literal t=
ypes can be used as non-type template parameters. As generalizing non type =
template parameters to any literal type has been shot down multiple times b=
y the committee, defining this feature as pure syntactic sugar would hinder=
 further evolution.<br></div></div></blockquote><div><br>But that&#39;s the=
 only way to make a constexpr parameter work. The behavior of a function, i=
ncluding the static types it uses, can change depending on the constexpr pa=
rameter it uses. That&#39;s the whole point. And doing that requires either=
 invoking template machinery or defining a whole new kind of template-like =
construct.<br><br>So whatever reasons the committee had for preventing the =
use of general literal types as non-type template parameters would apply ju=
st as well for `constexpr` parameters.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/04cd8448-8bf6-4dc5-a057-56354e045786%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/04cd8448-8bf6-4dc5-a057-56354e045786=
%40isocpp.org</a>.<br />

------=_Part_192_71392631.1473776097952--

------=_Part_191_341218757.1473776097952--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Tue, 13 Sep 2016 17:32:47 -0700 (PDT)
Raw View
------=_Part_27_1726370325.1473813167688
Content-Type: multipart/alternative;
 boundary="----=_Part_28_567535280.1473813167688"

------=_Part_28_567535280.1473813167688
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Tuesday, September 13, 2016 at 7:14:58 AM UTC-7, Nicol Bolas wrote:
>
> On Tuesday, September 13, 2016 at 8:44:46 AM UTC-4, Giovanni Piero Derett=
a=20
> wrote:
>>
>> On Tuesday, September 13, 2016 at 12:59:44 AM UTC+1, Nicol Bolas wrote:
>>>
>>> On Monday, September 12, 2016 at 5:54:19 PM UTC-4, Richard Smith wrote:
>>>>
>>>> Essentially, the question is: to what extent are these=20
>>>> functions-with-constexpr-parameters like function templates, and to wh=
at=20
>>>> extent are they like regular functions?
>>>>
>>>
>>> They should be in every way like template functions. That's the basis o=
f=20
>>> the idea: it's pure syntactic sugar.
>>>
>>>
>> The idea is nice, the problem is that only a small subset of literal=20
>> types can be used as non-type template parameters. As generalizing non t=
ype=20
>> template parameters to any literal type has been shot down multiple time=
s=20
>> by the committee, defining this feature as pure syntactic sugar would=20
>> hinder further evolution.
>>
>
> But that's the only way to make a constexpr parameter work. The behavior=
=20
> of a function, including the static types it uses, can change depending o=
n=20
> the constexpr parameter it uses. That's the whole point. And doing that=
=20
> requires either invoking template machinery or defining a whole new kind =
of=20
> template-like construct.
>
> So whatever reasons the committee had for preventing the use of general=
=20
> literal types as non-type template parameters would apply just as well fo=
r=20
> `constexpr` parameters.
>

For the record:
For a type to be useable as a constexpr parameter (i.e. to be a literal=20
type), the compiler must be able to *manipulate* values of the type at=20
compile-time.
For a type to be useable as a non-type template parameter, the type must=20
support identity-comparison in some meaningful sense, and also, the=20
compiler must be able to *stringify* values of the type at compile-time (in=
=20
a whole-program-consistent 1:1 way such that identity-equal values=20
stringify to bytewise-equal strings).

That's so that we can name-mangle foo<MyFirstValue> differently from=20
foo<MySecondValue>, and also so that we can call foo<MyFirstValue> from a=
=20
translation unit where it's declared-but-not-defined, define it in another=
=20
separately compiled translation unit, and still get the linker to resolve=
=20
the reference correctly.

Notice I'm saying "identity-comparison" instead of "equality-comparison" or=
=20
"operator=3D=3D"; for example you can use *references* as non-type template=
=20
parameters, even though operator=3D=3D for references does something differ=
ent=20
from identity-comparison.  Whereas, type double supports operator=3D=3D but=
=20
does not cleanly support identity-comparison, thanks to negative zero and=
=20
the multitude of NaN values; so it's *not* allowed as a non-type template=
=20
parameter.

Tough problems like "is type T stringifiable" and "what does identity=20
comparison mean for type T" are what's holding up string-literal template=
=20
parameters, among other things.  I naively imagine that most of the=20
committee is sympathetic to the *end goal* of literal values as non-type=20
template parameters; but that doesn't magically make it *implementable*.=20
There's still the tough problems to solve, first.

=E2=80=93Arthur

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/840ad250-14af-4a5b-ae06-ae15ae0b52be%40isocpp.or=
g.

------=_Part_28_567535280.1473813167688
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, September 13, 2016 at 7:14:58 AM UTC-7, Nicol =
Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">O=
n Tuesday, September 13, 2016 at 8:44:46 AM UTC-4, Giovanni Piero Deretta w=
rote:<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">On Tuesday, S=
eptember 13, 2016 at 12:59:44 AM UTC+1, Nicol Bolas wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">On Monday, September 12, 2016 at 5:=
54:19 PM UTC-4, Richard Smith 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"><div><div class=3D"gmail_quote"><div>Essentially, the que=
stion is: to what extent are these functions-with-constexpr-<wbr>parameters=
 like function templates, and to what extent are they like regular function=
s?</div></div></div></div></blockquote><div><br>They should be in every way=
 like template functions. That&#39;s the basis of the idea: it&#39;s pure s=
yntactic sugar.<br><br></div></div></blockquote><div><br>The idea is nice, =
the problem is that only a small subset of literal types can be used as non=
-type template parameters. As generalizing non type template parameters to =
any literal type has been shot down multiple times by the committee, defini=
ng this feature as pure syntactic sugar would hinder further evolution.<br>=
</div></div></blockquote><div><br>But that&#39;s the only way to make a con=
stexpr parameter work. The behavior of a function, including the static typ=
es it uses, can change depending on the constexpr parameter it uses. That&#=
39;s the whole point. And doing that requires either invoking template mach=
inery or defining a whole new kind of template-like construct.<br><br>So wh=
atever reasons the committee had for preventing the use of general literal =
types as non-type template parameters would apply just as well for `constex=
pr` parameters.<br></div></div></blockquote><div><br></div><div>For the rec=
ord:</div><div>For a type to be useable as a constexpr parameter (i.e. to b=
e a literal type), the compiler must be able to <i>manipulate</i> values of=
 the type at compile-time.</div><div>For a type to be useable as a non-type=
 template parameter, the type must support identity-comparison in some mean=
ingful sense, and also, the compiler must be able to <i>stringify</i> value=
s of the type at compile-time (in a whole-program-consistent 1:1 way such t=
hat identity-equal values stringify to bytewise-equal strings).</div><div><=
br></div><div>That&#39;s so that we can name-mangle foo&lt;MyFirstValue&gt;=
 differently from foo&lt;MySecondValue&gt;, and also so that we can call fo=
o&lt;MyFirstValue&gt; from a translation unit where it&#39;s declared-but-n=
ot-defined, define it in another separately compiled translation unit, and =
still get the linker to resolve the reference correctly.</div><div><br></di=
v><div><div>Notice I&#39;m saying &quot;identity-comparison&quot; instead o=
f &quot;equality-comparison&quot; or &quot;operator=3D=3D&quot;; for exampl=
e you can use=C2=A0<i>references</i>=C2=A0as non-type template parameters, =
even though=C2=A0<font face=3D"courier new, monospace">operator=3D=3D</font=
>=C2=A0for references does something different from identity-comparison. =
=C2=A0Whereas, type=C2=A0<font face=3D"courier new, monospace">double</font=
>=C2=A0supports=C2=A0<font face=3D"courier new, monospace">operator=3D=3D</=
font>=C2=A0but does not cleanly support identity-comparison, thanks to nega=
tive zero and the multitude of NaN values; so it&#39;s=C2=A0<i>not</i>=C2=
=A0allowed as a non-type template parameter.</div></div><div><br></div><div=
>Tough problems like &quot;is type T stringifiable&quot; and &quot;what doe=
s identity comparison mean for type T&quot; are what&#39;s holding up strin=
g-literal template parameters, among other things. =C2=A0I naively imagine =
that most of the committee is sympathetic to the <i>end goal</i> of literal=
 values as non-type template parameters; but that doesn&#39;t magically mak=
e it <i>implementable</i>. There&#39;s still the tough problems to solve, f=
irst.</div><div><br></div><div>=E2=80=93Arthur</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; 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/840ad250-14af-4a5b-ae06-ae15ae0b52be%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/840ad250-14af-4a5b-ae06-ae15ae0b52be=
%40isocpp.org</a>.<br />

------=_Part_28_567535280.1473813167688--

------=_Part_27_1726370325.1473813167688--

.