220 26389 <84e66a09-6750-4968-856e-a0db36da6eb8@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: template<auto&>
Date: Sat, 25 Jun 2016 12:00:19 -0700 (PDT)
Lines: 167
Approved: news@gmane.org
Message-ID: <84e66a09-6750-4968-856e-a0db36da6eb8@isocpp.org>
References: <58413fd1-653d-4171-a250-baa99c0a597b@isocpp.org>
 <2308f718-9fcb-445f-974c-9acc9c0aa605@isocpp.org>
 <e52a753b-cbe9-4ff0-b783-ffe4ffffb384@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3070_969028084.1466881219333"
X-Trace: ger.gmane.org 1466881225 4024 80.91.229.3 (25 Jun 2016 19:00:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 25 Jun 2016 19:00:25 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBRFJXO5QKGQE6KYNPHY@isocpp.org Sat Jun 25 21:00:25 2016
Return-path: <std-proposals+bncBCEKFTV6ZUMBBRFJXO5QKGQE6KYNPHY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBRFJXO5QKGQE6KYNPHY@isocpp.org>)
	id 1bGsoY-0000SF-1n
	for gclcip-std-proposals@m.gmane.org; Sat, 25 Jun 2016 21:00:22 +0200
Original-Received: by mail-ob0-f198.google.com with SMTP id fq2sf242629469obb.2
        for <gclcip-std-proposals@m.gmane.org>; Sat, 25 Jun 2016 12:00:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=uW/coB93z9fkyL04HU0XmgvX86JniHcy/RHI67iSt0k=;
        b=c5v4bgSd3DxZdtUsNLDCziwsAx5CJzH7CZwzRWaM2+wUwxIinPTMgVfMS8Opsb/bMA
         xKJ3426SUwToVJL/fBBNZg7TMrO+UyzIAzvyF9CaXr5vBXzB1UvuXsCvoCNbyyrseuy2
         34IdyGwgmV2laPNn2+4/XGUJ92ggstftwkrKwSW9oZPqt/5x/k8i+KtbtBt1ZIqJ9dYO
         f9LpCfCStRC4bqbVLOs3idNV/IXvYqjWsh6niHCnY/M1TNTOtJkErVuWme46ls7iw3kM
         nf4LW+2fGRnFf40nwWFyvvSqwHZFm/pPQqEU3hfdNH+veW49Fn1YZ9efajszJqRSspJY
         FV2A==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=uW/coB93z9fkyL04HU0XmgvX86JniHcy/RHI67iSt0k=;
        b=dkqhF18XAnXbic5BwJloh+JC+k9N5wnobB6qRRn7WpEZO7uUFPE5oujXuY5i4Z7CF+
         ZMMwN9CT/zT50FNUT1j1WStpJUuzVv763T2NU421uOZqhXr4grFdZWZP7yxruGsYvAvZ
         1pv3n6Y6jWJAVcQTKr62UcNNEglxE8HkTzu9MDbu9sitBMAjX1xl6jD+yUFmRPjkK4sm
         HwBaGoVR+Thck4C8tXYo0PsC4rxI4y1lU2qSxU7Be22HYR7UvIyhRKcW+z9q8DT5u+L0
         HISUWCsIAhVYILdPIIySt6NK7bGyhwt1tEyl6Mgr+Jp+yLwvXBpaF07wTrYl5tAR7n6R
         y0wg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=uW/coB93z9fkyL04HU0XmgvX86JniHcy/RHI67iSt0k=;
        b=YHxItJ+/UAHV2NxkxxS2vG0a7OxNMZIJHSBYOiROt6XHlVoUnhFAhRpBnbH3Vf6Co0
         ufiw7tcfje51OcOzYiZY40bdVRUlTdLTE07NbMylsKhoMXuQDaw2KZ6g1MnYz6t6Gdyq
         ndY6mPhWS5jhAcMqzwEb+W2B+jtDaqam6Apx4cL+iaSNuQqm1CgJAlcysjwjuZ3JXgue
         9sbLQLCOlvJIv8D8NXxDZSS0XA61Z7zC5HkEnoesI+Z6elh38a5TZevsAipW6oFI6SEr
         2y/WkG/wql4xi5fgjUtz0TZbNIBdMLtzQi4g/7J12GnxApvnZuciWdP3foAczkaR62lC
         Hv7g==
X-Gm-Message-State: ALyK8tKUswt5agvV6UHsR1b54WLqHWutYUf/IIMw55V4QqPgJ9Sn9AUXi3UGfyl7TLdUuw==
X-Received: by 10.36.73.170 with SMTP id e42mr4150153itd.4.1466881221057;
        Sat, 25 Jun 2016 12:00:21 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.181.74 with SMTP id e71ls992091iof.27.gmail; Sat, 25 Jun
 2016 12:00:20 -0700 (PDT)
X-Received: by 10.36.127.66 with SMTP id r63mr114339itc.2.1466881220196;
        Sat, 25 Jun 2016 12:00:20 -0700 (PDT)
In-Reply-To: <e52a753b-cbe9-4ff0-b783-ffe4ffffb384@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:26389
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26389>

------=_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&#39;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&#39;;=
return true;" onclick=3D"this.href=3D&#39;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&#39;;return true;">P0127R1</a>, I wondered if auto&amp; 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">&lt;</span><span style=3D"color:#008">=
auto</span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000=
"> thing</span><span style=3D"color:#660">&gt;</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">&lt;&lt;</span><span style=3D"color:#000"> </span><span style=3D"=
color:#080">&quot;value: &quot;</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> thing <=
/span><span style=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000">=
 </span><span style=3D"color:#080">&quot; address: &quot;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">&lt;&lt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">&amp;</span><span styl=
e=3D"color:#000">thing </span><span style=3D"color:#660">&lt;&lt;</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">&lt;i&gt;</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&#39;t=
 do `template&lt;int &amp;i&gt;`=C2=A0 before, so you can&#39;t do it now. =
</div></div></blockquote><div><br>We <b>could </b>do `template&lt;int &amp;=
i&gt;` 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&lt;*i&gt;`.<br></div></div=
></blockquote></div></blockquote><div><br>... I don&#39;t know how I didn&#=
39;t see that the first time I read it.<br><br>In which case, `auto&amp;` 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&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/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--

.
