Topic: Questions about P0091: Template argument


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

On Sun, Jul 10, 2016 at 12:34 AM, TONGARI J <tongari95@gmail.com> wrote:

> P0091 is voted into C++17, but for outsiders it's unclear what
> decisions/changes has been made since:
>
> ** What's the syntax settled for explicit deduction guides?*
>
> The proposed syntax in P0091R2 is:
>     *template < template-parameter-list > class-name (
> parameter-declaration-clause ) -> simple-template-id*
>
> The author also listed some alternatives and left the decision to the
> committee, what's the committee's decision?
>

The proposed syntax was accepted.


> Is it possible for a syntax that doesn't require us to repeat the
> class-name twice, e.g:
>     *template-parameter-list > simple-template-id auto(
> parameter-declaration-clause )*
>
> template<typename Iter>
> vector<typename iterator_traits<Iter>::value_type> auto(Iter b, Iter e);
>

There is no support for such a syntax.


> ** Are non-template explicit deduction guides allowed?*
>
> template<class T>
> struct S
> {
>     S(T);
> };
>
> S(char const*) -> S<std::string>;
>
> S s{"hello"}; // deduced to S<std::string>
>

Yes, this is permitted.

** Does the deduction work for aggregates?*
>
> template<class A, class B>
> struct Agg
> {
>     A a;
>     B b;
> };
>
> Agg agg{1, 2.0}; // ok? deduced to Agg<int, double>
>

No, you can't do that; the deduction only considers constructors. This
seems like a reasonable extension, though.


> If the above doesn't work, will explicit deduction guides help?
>
> template<class A, class B>
> Agg(A a, B b) -> Agg<A, B>;
>

Yes, that should work.

--
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/CAOfiQqmGcF359uMD%3Dvu%3DMnZGwFaJH%2B_zbr98j8zG9E8ya1SRNg%40mail.gmail.com.

--001a1149b7e8ffa1af05376330e8
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=
un, Jul 10, 2016 at 12:34 AM, TONGARI J <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:tongari95@gmail.com" target=3D"_blank">tongari95@gmail.com</a>&gt;</sp=
an> 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"><div>P0091 is=
 voted into C++17, but for outsiders it&#39;s unclear what decisions/change=
s has been made since:</div><div><br></div><div><b>* What&#39;s the syntax =
settled for explicit deduction guides?</b></div><div><br></div><div>The pro=
posed syntax in P0091R2 is:</div><div>=C2=A0 =C2=A0 <i>template &lt; templa=
te-parameter-list &gt; class-name ( parameter-declaration-clause ) -&gt; si=
mple-template-id</i></div><div><i><br></i></div><div>The author also listed=
 some alternatives and left the decision to the committee, what&#39;s the c=
ommittee&#39;s decision?</div></div></blockquote><div><br></div><div>The pr=
oposed syntax was accepted.</div><div>=C2=A0</div><blockquote class=3D"gmai=
l_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left=
:1ex"><div dir=3D"ltr"><div>Is it possible for a syntax that doesn&#39;t re=
quire us to repeat the class-name twice, e.g:</div><div>=C2=A0 =C2=A0=C2=A0=
<i>template-parameter-list &gt; simple-template-id auto( parameter-declarat=
ion-clause )</i></div><div><br></div><div style=3D"border:1px solid rgb(187=
,187,187);word-wrap:break-word;background-color:rgb(250,250,250)"><code><di=
v><span style=3D"color:#008">template</span><span style=3D"color:#660">&lt;=
</span><span style=3D"color:#008">typename</span><span style=3D"color:#000"=
> </span><span style=3D"color:#606">Iter</span><span style=3D"color:#660">&=
gt;</span><span style=3D"color:#000"><br>vector</span><span style=3D"color:=
#660">&lt;</span><span style=3D"color:#008">typename</span><span style=3D"c=
olor:#000"> iterator_traits</span><span style=3D"color:#660">&lt;</span><sp=
an style=3D"color:#606">Iter</span><span style=3D"color:#660">&gt;::</span>=
<span style=3D"color:#000">value_type</span><span style=3D"color:#660">&gt;=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">auto</=
span><span style=3D"color:#660">(</span><span style=3D"color:#606">Iter</sp=
an><span style=3D"color:#000"> b</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#606">Iter</span><sp=
an style=3D"color:#000"> e</span><span style=3D"color:#660">);</span></div>=
</code></div></div></blockquote><div><br></div><div>There is no support for=
 such a syntax.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><div><b>* Are non-template explicit deduction guides allowed?</b=
></div><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:#660">&lt;</span><span =
style=3D"color:#008">class</span><span style=3D"color:#000"> T</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"color:#000"> S<br></span>=
<span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 S</span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">T</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br=
><br>S</span><span style=3D"color:#660">(</span><span style=3D"color:#008">=
char</span><span style=3D"color:#000"> </span><span style=3D"color:#008">co=
nst</span><span style=3D"color:#660">*)</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">-&gt;</span><span style=3D"color:#000"> S<=
/span><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">std<=
/span><span style=3D"color:#660">::</span><span style=3D"color:#008">string=
</span><span style=3D"color:#660">&gt;;</span><span style=3D"color:#000"><b=
r><br>S s</span><span style=3D"color:#660">{</span><span style=3D"color:#08=
0">&quot;hello&quot;</span><span style=3D"color:#660">};</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// deduced to S&lt;std::=
string&gt;</span></div></code></div></div></blockquote><div><br></div><div>=
Yes, this is permitted.</div><div><br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<div dir=3D"ltr"><div><b>* Does the deduction work for aggregates?</b></div=
><div><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:b=
reak-word;background-color:rgb(250,250,250)"><code><div><span style=3D"colo=
r:#008">template</span><span style=3D"color:#660">&lt;</span><span style=3D=
"color:#008">class</span><span style=3D"color:#000"> A</span><span style=3D=
"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#008">class</span><span style=3D"color:#000"> B</span><span style=3D"colo=
r:#660">&gt;</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#008">struct</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#606">Agg</span><span style=3D"color:#000"><br></span><span style=3D"col=
or:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 A a</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 B b</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:#606">Agg</span><span style=3D"color:#0=
00"> agg</span><span style=3D"color:#660">{</span><span style=3D"color:#066=
">1</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </=
span><span style=3D"color:#066">2.0</span><span style=3D"color:#660">};</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#800">// ok? ded=
uced to Agg&lt;int, double&gt;</span></div></code></div></div></blockquote>=
<div><br></div><div>No, you can&#39;t do that; the deduction only considers=
 constructors. This seems like a reasonable extension, though.</div><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>If the abo=
ve doesn&#39;t work, will explicit deduction guides help?</div><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">=
class</span><span style=3D"color:#000"> A</span><span style=3D"color:#660">=
,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">class=
</span><span style=3D"color:#000"> B</span><span style=3D"color:#660">&gt;<=
/span><span style=3D"color:#000"><br></span><span style=3D"color:#606">Agg<=
/span><span style=3D"color:#660">(</span><span style=3D"color:#000">A a</sp=
an><span style=3D"color:#660">,</span><span style=3D"color:#000"> B b</span=
><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">-&gt;</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#606">Agg</span><span style=3D"color:#660">&lt;</span><span=
 style=3D"color:#000">A</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> B</span><span style=3D"color:#660">&gt;;</span></div></co=
de></div></div></blockquote><div><br></div><div>Yes, that should work.</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/CAOfiQqmGcF359uMD%3Dvu%3DMnZGwFaJH%2B=
_zbr98j8zG9E8ya1SRNg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmGcF=
359uMD%3Dvu%3DMnZGwFaJH%2B_zbr98j8zG9E8ya1SRNg%40mail.gmail.com</a>.<br />

--001a1149b7e8ffa1af05376330e8--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 11 Jul 2016 15:36:08 -0700 (PDT)
Raw View
------=_Part_636_1096239412.1468276568245
Content-Type: multipart/alternative;
 boundary="----=_Part_637_17117729.1468276568246"

------=_Part_637_17117729.1468276568246
Content-Type: text/plain; charset=UTF-8



On Monday, July 11, 2016 at 5:54:08 PM UTC-4, Richard Smith wrote:
>
> On Sun, Jul 10, 2016 at 12:34 AM, TONGARI J <tong...@gmail.com
> <javascript:>> wrote:
>
>> P0091 is voted into C++17, but for outsiders it's unclear what
>> decisions/changes has been made since:
>>
>> ** What's the syntax settled for explicit deduction guides?*
>>
>> The proposed syntax in P0091R2 is:
>>     *template < template-parameter-list > class-name (
>> parameter-declaration-clause ) -> simple-template-id*
>>
>> The author also listed some alternatives and left the decision to the
>> committee, what's the committee's decision?
>>
>
> The proposed syntax was accepted.
>
>
>> Is it possible for a syntax that doesn't require us to repeat the
>> class-name twice, e.g:
>>     *template-parameter-list > simple-template-id auto(
>> parameter-declaration-clause )*
>>
>> template<typename Iter>
>> vector<typename iterator_traits<Iter>::value_type> auto(Iter b, Iter e);
>>
>
> There is no support for such a syntax.
>
>
>> ** Are non-template explicit deduction guides allowed?*
>>
>> template<class T>
>> struct S
>> {
>>     S(T);
>> };
>>
>> S(char const*) -> S<std::string>;
>>
>> S s{"hello"}; // deduced to S<std::string>
>>
>
> Yes, this is permitted.
>
> ** Does the deduction work for aggregates?*
>>
>> template<class A, class B>
>> struct Agg
>> {
>>     A a;
>>     B b;
>> };
>>
>> Agg agg{1, 2.0}; // ok? deduced to Agg<int, double>
>>
>
> No, you can't do that; the deduction only considers constructors. This
> seems like a reasonable extension, though.
>
>
>> If the above doesn't work, will explicit deduction guides help?
>>
>> template<class A, class B>
>> Agg(A a, B b) -> Agg<A, B>;
>>
>
> Yes, that should work.
>

Wait, what? Deduction doesn't work for aggregate templates, because they
have no constructor. But you can add this deduction syntax to make it work.

Is this considered to give `Agg` a constructor? That is, is `Agg` no longer
an aggregate?

--
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/0fcb5a7b-2dbf-4fa6-9406-bd3b58b085c9%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Monday, July 11, 2016 at 5:54:08 PM UTC-4, Rich=
ard 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"lt=
r"><div><div class=3D"gmail_quote">On Sun, Jul 10, 2016 at 12:34 AM, TONGAR=
I J <span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obf=
uscated-mailto=3D"5JhjHWd1CgAJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;">tong...@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"><div>P0091 is voted into C++17, but =
for outsiders it&#39;s unclear what decisions/changes has been made since:<=
/div><div><br></div><div><b>* What&#39;s the syntax settled for explicit de=
duction guides?</b></div><div><br></div><div>The proposed syntax in P0091R2=
 is:</div><div>=C2=A0 =C2=A0 <i>template &lt; template-parameter-list &gt; =
class-name ( parameter-declaration-clause ) -&gt; simple-template-id</i></d=
iv><div><i><br></i></div><div>The author also listed some alternatives and =
left the decision to the committee, what&#39;s the committee&#39;s decision=
?</div></div></blockquote><div><br></div><div>The proposed syntax was accep=
ted.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
<div>Is it possible for a syntax that doesn&#39;t require us to repeat the =
class-name twice, e.g:</div><div>=C2=A0 =C2=A0=C2=A0<i>template-parameter-l=
ist &gt; simple-template-id auto( parameter-declaration-clause )</i></div><=
div><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:bre=
ak-word;background-color:rgb(250,250,250)"><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:#606">Iter</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br>vector</span><span style=3D"color:#660">&lt;</span><spa=
n style=3D"color:#008">typename</span><span style=3D"color:#000"> iterator_=
traits</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#60=
6">Iter</span><span style=3D"color:#660">&gt;::</span><span style=3D"color:=
#000">value_<wbr>type</span><span style=3D"color:#660">&gt;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#660">(</span><span style=3D"color:#606">Iter</span><span style=
=3D"color:#000"> b</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span style=3D"color:#606">Iter</span><span style=3D"co=
lor:#000"> e</span><span style=3D"color:#660">);</span></div></code></div><=
/div></blockquote><div><br></div><div>There is no support for such a syntax=
..</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><di=
v><b>* Are non-template explicit deduction guides allowed?</b></div><div><b=
r></div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:break-wor=
d;background-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">=
template</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#=
008">class</span><span style=3D"color:#000"> T</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"color:#000"> S<br></span><span style=3D"c=
olor:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 S</span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#000">T</span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#660">};</span><span style=3D"color:#000"><br><br>S</span><span=
 style=3D"color:#660">(</span><span style=3D"color:#008">char</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#008">const</span><span st=
yle=3D"color:#660">*)</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">-&gt;</span><span style=3D"color:#000"> S</span><span style=
=3D"color:#660">&lt;</span><span style=3D"color:#000">std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#008">string</span><span styl=
e=3D"color:#660">&gt;;</span><span style=3D"color:#000"><br><br>S s</span><=
span style=3D"color:#660">{</span><span style=3D"color:#080">&quot;hello&qu=
ot;</span><span style=3D"color:#660">};</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#800">// deduced to S&lt;std::string&gt;</span><=
/div></code></div></div></blockquote><div><br></div><div>Yes, this is permi=
tted.</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><=
div><b>* Does the deduction work for aggregates?</b></div><div><br></div><d=
iv style=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;backgrou=
nd-color:rgb(250,250,250)"><code><div><span style=3D"color:#008">template</=
span><span style=3D"color:#660">&lt;</span><span style=3D"color:#008">class=
</span><span style=3D"color:#000"> A</span><span style=3D"color:#660">,</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">class</spa=
n><span style=3D"color:#000"> B</span><span style=3D"color:#660">&gt;</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">struct</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#606">Agg</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0 =C2=A0 A a</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 B b</span><span =
style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">};</span><span style=3D"color:#000"><br><br></span><span=
 style=3D"color:#606">Agg</span><span style=3D"color:#000"> agg</span><span=
 style=3D"color:#660">{</span><span style=3D"color:#066">1</span><span styl=
e=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"=
color:#066">2.0</span><span style=3D"color:#660">};</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">// ok? deduced to Agg&lt;int, =
double&gt;</span></div></code></div></div></blockquote><div><br></div><div>=
No, you can&#39;t do that; the deduction only considers constructors. This =
seems like a reasonable extension, though.</div><div>=C2=A0</div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr"><div>If the above doesn&#39;t work, w=
ill explicit deduction guides help?</div><div><br></div><div style=3D"borde=
r: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:#660">&lt;</span><span style=3D"color:#008">class</span><span sty=
le=3D"color:#000"> A</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">class</span><span style=
=3D"color:#000"> B</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#606">Agg</span><span style=
=3D"color:#660">(</span><span style=3D"color:#000">A a</span><span style=3D=
"color:#660">,</span><span style=3D"color:#000"> B b</span><span style=3D"c=
olor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:=
#660">-&gt;</span><span style=3D"color:#000"> </span><span style=3D"color:#=
606">Agg</span><span style=3D"color:#660">&lt;</span><span style=3D"color:#=
000">A</span><span style=3D"color:#660">,</span><span style=3D"color:#000">=
 B</span><span style=3D"color:#660">&gt;;</span></div></code></div></div></=
blockquote><div><br></div><div>Yes, that should work.</div></div></div></di=
v></blockquote><div><br>Wait, what? Deduction doesn&#39;t work for aggregat=
e templates, because they have no constructor. But you can add this deducti=
on syntax to make it work.<br><br>Is this considered to give `Agg` a constr=
uctor? That is, is `Agg` no longer an aggregate?<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/0fcb5a7b-2dbf-4fa6-9406-bd3b58b085c9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0fcb5a7b-2dbf-4fa6-9406-bd3b58b085c9=
%40isocpp.org</a>.<br />

------=_Part_637_17117729.1468276568246--

------=_Part_636_1096239412.1468276568245--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 11 Jul 2016 16:58:22 -0700
Raw View
--001a113a0d16653efc053764ed12
Content-Type: text/plain; charset=UTF-8

On Mon, Jul 11, 2016 at 3:36 PM, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Monday, July 11, 2016 at 5:54:08 PM UTC-4, Richard Smith wrote:
>
>> On Sun, Jul 10, 2016 at 12:34 AM, TONGARI J <tong...@gmail.com> wrote:
>>
>>> P0091 is voted into C++17, but for outsiders it's unclear what
>>> decisions/changes has been made since:
>>>
>>> ** What's the syntax settled for explicit deduction guides?*
>>>
>>> The proposed syntax in P0091R2 is:
>>>     *template < template-parameter-list > class-name (
>>> parameter-declaration-clause ) -> simple-template-id*
>>>
>>> The author also listed some alternatives and left the decision to the
>>> committee, what's the committee's decision?
>>>
>>
>> The proposed syntax was accepted.
>>
>>
>>> Is it possible for a syntax that doesn't require us to repeat the
>>> class-name twice, e.g:
>>>     *template-parameter-list > simple-template-id auto(
>>> parameter-declaration-clause )*
>>>
>>> template<typename Iter>
>>> vector<typename iterator_traits<Iter>::value_type> auto(Iter b, Iter e);
>>>
>>
>> There is no support for such a syntax.
>>
>>
>>> ** Are non-template explicit deduction guides allowed?*
>>>
>>> template<class T>
>>> struct S
>>> {
>>>     S(T);
>>> };
>>>
>>> S(char const*) -> S<std::string>;
>>>
>>> S s{"hello"}; // deduced to S<std::string>
>>>
>>
>> Yes, this is permitted.
>>
>> ** Does the deduction work for aggregates?*
>>>
>>> template<class A, class B>
>>> struct Agg
>>> {
>>>     A a;
>>>     B b;
>>> };
>>>
>>> Agg agg{1, 2.0}; // ok? deduced to Agg<int, double>
>>>
>>
>> No, you can't do that; the deduction only considers constructors. This
>> seems like a reasonable extension, though.
>>
>>
>>> If the above doesn't work, will explicit deduction guides help?
>>>
>>> template<class A, class B>
>>> Agg(A a, B b) -> Agg<A, B>;
>>>
>>
>> Yes, that should work.
>>
>
> Wait, what? Deduction doesn't work for aggregate templates, because they
> have no constructor. But you can add this deduction syntax to make it work.
>
> Is this considered to give `Agg` a constructor? That is, is `Agg` no
> longer an aggregate?
>

No, class template argument deduction happens before initialization, and
deduction guide declarations are not used for anything other than guiding
class template argument deduction.

In the declaration

  Agg agg{1, 2.0};

we perform overload resolution as if we were initializing an object of some
hypothetical type X and we had the following overload set of constructors
for X:

  template<class A, class B> X(); // implicit, from class template
  template<class A, class B> X(const Agg<A, B> &); // implicit, from class
template
  template<class A, class B> X(Agg<A, B> &&); // implicit, from class
template
  template<class A, class B> X(A a, B b); // from deduction guide

We pick #4 (which doesn't matter) and deduce A=int, B=double. Those types
are then substituted into the simple-template-id from the deduction guide,
giving the type Agg<int, double> as the type of agg.

With that type deduced, we then initialize agg normally, which in this case
happens to perform aggregate initialization.

--
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/CAOfiQqneUHzhRXAHPpU36E4CzWpTAMaEpshBX_s3MpFRavcm1Q%40mail.gmail.com.

--001a113a0d16653efc053764ed12
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, Jul 11, 2016 at 3:36 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:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div dir=3D"ltr">On Monday, July 11, 2016 a=
t 5:54:08 PM UTC-4, Richard Smith wrote:<div><div class=3D"h5"><blockquote =
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1=
px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:=
1ex"><div dir=3D"ltr"><div><div class=3D"gmail_quote">On Sun, Jul 10, 2016 =
at 12:34 AM, TONGARI J <span dir=3D"ltr">&lt;<a rel=3D"nofollow">tong...@gm=
ail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,2=
04,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><div>P00=
91 is voted into C++17, but for outsiders it&#39;s unclear what decisions/c=
hanges has been made since:</div><div><br></div><div><b>* What&#39;s the sy=
ntax settled for explicit deduction guides?</b></div><div><br></div><div>Th=
e proposed syntax in P0091R2 is:</div><div>=C2=A0 =C2=A0 <i>template &lt; t=
emplate-parameter-list &gt; class-name ( parameter-declaration-clause ) -&g=
t; simple-template-id</i></div><div><i><br></i></div><div>The author also l=
isted some alternatives and left the decision to the committee, what&#39;s =
the committee&#39;s decision?</div></div></blockquote><div><br></div><div>T=
he proposed syntax was accepted.</div><div>=C2=A0</div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;borde=
r-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><di=
v dir=3D"ltr"><div>Is it possible for a syntax that doesn&#39;t require us =
to repeat the class-name twice, e.g:</div><div>=C2=A0 =C2=A0=C2=A0<i>templa=
te-parameter-list &gt; simple-template-id auto( parameter-declaration-claus=
e )</i></div><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 s=
tyle=3D"color:rgb(0,0,136)">template</span><span style=3D"color:rgb(102,102=
,0)">&lt;</span><span style=3D"color:rgb(0,0,136)">typename</span><span sty=
le=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Iter</=
span><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:r=
gb(0,0,0)"><br>vector</span><span style=3D"color:rgb(102,102,0)">&lt;</span=
><span style=3D"color:rgb(0,0,136)">typename</span><span style=3D"color:rgb=
(0,0,0)"> iterator_traits</span><span style=3D"color:rgb(102,102,0)">&lt;</=
span><span style=3D"color:rgb(102,0,102)">Iter</span><span style=3D"color:r=
gb(102,102,0)">&gt;::</span><span style=3D"color:rgb(0,0,0)">value_type</sp=
an><span style=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">auto</span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(102,0,102)">Iter=
</span><span style=3D"color:rgb(0,0,0)"> b</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"=
color:rgb(102,0,102)">Iter</span><span style=3D"color:rgb(0,0,0)"> e</span>=
<span style=3D"color:rgb(102,102,0)">);</span></div></code></div></div></bl=
ockquote><div><br></div><div>There is no support for such a syntax.</div><d=
iv>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-lef=
t-style:solid;padding-left:1ex"><div dir=3D"ltr"><div><b>* Are non-template=
 explicit deduction guides allowed?</b></div><div><br></div><div style=3D"b=
order:1px solid rgb(187,187,187);word-wrap:break-word;background-color:rgb(=
250,250,250)"><code><div><span style=3D"color:rgb(0,0,136)">template</span>=
<span style=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,=
0,136)">class</span><span style=3D"color:rgb(0,0,0)"> T</span><span style=
=3D"color:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"><br><=
/span><span style=3D"color:rgb(0,0,136)">struct</span><span style=3D"color:=
rgb(0,0,0)"> S<br></span><span style=3D"color:rgb(102,102,0)">{</span><span=
 style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 S</span><span style=3D"color:=
rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">T</span><span styl=
e=3D"color:rgb(102,102,0)">);</span><span style=3D"color:rgb(0,0,0)"><br></=
span><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb=
(0,0,0)"><br><br>S</span><span style=3D"color:rgb(102,102,0)">(</span><span=
 style=3D"color:rgb(0,0,136)">char</span><span style=3D"color:rgb(0,0,0)"> =
</span><span style=3D"color:rgb(0,0,136)">const</span><span style=3D"color:=
rgb(102,102,0)">*)</span><span style=3D"color:rgb(0,0,0)"> </span><span sty=
le=3D"color:rgb(102,102,0)">-&gt;</span><span style=3D"color:rgb(0,0,0)"> S=
</span><span style=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color=
:rgb(0,0,0)">std</span><span style=3D"color:rgb(102,102,0)">::</span><span =
style=3D"color:rgb(0,0,136)">string</span><span style=3D"color:rgb(102,102,=
0)">&gt;;</span><span style=3D"color:rgb(0,0,0)"><br><br>S s</span><span st=
yle=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,136,0)">&qu=
ot;hello&quot;</span><span style=3D"color:rgb(102,102,0)">};</span><span st=
yle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(136,0,0)">// dedu=
ced to S&lt;std::string&gt;</span></div></code></div></div></blockquote><di=
v><br></div><div>Yes, this is permitted.</div><div><br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px=
;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1e=
x"><div dir=3D"ltr"><div><b>* Does the deduction work for aggregates?</b></=
div><div><br></div><div style=3D"border:1px solid rgb(187,187,187);word-wra=
p:break-word;background-color:rgb(250,250,250)"><code><div><span style=3D"c=
olor:rgb(0,0,136)">template</span><span style=3D"color:rgb(102,102,0)">&lt;=
</span><span style=3D"color:rgb(0,0,136)">class</span><span style=3D"color:=
rgb(0,0,0)"> A</span><span style=3D"color:rgb(102,102,0)">,</span><span sty=
le=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</s=
pan><span style=3D"color:rgb(0,0,0)"> B</span><span style=3D"color:rgb(102,=
102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=
=3D"color:rgb(0,0,136)">struct</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,0,102)">Agg</span><span style=3D"color:rgb(=
0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">{</span><span style=
=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 A a</span><span style=3D"color:rgb(=
102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 =C2=A0 B b<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb=
(0,0,0)"><br></span><span style=3D"color:rgb(102,102,0)">};</span><span sty=
le=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"color:rgb(102,0,102)"=
>Agg</span><span style=3D"color:rgb(0,0,0)"> agg</span><span style=3D"color=
:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,102,102)">1</span><span=
 style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> <=
/span><span style=3D"color:rgb(0,102,102)">2.0</span><span style=3D"color:r=
gb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(136,0,0)">// ok? deduced to Agg&lt;int, double&gt;</span></d=
iv></code></div></div></blockquote><div><br></div><div>No, you can&#39;t do=
 that; the deduction only considers constructors. This seems like a reasona=
ble extension, though.</div><div>=C2=A0</div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-col=
or:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"l=
tr"><div>If the above doesn&#39;t work, will explicit deduction guides help=
?</div><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:rgb(0,0,136)">template</span><span style=3D"color:rgb(102,102,0)"=
>&lt;</span><span style=3D"color:rgb(0,0,136)">class</span><span style=3D"c=
olor:rgb(0,0,0)"> A</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">cla=
ss</span><span style=3D"color:rgb(0,0,0)"> B</span><span style=3D"color:rgb=
(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)"><br></span><span s=
tyle=3D"color:rgb(102,0,102)">Agg</span><span style=3D"color:rgb(102,102,0)=
">(</span><span style=3D"color:rgb(0,0,0)">A a</span><span style=3D"color:r=
gb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> B b</span><span st=
yle=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">-&gt;</span><span style=3D"color:rg=
b(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Agg</span><span styl=
e=3D"color:rgb(102,102,0)">&lt;</span><span style=3D"color:rgb(0,0,0)">A</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0=
,0,0)"> B</span><span style=3D"color:rgb(102,102,0)">&gt;;</span></div></co=
de></div></div></blockquote><div><br></div><div>Yes, that should work.</div=
></div></div></div></blockquote></div></div><div><br>Wait, what? Deduction =
doesn&#39;t work for aggregate templates, because they have no constructor.=
 But you can add this deduction syntax to make it work.<br><br>Is this cons=
idered to give `Agg` a constructor? That is, is `Agg` no longer an aggregat=
e?</div></div></blockquote><div><br></div><div>No, class template argument =
deduction happens before initialization, and deduction guide declarations a=
re not used for anything other than guiding class template argument deducti=
on.</div><div><br></div><div>In the declaration</div><div><br></div><div>=
=C2=A0 Agg agg{1, 2.0};</div><div><br></div><div>we perform overload resolu=
tion as if we were initializing an object of some hypothetical type X and w=
e had the following overload set of constructors for X:</div><div><br></div=
><div>=C2=A0 template&lt;class A, class B&gt; X(); // implicit, from class =
template</div><div>=C2=A0 template&lt;class A, class B&gt; X(const Agg&lt;A=
, B&gt; &amp;); // implicit, from class template</div><div>=C2=A0 template&=
lt;class A, class B&gt; X(Agg&lt;A, B&gt; &amp;&amp;); // implicit, from cl=
ass template<br></div><div>=C2=A0 template&lt;class A, class B&gt; X(A a, B=
 b); // from deduction guide</div><div><br></div><div>We pick #4 (which doe=
sn&#39;t matter) and deduce A=3Dint, B=3Ddouble. Those types are then subst=
ituted into the simple-template-id from the deduction guide, giving the typ=
e Agg&lt;int, double&gt; as the type of agg.</div><div><br></div><div>With =
that type deduced, we then initialize agg normally, which in this case happ=
ens to perform aggregate initialization.</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/CAOfiQqneUHzhRXAHPpU36E4CzWpTAMaEpshB=
X_s3MpFRavcm1Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqneUHzhRXAH=
PpU36E4CzWpTAMaEpshBX_s3MpFRavcm1Q%40mail.gmail.com</a>.<br />

--001a113a0d16653efc053764ed12--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 11 Jul 2016 19:20:03 -0500
Raw View
On Mon, Jul 11, 2016 at 6:58 PM, Richard Smith <richard@metafoo.co.uk> wrote:
> With that type deduced, we then initialize agg normally, which in this case
> happens to perform aggregate initialization.

So this works as well?

  template <template... T>
  array(T&&... t) -> array<common_type_t<T...>, sizeof...(T)>;

  auto a = array{ 1, 2, 3u };

For the example raised before, does this work?

  Agg<long> agg{1, 2.0};  // deducing only B

(I guess not as the wording seems not having this grammar).

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/

--
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/CAGsORuB5mN1sVJ1oBF5067cKzmzkubAgO1MAwu1_VaPj_DHMGQ%40mail.gmail.com.

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 11 Jul 2016 18:22:28 -0700
Raw View
--001a1149b7e830a1aa0537661af6
Content-Type: text/plain; charset=UTF-8

On Mon, Jul 11, 2016 at 5:20 PM, Zhihao Yuan <zy@miator.net> wrote:

> On Mon, Jul 11, 2016 at 6:58 PM, Richard Smith <richard@metafoo.co.uk>
> wrote:
> > With that type deduced, we then initialize agg normally, which in this
> case
> > happens to perform aggregate initialization.
>
> So this works as well?
>
>   template <template... T>
>   array(T&&... t) -> array<common_type_t<T...>, sizeof...(T)>;
>
>   auto a = array{ 1, 2, 3u };
>

Yes, that should work.

For the example raised before, does this work?
>
>   Agg<long> agg{1, 2.0};  // deducing only B
>
> (I guess not as the wording seems not having this grammar).
>

No, if an explicit template argument list is written, class template
argument deduction is not performed. Various concerns were raised about
readability, backwards-compatibility, the ability to add default template
arguments to existing templates, and so on, that caused us to conclude that
this would be a bad idea without an explicit sigil requesting deduction.

In Evolution we discussed allowing an opt-in to deduction with a syntax like

  Agg<long, @> agg{1, 2.0};

.... but the tricky part is deciding what concrete syntax should replace the
@ here. This decision can't really be made in isolation: it has a bearing
on the syntax of pattern matching and on concepts, and it was too late to
design something new for this at Oulu. (There are a lot of possibilities,
and they have different trade-offs and drawbacks.)

--
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/CAOfiQqkxSA1E%2B8K7Lu_YidLWFmRQXyMiwQCmPfV62mhyNyyYsA%40mail.gmail.com.

--001a1149b7e830a1aa0537661af6
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, Jul 11, 2016 at 5:20 PM, Zhihao Yuan <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:zy@miator.net" target=3D"_blank">zy@miator.net</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"><span class=3D"">On Mon, Jul 11, 2016 at =
6:58 PM, Richard Smith &lt;<a href=3D"mailto:richard@metafoo.co.uk">richard=
@metafoo.co.uk</a>&gt; wrote:<br>
&gt; With that type deduced, we then initialize agg normally, which in this=
 case<br>
&gt; happens to perform aggregate initialization.<br>
<br>
</span>So this works as well?<br>
<br>
=C2=A0 template &lt;template... T&gt;<br>
=C2=A0 array(T&amp;&amp;... t) -&gt; array&lt;common_type_t&lt;T...&gt;, si=
zeof...(T)&gt;;<br>
<br>
=C2=A0 auto a =3D array{ 1, 2, 3u };<br></blockquote><div><br></div><div>Ye=
s, that should work.</div><div><br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For the example raised before, does this work?<br>
<br>
=C2=A0 Agg&lt;long&gt; agg{1, 2.0};=C2=A0 // deducing only B<br>
<br>
(I guess not as the wording seems not having this grammar).<br></blockquote=
><div><br></div><div>No, if an explicit template argument list is written, =
class template argument deduction is not performed. Various concerns were r=
aised about readability, backwards-compatibility, the ability to add defaul=
t template arguments to existing templates, and so on, that caused us to co=
nclude that this would be a bad idea without an explicit sigil requesting d=
eduction.</div><div><br></div><div>In Evolution we discussed allowing an op=
t-in to deduction with a syntax like</div><div><br></div><div>=C2=A0 Agg&lt=
;long, @&gt; agg{1, 2.0};</div><div><br></div><div>... but the tricky part =
is deciding what concrete syntax should replace the @ here. This decision c=
an&#39;t really be made in isolation: it has a bearing on the syntax of pat=
tern matching and on concepts, and it was too late to design something new =
for this at Oulu. (There are a lot of possibilities, and they have differen=
t trade-offs and drawbacks.)</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/CAOfiQqkxSA1E%2B8K7Lu_YidLWFmRQXyMiwQ=
CmPfV62mhyNyyYsA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqkxSA1E%2=
B8K7Lu_YidLWFmRQXyMiwQCmPfV62mhyNyyYsA%40mail.gmail.com</a>.<br />

--001a1149b7e830a1aa0537661af6--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 11 Jul 2016 20:59:43 -0500
Raw View
On Mon, Jul 11, 2016 at 8:22 PM, Richard Smith <richard@metafoo.co.uk> wrote:
>
> In Evolution we discussed allowing an opt-in to deduction with a syntax like
>
>   Agg<long, @> agg{1, 2.0};
>
> ... but the tricky part is deciding what concrete syntax should replace the
> @ here. This decision can't really be made in isolation: it has a bearing on
> the syntax of pattern matching and on concepts, and [...]

And it's questionable whether people want to use this
form...  Thanks for the explanations.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://blog.miator.net/

--
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/CAGsORuC85FDR8GWoRZzEknjv%2BHiKGLFsfdYADGns%2BhN8uA4stA%40mail.gmail.com.

.