Topic: template<auto&>
Author: Guillaume Racicot <gufideg@gmail.com>
Date: Sat, 25 Jun 2016 09:14:27 -0700 (PDT)
Raw View
------=_Part_2891_887988895.1466871267830
Content-Type: multipart/alternative;
boundary="----=_Part_2892_1965327228.1466871267830"
------=_Part_2892_1965327228.1466871267830
Content-Type: text/plain; charset=UTF-8
After reading P0127R1
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.html>, I
wondered if auto& as a template parameter is be possible too. It would
allow things like this:
template<auto& thing>
struct Foo {
void display() {
std::cout << "value: " << thing << " address: " << &thing << std::
endl;
}
};
extern int i;
Foo<i> foo;
Is this thing already possible in the current proposal?
--
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/58413fd1-653d-4171-a250-baa99c0a597b%40isocpp.org.
------=_Part_2892_1965327228.1466871267830
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">After reading=C2=A0<a href=3D"http://www.open-std.org/jtc1=
/sc22/wg21/docs/papers/2016/p0127r1.html">P0127R1</a>, I wondered if auto&a=
mp; as a template parameter is be possible too. It would allow things like =
this:<div><br></div><div class=3D"prettyprint" style=3D"border: 1px solid r=
gb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 2=
50);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> thing</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Foo</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> display</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">()</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">cout </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: #080;" cla=
ss=3D"styled-by-prettify">"value: "</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> thing </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"><<</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">" address: "</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-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify">t=
hing </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&=
lt;</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: #000;" class=3D"styled-by-prettify">endl</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </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></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">extern</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-pretti=
fy"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">Foo</span><span=
style=3D"color: #080;" class=3D"styled-by-prettify"><i></span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span></div></code></div><=
div><br></div><div>Is this thing already possible in the current proposal?<=
/div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/58413fd1-653d-4171-a250-baa99c0a597b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/58413fd1-653d-4171-a250-baa99c0a597b=
%40isocpp.org</a>.<br />
------=_Part_2892_1965327228.1466871267830--
------=_Part_2891_887988895.1466871267830--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 25 Jun 2016 10:56:43 -0700 (PDT)
Raw View
------=_Part_205_1149690343.1466877403771
Content-Type: multipart/alternative;
boundary="----=_Part_206_1122936876.1466877403772"
------=_Part_206_1122936876.1466877403772
Content-Type: text/plain; charset=UTF-8
On Saturday, June 25, 2016 at 12:14:28 PM UTC-4, Guillaume Racicot wrote:
>
> After reading P0127R1
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.html>, I
> wondered if auto& as a template parameter is be possible too. It would
> allow things like this:
>
> template<auto& thing>
> struct Foo {
> void display() {
> std::cout << "value: " << thing << " address: " << &thing << std::
> endl;
> }
> };
>
> extern int i;
>
> Foo<i> foo;
>
> Is this thing already possible in the current proposal?
>
No. The paper merely adds deduction of the type of non-type template
parameters based on the value passed. It does not change what valid
non-type template parameters can be.
You couldn't do `template<int &i>` before, so you can't do it now. You can
make it a pointer if you want, but that would require doing `Foo<*i>`.
--
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/2308f718-9fcb-445f-974c-9acc9c0aa605%40isocpp.org.
------=_Part_206_1122936876.1466877403772
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, June 25, 2016 at 12:14:28 PM UTC-4, Guillaume=
Racicot 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=
">After reading=C2=A0<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs=
/papers/2016/p0127r1.html" target=3D"_blank" rel=3D"nofollow" onmousedown=
=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-s=
td.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0127r1.html\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNEYB71CqkjHlBm03Vs5JBamsn2y6A';return tru=
e;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2=
Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0127r1.htm=
l\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYB71CqkjHlBm03Vs5JBamsn2y6A'=
;return true;">P0127R1</a>, I wondered if auto& as a template parameter=
is be possible too. It would allow things like this:<div><br></div><div st=
yle=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-co=
lor:rgb(250,250,250)"><code><div><span style=3D"color:#008">template</span>=
<span style=3D"color:#660"><</span><span style=3D"color:#008">auto</span=
><span style=3D"color:#660">&</span><span style=3D"color:#000"> thing</=
span><span style=3D"color:#660">></span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#008">struct</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#606">Foo</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0=
=C2=A0 </span><span style=3D"color:#008">void</span><span style=3D"color:#=
000"> display</span><span style=3D"color:#660">()</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#00=
0"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"color:#660">::<=
/span><span style=3D"color:#000">cout </span><span style=3D"color:#660"><=
;<</span><span style=3D"color:#000"> </span><span style=3D"color:#080">&=
quot;value: "</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660"><<</span><span style=3D"color:#000"> thing </span><span s=
tyle=3D"color:#660"><<</span><span style=3D"color:#000"> </span><span=
style=3D"color:#080">" address: "</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660"><<</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">&</span><span style=3D"color:#0=
00">thing </span><span style=3D"color:#660"><<</span><span style=3D"c=
olor:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"co=
lor:#000">endl</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#660">}</span><span s=
tyle=3D"color:#000"><br></span><span style=3D"color:#660">};</span><span st=
yle=3D"color:#000"><br><br></span><span style=3D"color:#008">extern</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">int</span><spa=
n style=3D"color:#000"> i</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"><br><br></span><span style=3D"color:#606">Foo</span><spa=
n style=3D"color:#080"><i></span><span style=3D"color:#000"> foo</spa=
n><span style=3D"color:#660">;</span></div></code></div><div><br></div><div=
>Is this thing already possible in the current proposal?</div></div></block=
quote><div><br>No. The paper merely adds deduction of the type of non-type =
template parameters based on the value passed. It does not change what vali=
d non-type template parameters can be.<br><br>You couldn't do `template=
<int &i>`=C2=A0 before, so you can't do it now. You can make =
it a pointer if you want, but that would require doing `Foo<*i>`.<br>=
</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2308f718-9fcb-445f-974c-9acc9c0aa605%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2308f718-9fcb-445f-974c-9acc9c0aa605=
%40isocpp.org</a>.<br />
------=_Part_206_1122936876.1466877403772--
------=_Part_205_1149690343.1466877403771--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 25 Jun 2016 10:57:20 -0700 (PDT)
Raw View
------=_Part_328_13700544.1466877441078
Content-Type: multipart/alternative;
boundary="----=_Part_329_668964024.1466877441078"
------=_Part_329_668964024.1466877441078
Content-Type: text/plain; charset=UTF-8
On Saturday, June 25, 2016 at 1:56:44 PM UTC-4, Nicol Bolas wrote:
>
> You couldn't do `template<int &i>` before, so you can't do it now. You
> can make it a pointer if you want, but that would require doing `Foo<*i>`.
>
I of course meant `Foo<&i>`.
--
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/48621f7a-46f0-4b6f-833c-326ad1c4426e%40isocpp.org.
------=_Part_329_668964024.1466877441078
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br>On Saturday, June 25, 2016 at 1:56:44 PM UTC-4, 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"><=
div>You couldn't do `template<int &i>`=C2=A0 before, so you c=
an't do it now. You can make it a pointer if you want, but that would r=
equire doing `Foo<*i>`.<br></div></div></blockquote><div><br>I of cou=
rse meant `Foo<&i>`. <br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/48621f7a-46f0-4b6f-833c-326ad1c4426e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/48621f7a-46f0-4b6f-833c-326ad1c4426e=
%40isocpp.org</a>.<br />
------=_Part_329_668964024.1466877441078--
------=_Part_328_13700544.1466877441078--
.
Author: "S.B." <i.and.my.little.friends@gmail.com>
Date: Sat, 25 Jun 2016 11:25:38 -0700 (PDT)
Raw View
------=_Part_3120_42272680.1466879138899
Content-Type: multipart/alternative;
boundary="----=_Part_3121_2079464929.1466879138900"
------=_Part_3121_2079464929.1466879138900
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Sunday, June 26, 2016 at 1:56:44 AM UTC+8, Nicol Bolas wrote:
>
> On Saturday, June 25, 2016 at 12:14:28 PM UTC-4, Guillaume Racicot wrote:
>>
>> After reading P0127R1=20
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.html>,=
=20
>> I wondered if auto& as a template parameter is be possible too. It would=
=20
>> allow things like this:
>>
>> template<auto& thing>
>> struct Foo {
>> void display() {
>> std::cout << "value: " << thing << " address: " << &thing << std
>> ::endl;
>> }
>> };
>>
>> extern int i;
>>
>> Foo<i> foo;
>>
>> Is this thing already possible in the current proposal?
>>
>
> No. The paper merely adds deduction of the type of non-type template=20
> parameters based on the value passed. It does not change what valid=20
> non-type template parameters can be.
>
> You couldn't do `template<int &i>` before, so you can't do it now.=20
>
We *could *do `template<int &i>` before.
N4594 =C2=A7 14.1[temp.param]p4
4 A non-type template-parameter shall have one of the following (optionally=
=20
cv-quali=EF=AC=81ed) types:
=E2=80=94 (4.1) integral or enumeration type,
=E2=80=94 (4.2) pointer to object or pointer to function,
*=E2=80=94 (4.3) lvalue reference to object or lvalue reference to function=
,*
=E2=80=94 (4.4) pointer to member,
=E2=80=94 (4.5) std::nullptr_t.
> You can make it a pointer if you want, but that would require doing=20
> `Foo<*i>`.
>
--=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/e52a753b-cbe9-4ff0-b783-ffe4ffffb384%40isocpp.or=
g.
------=_Part_3121_2079464929.1466879138900
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Sunday, June 26, 2016 at 1:56:44 AM UTC+8, Nico=
l Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
>On Saturday, June 25, 2016 at 12:14:28 PM UTC-4, Guillaume Racicot 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">After reading=C2=A0=
<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.=
html" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2F=
wg21%2Fdocs%2Fpapers%2F2016%2Fp0127r1.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x=
3dAFQjCNEYB71CqkjHlBm03Vs5JBamsn2y6A';return true;" onclick=3D"this.hre=
f=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc=
1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0127r1.html\x26sa\x3dD\x26sntz\x3=
d1\x26usg\x3dAFQjCNEYB71CqkjHlBm03Vs5JBamsn2y6A';return true;">P0127R1<=
/a>, I wondered if auto& as a template parameter is be possible too. It=
would allow things like this:<div><br></div><div style=3D"border:1px solid=
rgb(187,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><=
code><div><span style=3D"color:#008">template</span><span style=3D"color:#6=
60"><</span><span style=3D"color:#008">auto</span><span style=3D"color:#=
660">&</span><span style=3D"color:#000"> thing</span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"><br></span><span style=3D"co=
lor:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#606">Foo</span><span style=3D"color:#000"> </span><span style=3D"color=
:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color:#008">void</span><span style=3D"color:#000"> display</span><sp=
an style=3D"color:#660">()</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">cout </span><span style=3D"color:#660"><<</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#080">"value: "</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660"><<<=
/span><span style=3D"color:#000"> thing </span><span style=3D"color:#660">&=
lt;<</span><span style=3D"color:#000"> </span><span style=3D"color:#080"=
>" address: "</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660"><<</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#660">&</span><span style=3D"color:#000">thing </span><spa=
n style=3D"color:#660"><<</span><span style=3D"color:#000"> std</span=
><span style=3D"color:#660">::</span><span style=3D"color:#000">endl</span>=
<span style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 </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><br></span><span style=3D"color:#008">extern</span><span style=3D"color=
:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:#0=
00"> i</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br><br></span><span style=3D"color:#606">Foo</span><span style=3D"color:#0=
80"><i></span><span style=3D"color:#000"> foo</span><span style=3D"co=
lor:#660">;</span></div></code></div><div><br></div><div>Is this thing alre=
ady possible in the current proposal?</div></div></blockquote><div><br>No. =
The paper merely adds deduction of the type of non-type template parameters=
based on the value passed. It does not change what valid non-type template=
parameters can be.<br><br>You couldn't do `template<int &i>`=
=C2=A0 before, so you can't do it now. </div></div></blockquote><div><b=
r>We <b>could </b>do `template<int &i>` before.<br><br>N4594 =C2=
=A7 14.1[temp.param]p4<br>4 A non-type template-parameter shall have one of=
the following (optionally cv-quali=EF=AC=81ed) types:<br>=E2=80=94 (4.1) i=
ntegral or enumeration type,<br>=E2=80=94 (4.2) pointer to object or pointe=
r to function,<br><b>=E2=80=94 (4.3) lvalue reference to object or lvalue r=
eference to function,</b><br>=E2=80=94 (4.4) pointer to member,<br>=E2=80=
=94 (4.5) std::nullptr_t.<br></div><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>You can make it a pointer if you want, but that=
would require doing `Foo<*i>`.<br></div></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e52a753b-cbe9-4ff0-b783-ffe4ffffb384%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e52a753b-cbe9-4ff0-b783-ffe4ffffb384=
%40isocpp.org</a>.<br />
------=_Part_3121_2079464929.1466879138900--
------=_Part_3120_42272680.1466879138899--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sat, 25 Jun 2016 12:00:19 -0700 (PDT)
Raw View
------=_Part_3070_969028084.1466881219333
Content-Type: multipart/alternative;
boundary="----=_Part_3071_1021894798.1466881219334"
------=_Part_3071_1021894798.1466881219334
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Saturday, June 25, 2016 at 2:25:38 PM UTC-4, S.B. wrote:
>
> On Sunday, June 26, 2016 at 1:56:44 AM UTC+8, Nicol Bolas wrote:
>>
>> On Saturday, June 25, 2016 at 12:14:28 PM UTC-4, Guillaume Racicot wrote=
:
>>>
>>> After reading P0127R1=20
>>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0127r1.html>,=
=20
>>> I wondered if auto& as a template parameter is be possible too. It woul=
d=20
>>> allow things like this:
>>>
>>> template<auto& thing>
>>> struct Foo {
>>> void display() {
>>> std::cout << "value: " << thing << " address: " << &thing << st=
d
>>> ::endl;
>>> }
>>> };
>>>
>>> extern int i;
>>>
>>> Foo<i> foo;
>>>
>>> Is this thing already possible in the current proposal?
>>>
>>
>> No. The paper merely adds deduction of the type of non-type template=20
>> parameters based on the value passed. It does not change what valid=20
>> non-type template parameters can be.
>>
>> You couldn't do `template<int &i>` before, so you can't do it now.=20
>>
>
> We *could *do `template<int &i>` before.
>
> N4594 =C2=A7 14.1[temp.param]p4
> 4 A non-type template-parameter shall have one of the following=20
> (optionally cv-quali=EF=AC=81ed) types:
> =E2=80=94 (4.1) integral or enumeration type,
> =E2=80=94 (4.2) pointer to object or pointer to function,
> *=E2=80=94 (4.3) lvalue reference to object or lvalue reference to functi=
on,*
> =E2=80=94 (4.4) pointer to member,
> =E2=80=94 (4.5) std::nullptr_t.
>
>> You can make it a pointer if you want, but that would require doing=20
>> `Foo<*i>`.
>>
>
.... I don't know how I didn't see that the first time I read it.
In which case, `auto&` ought to work.
--=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/84e66a09-6750-4968-856e-a0db36da6eb8%40isocpp.or=
g.
------=_Part_3071_1021894798.1466881219334
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, June 25, 2016 at 2:25:38 PM UTC-4, S.B. wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">On Sunday, J=
une 26, 2016 at 1:56:44 AM UTC+8, Nicol Bolas wrote:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><div dir=3D"ltr">On Saturday, June 25, 2016 at 12:14:28 PM=
UTC-4, Guillaume Racicot wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><di=
v dir=3D"ltr">After reading=C2=A0<a href=3D"http://www.open-std.org/jtc1/sc=
22/wg21/docs/papers/2016/p0127r1.html" rel=3D"nofollow" target=3D"_blank" o=
nmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2F=
www.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0127r1.html=
\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYB71CqkjHlBm03Vs5JBamsn2y6A';=
return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp=
0127r1.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEYB71CqkjHlBm03Vs5JBams=
n2y6A';return true;">P0127R1</a>, I wondered if auto& as a template=
parameter is be possible too. It would allow things like this:<div><br></d=
iv><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;bac=
kground-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">templ=
ate</span><span style=3D"color:#660"><</span><span style=3D"color:#008">=
auto</span><span style=3D"color:#660">&</span><span style=3D"color:#000=
"> thing</span><span style=3D"color:#660">></span><span style=3D"color:#=
000"><br></span><span style=3D"color:#008">struct</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#606">Foo</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> display</span><span style=3D"color:#660">()</span><span st=
yle=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 std</span><span style=3D"co=
lor:#660">::</span><span style=3D"color:#000">cout </span><span style=3D"co=
lor:#660"><<</span><span style=3D"color:#000"> </span><span style=3D"=
color:#080">"value: "</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660"><<</span><span style=3D"color:#000"> thing <=
/span><span style=3D"color:#660"><<</span><span style=3D"color:#000">=
</span><span style=3D"color:#080">" address: "</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660"><<</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">&</span><span styl=
e=3D"color:#000">thing </span><span style=3D"color:#660"><<</span><sp=
an style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><spa=
n style=3D"color:#000">endl</span><span style=3D"color:#660">;</span><span =
style=3D"color:#000"><br>=C2=A0 =C2=A0 </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><br></span><span style=3D"color:#008">e=
xtern</span><span style=3D"color:#000"> </span><span style=3D"color:#008">i=
nt</span><span style=3D"color:#000"> i</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br><br></span><span style=3D"color:#606">F=
oo</span><span style=3D"color:#080"><i></span><span style=3D"color:#0=
00"> foo</span><span style=3D"color:#660">;</span></div></code></div><div><=
br></div><div>Is this thing already possible in the current proposal?</div>=
</div></blockquote><div><br>No. The paper merely adds deduction of the type=
of non-type template parameters based on the value passed. It does not cha=
nge what valid non-type template parameters can be.<br><br>You couldn't=
do `template<int &i>`=C2=A0 before, so you can't do it now. =
</div></div></blockquote><div><br>We <b>could </b>do `template<int &=
i>` before.<br><br>N4594 =C2=A7 14.1[temp.param]p4<br>4 A non-type templ=
ate-parameter shall have one of the following (optionally cv-quali=EF=AC=81=
ed) types:<br>=E2=80=94 (4.1) integral or enumeration type,<br>=E2=80=94 (4=
..2) pointer to object or pointer to function,<br><b>=E2=80=94 (4.3) lvalue =
reference to object or lvalue reference to function,</b><br>=E2=80=94 (4.4)=
pointer to member,<br>=E2=80=94 (4.5) std::nullptr_t.<br></div><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>You can make it a pointe=
r if you want, but that would require doing `Foo<*i>`.<br></div></div=
></blockquote></div></blockquote><div><br>... I don't know how I didn&#=
39;t see that the first time I read it.<br><br>In which case, `auto&` o=
ught to work.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/84e66a09-6750-4968-856e-a0db36da6eb8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/84e66a09-6750-4968-856e-a0db36da6eb8=
%40isocpp.org</a>.<br />
------=_Part_3071_1021894798.1466881219334--
------=_Part_3070_969028084.1466881219333--
.
Author: bekenn@gmail.com
Date: Sat, 25 Jun 2016 21:44:03 -0700 (PDT)
Raw View
------=_Part_3135_826069971.1466916243750
Content-Type: multipart/alternative;
boundary="----=_Part_3136_31351851.1466916243751"
------=_Part_3136_31351851.1466916243751
Content-Type: text/plain; charset=UTF-8
template <auto&> does indeed work and is an intended part of the design.
--
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/f6bb0c9e-34c2-4ddd-9cf4-49d1ea9824a2%40isocpp.org.
------=_Part_3136_31351851.1466916243751
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">template <auto&> does indeed work and is an inte=
nded part of the design.<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f6bb0c9e-34c2-4ddd-9cf4-49d1ea9824a2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f6bb0c9e-34c2-4ddd-9cf4-49d1ea9824a2=
%40isocpp.org</a>.<br />
------=_Part_3136_31351851.1466916243751--
------=_Part_3135_826069971.1466916243750--
.