Topic: An idea on how to deduce class template arguments


Author: Zhihao Yuan <zy@miator.net>
Date: Tue, 31 Oct 2017 13:19:06 -0500
Raw View
--001a11c000166b2ebb055cdbcae8
Content-Type: text/plain; charset="UTF-8"

I was being asked about this question during CppCon,
and I answered "no concrete solution emerged".  Here
is an idea I got recently.

For short, write additional deduction guides like these:

    template <typename T, typename... U>
    array<T>(U...) -> array<T, sizeof...(U)>;

    template <typename... T, typename... U>
    tuple<T...>(T..., U...) -> tuple<T..., U...>;

This syntax looks like function template partial
specializations, but you know there is no such thing.
The semantics is easier to explain if the feature is
also enabled for function templates, where those
extra template arguments here are matched against
"prototype parameters".  Function templates with
prototype parameters are not specializations, just
main templates.  Let's say we have

    template <typename T, typename U>
    auto gcd(T, U);  // 1

    template <typename T, typename U>
    auto gcd<T>(T, U);  // 2

When user calls

    gcd<int>('a', 'b');

, both #1 and #2 participate in overload resolution.  #1
becomes

    gcd<int, char>(int, char);

In #2, first, deduce T out of <int> using the rules of
template argument deduction, then substitute T = int
back into the template and obtain

    gcd<int>(int, U);

, then deduce U out of the type of 'b' which is char, so
it's also

    gcd<int, char>(int, char);

They are equally good, so a disambiguation rule kicks
in and prefers the one substituted from a function
template with prototype parameters.

Deduction guide's version works in the same way.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

--
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/CAGsORuB-8CepXueTovbXfB6dbAb2_p2_hOT6-T2LR7OsZ5g%2Bdg%40mail.gmail.com.

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

<div dir=3D"ltr"><div><div>I was being asked about this question during Cpp=
Con,<br></div>and I answered &quot;no concrete solution emerged&quot;.=C2=
=A0 Here<br></div>is an idea I got recently.<br><div><div><div><br>For shor=
t, write additional deduction guides like these:<br><br>=C2=A0=C2=A0=C2=A0 =
template &lt;typename T, typename... U&gt;<br>=C2=A0=C2=A0=C2=A0 array&lt;T=
&gt;(U...) -&gt; array&lt;T, sizeof...(U)&gt;;<br><br>=C2=A0=C2=A0=C2=A0 te=
mplate &lt;typename... T, typename... U&gt;<br>=C2=A0=C2=A0=C2=A0 tuple&lt;=
T...&gt;(T..., U...) -&gt; tuple&lt;T..., U...&gt;;<br><br>This syntax look=
s like function template partial<br>specializations, but you know there is =
no such thing.<br>The semantics is easier to explain if the feature is<br>a=
lso enabled for function templates, where those<br>extra template arguments=
 here are matched against<br>&quot;prototype parameters&quot;.=C2=A0 Functi=
on templates with<br>prototype parameters are not specializations, just<br>=
main templates.=C2=A0 Let&#39;s say we have<br><br>=C2=A0=C2=A0=C2=A0 templ=
ate &lt;typename T, typename U&gt;<br>=C2=A0=C2=A0=C2=A0 auto gcd(T, U);=C2=
=A0 // 1<br><br>=C2=A0=C2=A0=C2=A0 template &lt;typename T, typename U&gt;<=
br>=C2=A0=C2=A0=C2=A0 auto gcd&lt;T&gt;(T, U);=C2=A0 // 2<br><br>When user =
calls<br><br>=C2=A0=C2=A0=C2=A0 gcd&lt;int&gt;(&#39;a&#39;, &#39;b&#39;);<b=
r><br>, both #1 and #2 participate in overload resolution.=C2=A0 #1<br>beco=
mes<br><br>=C2=A0=C2=A0=C2=A0 gcd&lt;int, char&gt;(int, char);<br><br>In #2=
, first, deduce T out of &lt;int&gt; using the rules of<br>template argumen=
t deduction, then substitute T =3D int<br>back into the template and obtain=
<br><br>=C2=A0=C2=A0=C2=A0 gcd&lt;int&gt;(int, U);<br><br>, then deduce U o=
ut of the type of &#39;b&#39; which is char, so<br>it&#39;s also<br><br>=C2=
=A0=C2=A0=C2=A0 gcd&lt;int, char&gt;(int, char);<br><br>They are equally go=
od, so a disambiguation rule kicks<br>in and prefers the one substituted fr=
om a function<br>template with prototype parameters.<br><br>Deduction guide=
&#39;s version works in the same way.<br clear=3D"all"><br>-- <br><div clas=
s=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=
=3D"ltr"><div>Zhihao Yuan, ID lichray<br>The best way to predict the future=
 is to invent it.<br>_______________________________________________<br></d=
iv></div></div></div></div></div></div>
</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/CAGsORuB-8CepXueTovbXfB6dbAb2_p2_hOT6=
-T2LR7OsZ5g%2Bdg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuB-8CepXu=
eTovbXfB6dbAb2_p2_hOT6-T2LR7OsZ5g%2Bdg%40mail.gmail.com</a>.<br />

--001a11c000166b2ebb055cdbcae8--

.


Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Tue, 31 Oct 2017 15:31:28 -0700 (PDT)
Raw View
------=_Part_9487_198002820.1509489088416
Content-Type: multipart/alternative;
 boundary="----=_Part_9488_666195400.1509489088417"

------=_Part_9488_666195400.1509489088417
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tuesday, October 31, 2017 at 11:19:22 AM UTC-7, Zhihao Yuan wrote:
>
> I was being asked about this question during CppCon,
> and I answered "no concrete solution emerged".  Here
> is an idea I got recently.
>

Can you explain the question, please?

When I hear "partial specialization, CTAD, no solution", I immediately=20
think of this fiasco:

    template<class> struct Foo;  // notice the lack of explicit deduction=
=20
guides

    template<class T>
    struct Foo<T*> {
        Foo(T&);
    };

    int i;
    Foo f(i);  // "obviously" we want Foo<int*>, but in C++17 this is not=
=20
deducible

Can you explain whether you're trying to solve this problem, or a different=
=20
problem, and if so, what problem?
Obviously the above problem cannot be "solved" by telling the programmer to=
=20
write explicit deduction guides, because the problem is that explicit=20
guides are required in the first place.

[...]

> Function templates with
> prototype parameters are not specializations, just
> main templates.  Let's say we have
>
>     template <typename T, typename U>
>     auto gcd(T, U);  // 1
>
>     template <typename T, typename U>
>     auto gcd<T>(T, U);  // 2
>

The second of these declarations is a syntax error. Could you rephrase this=
=20
as valid C++17 code, or else explain what extensions you're assuming?
Incidentally, I don't know what "prototype parameters" means.

=E2=80=93Arthur

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

------=_Part_9488_666195400.1509489088417
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, October 31, 2017 at 11:19:22 AM UTC-7, Zhihao =
Yuan 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"><d=
iv><div>I was being asked about this question during CppCon,<br></div>and I=
 answered &quot;no concrete solution emerged&quot;.=C2=A0 Here<br></div>is =
an idea I got recently.<br></div></blockquote><div><br></div><div>Can you e=
xplain the question, please?</div><div><br></div><div>When I hear &quot;par=
tial specialization, CTAD, no solution&quot;, I immediately think of this f=
iasco:</div><div><br></div><div>=C2=A0 =C2=A0 template&lt;class&gt; struct =
Foo; =C2=A0// notice the lack of explicit deduction guides</div><div><br></=
div><div>=C2=A0 =C2=A0 template&lt;class T&gt;</div><div>=C2=A0 =C2=A0 stru=
ct Foo&lt;T*&gt; {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Foo(T&amp;);</div>=
<div>=C2=A0 =C2=A0 };</div><div><br></div><div>=C2=A0 =C2=A0 int i;</div><d=
iv>=C2=A0 =C2=A0 Foo f(i); =C2=A0// &quot;obviously&quot; we want Foo&lt;in=
t*&gt;, but in C++17 this is not deducible</div><div><br></div><div>Can you=
 explain whether you&#39;re trying to solve this problem, or a different pr=
oblem, and if so, what problem?</div><div>Obviously the above problem canno=
t be &quot;solved&quot; by telling the programmer to write explicit deducti=
on guides, because the problem is that explicit guides are required in the =
first place.</div><div><br></div><div>[...]</div><blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr"><div><div><div>Function templates with<=
br>prototype parameters are not specializations, just<br>main templates.=C2=
=A0 Let&#39;s say we have<br><br>=C2=A0=C2=A0=C2=A0 template &lt;typename T=
, typename U&gt;<br>=C2=A0=C2=A0=C2=A0 auto gcd(T, U);=C2=A0 // 1<br><br>=
=C2=A0=C2=A0=C2=A0 template &lt;typename T, typename U&gt;<br>=C2=A0=C2=A0=
=C2=A0 auto gcd&lt;T&gt;(T, U);=C2=A0 // 2<br></div></div></div></div></blo=
ckquote><div><br></div><div>The second of these declarations is a syntax er=
ror. Could you rephrase this as valid C++17 code, or else explain what exte=
nsions you&#39;re assuming?</div><div>Incidentally, I don&#39;t know what &=
quot;prototype parameters&quot; means.</div><div><br></div><div>=E2=80=93Ar=
thur</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/94ff6f1b-2175-4285-ab44-1192e7d9b3fc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/94ff6f1b-2175-4285-ab44-1192e7d9b3fc=
%40isocpp.org</a>.<br />

------=_Part_9488_666195400.1509489088417--

------=_Part_9487_198002820.1509489088416--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Tue, 31 Oct 2017 17:58:33 -0500
Raw View
--94eb2c05f6d6cd6cb7055cdfb1cc
Content-Type: text/plain; charset="UTF-8"

On Tue, Oct 31, 2017 at 5:31 PM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
wrote:

> Can you explain the question, please?
>
> When I hear "partial specialization, CTAD, no solution", I immediately
> think of this fiasco:
>
>     template<class> struct Foo;  // notice the lack of explicit deduction
> guides
>
>     template<class T>
>     struct Foo<T*> {
>

I used a wrong term... What I mean is to deduce from a
_simple-template-id_, like this

  tuple<string> t("str", 1);  // first element std::string

[...]

> Function templates with
> prototype parameters are not specializations, just
> main templates.  Let's say we have
>
>     template <typename T, typename U>
>     auto gcd(T, U);  // 1
>
>     template <typename T, typename U>
>     auto gcd<T>(T, U);  // 2
>

The second of these declarations is a syntax error. Could you rephrase this
as valid C++17 code, or else explain what extensions you're assuming?
Incidentally, I don't know what "prototype parameters" means.

It's a term used in Concepts TS to mean "the
leading template parameters which can form
currying".  I borrowed this term here in the
description of a new form of function template
I want to propose, whose the syntax is as
same as an "function template partial
specialization", although there is no such thing.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

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

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

<div dir=3D"ltr">On Tue, Oct 31, 2017 at 5:31 PM, Arthur O&#39;Dwyer <span =
dir=3D"ltr">&lt;<a target=3D"_blank" href=3D"mailto:arthur.j.odwyer@gmail.c=
om">arthur.j.odwyer@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_=
extra"><div class=3D"gmail_quote"><blockquote style=3D"margin:0px 0px 0px 0=
..8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmai=
l_quote"><div dir=3D"ltr"><span></span><div>Can you explain the question, p=
lease?</div><div><br></div><div>When I hear &quot;partial specialization, C=
TAD, no solution&quot;, I immediately think of this fiasco:</div><div><br><=
/div><div>=C2=A0 =C2=A0 template&lt;class&gt; struct Foo; =C2=A0// notice t=
he lack of explicit deduction guides</div><div><br></div><div>=C2=A0 =C2=A0=
 template&lt;class T&gt;</div><div>=C2=A0 =C2=A0 struct Foo&lt;T*&gt; {</di=
v><div></div></div></blockquote><br></div><div class=3D"gmail_quote">I used=
 a wrong term... What I mean is to deduce from a<br></div><div class=3D"gma=
il_quote">_simple-template-id_, like this<br><br></div><div class=3D"gmail_=
quote">=C2=A0 tuple&lt;string&gt; t(&quot;str&quot;, 1);=C2=A0 // first ele=
ment std::string<br></div><div class=3D"gmail_quote"><div dir=3D"ltr"><div>=
<br></div><div>[...]</div><span><blockquote style=3D"margin:0px 0px 0px 0.8=
ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_=
quote"><div dir=3D"ltr"><div><div><div>Function templates with<br>prototype=
 parameters are not specializations, just<br>main templates.=C2=A0 Let&#39;=
s say we have<br><br>=C2=A0=C2=A0=C2=A0 template &lt;typename T, typename U=
&gt;<br>=C2=A0=C2=A0=C2=A0 auto gcd(T, U);=C2=A0 // 1<br><br>=C2=A0=C2=A0=
=C2=A0 template &lt;typename T, typename U&gt;<br>=C2=A0=C2=A0=C2=A0 auto g=
cd&lt;T&gt;(T, U);=C2=A0 // 2<br></div></div></div></div></blockquote><div>=
<br></div></span><div>The second of these declarations is a syntax error. C=
ould you rephrase this as valid C++17 code, or else explain what extensions=
 you&#39;re assuming?</div><div>Incidentally, I don&#39;t know what &quot;p=
rototype parameters&quot; means.</div><span class=3D"gmail-m_-1865515751872=
424895HOEnZb"></span></div></div><br></div><div class=3D"gmail_extra">It&#3=
9;s a term used in Concepts TS to mean &quot;the<br>leading template parame=
ters which can form<br>currying&quot;.=C2=A0 I borrowed this term here in t=
he<br></div><div class=3D"gmail_extra">description of a new form of functio=
n template<br></div><div class=3D"gmail_extra">I want to propose<span>, who=
se the syntax is as<br></span></div><div class=3D"gmail_extra"><span>same a=
s an &quot;function template partial<br></span></div><div class=3D"gmail_ex=
tra"><span>specialization&quot;, although there is no such thing.<br></span=
></div><div class=3D"gmail_extra"><br>-- <br><div class=3D"gmail-m_-1865515=
751872424895gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><d=
iv dir=3D"ltr"><div>Zhihao Yuan, ID lichray<br>The best way to predict the =
future is to invent it.<br>______________________________<wbr>_____________=
____<br></div></div></div></div></div></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/CAGsORuCDVZf6nmSmk_hy2kvWPzfFm_Dowir5=
0AUqV0Os2qcEcA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuCDVZf6nmSm=
k_hy2kvWPzfFm_Dowir50AUqV0Os2qcEcA%40mail.gmail.com</a>.<br />

--94eb2c05f6d6cd6cb7055cdfb1cc--

.


Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Tue, 31 Oct 2017 18:24:01 -0700
Raw View
--f403045c182e0f8a74055ce1ba4a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 31, 2017 at 3:58 PM, Zhihao Yuan <zy@miator.net> wrote:

> On Tue, Oct 31, 2017 at 5:31 PM, Arthur O'Dwyer <arthur.j.odwyer@gmail.co=
m
> > wrote:
>
>> Can you explain the question, please?
>>
>> When I hear "partial specialization, CTAD, no solution", I immediately
>> think of this fiasco:
>>
>>     template<class> struct Foo;  // notice the lack of explicit deductio=
n
>> guides
>>
>>     template<class T>
>>     struct Foo<T*> {
>>
>
> I used a wrong term... What I mean is to deduce from a
> _simple-template-id_, like this
>
>   tuple<string> t("str", 1);  // first element std::string
>

Oh, okay. That seems insane. It's one thing to have "tuple" secretly mean
"tuple<string, int>". It's quite another to have "tuple<string>" secretly
mean "tuple<string, int>".

=E2=80=93Arthur

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

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

<div dir=3D"ltr">On Tue, Oct 31, 2017 at 3:58 PM, Zhihao Yuan <span dir=3D"=
ltr">&lt;<a href=3D"mailto:zy@miator.net" target=3D"_blank">zy@miator.net</=
a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quot=
e"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Tue, Oct 31, 2017 at =
5:31 PM, Arthur O&#39;Dwyer <span dir=3D"ltr">&lt;<a href=3D"mailto:arthur.=
j.odwyer@gmail.com" target=3D"_blank">arthur.j.odwyer@gmail.com</a>&gt;</sp=
an> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockq=
uote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,20=
4);padding-left:1ex" class=3D"gmail_quote"><div dir=3D"ltr"><span></span><d=
iv>Can you explain the question, please?</div><div><br></div><div>When I he=
ar &quot;partial specialization, CTAD, no solution&quot;, I immediately thi=
nk of this fiasco:</div><div><br></div><div>=C2=A0 =C2=A0 template&lt;class=
&gt; struct Foo; =C2=A0// notice the lack of explicit deduction guides</div=
><div><br></div><div>=C2=A0 =C2=A0 template&lt;class T&gt;</div><div>=C2=A0=
 =C2=A0 struct Foo&lt;T*&gt; {</div><div></div></div></blockquote><br></div=
><div class=3D"gmail_quote">I used a wrong term... What I mean is to deduce=
 from a<br></div><div class=3D"gmail_quote">_simple-template-id_, like this=
<br><br></div><div class=3D"gmail_quote">=C2=A0 tuple&lt;string&gt; t(&quot=
;str&quot;, 1);=C2=A0 // first element std::string<br></div></div></div></b=
lockquote><div><br></div><div>Oh, okay. That seems insane. It&#39;s one thi=
ng to have &quot;tuple&quot; secretly mean &quot;tuple&lt;string, int&gt;&q=
uot;. It&#39;s quite another to have &quot;tuple&lt;string&gt;&quot; secret=
ly mean &quot;tuple&lt;string, int&gt;&quot;.</div><div><br></div><div>=E2=
=80=93Arthur</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/CADvuK0L2Sx6XJeH_0vo7eYRTBPe%2BuTSdyZ=
NGa9n7BuMB4DoZgQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0L2Sx6XJe=
H_0vo7eYRTBPe%2BuTSdyZNGa9n7BuMB4DoZgQ%40mail.gmail.com</a>.<br />

--f403045c182e0f8a74055ce1ba4a--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Tue, 31 Oct 2017 20:37:39 -0500
Raw View
--94eb2c05f6d6cf096a055ce1ea53
Content-Type: text/plain; charset="UTF-8"

On Tue, Oct 31, 2017 at 8:24 PM, Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
wrote:

> On Tue, Oct 31, 2017 at 3:58 PM, Zhihao Yuan <zy@miator.net> wrote:
>
>> I used a wrong term... What I mean is to deduce from a
>> _simple-template-id_, like this
>>
>>   tuple<string> t("str", 1);  // first element std::string
>>
>
> Oh, okay. That seems insane. It's one thing to have "tuple" secretly mean
> "tuple<string, int>". It's quite another to have "tuple<string>" secretly
> mean "tuple<string, int>".
>

That was the major reason for not doing so
automatically when discussing CTAD for
C++17.  However, if we can specify deduction
guides to match the template argument lists
and place a tiebreaker between the two
kinds of deduction guides, it works safely,
and enables array<int>{ 'a', 'b' }, which may
looks saner for you ;)

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

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

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

<div dir=3D"ltr">On Tue, Oct 31, 2017 at 8:24 PM, Arthur O&#39;Dwyer <span =
dir=3D"ltr">&lt;<a href=3D"mailto:arthur.j.odwyer@gmail.com" target=3D"_bla=
nk">arthur.j.odwyer@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_=
extra"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><span class=3D"">On Tue, Oct 31, 2017 at 3:58 PM, Zhihao Yuan <spa=
n dir=3D"ltr">&lt;<a href=3D"mailto:zy@miator.net" target=3D"_blank">zy@mia=
tor.net</a>&gt;</span> wrote:</span><br><span class=3D""></span><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><span class=3D""><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p=
adding-left:1ex"><div dir=3D"ltr">I used a wrong term... What I mean is to =
deduce from a<br><div class=3D"gmail_extra"><div class=3D"gmail_quote">_sim=
ple-template-id_, like this<br><br></div><div class=3D"gmail_quote">=C2=A0 =
tuple&lt;string&gt; t(&quot;str&quot;, 1);=C2=A0 // first element std::stri=
ng<br></div></div></div></blockquote><div><br></div></span><div>Oh, okay. T=
hat seems insane. It&#39;s one thing to have &quot;tuple&quot; secretly mea=
n &quot;tuple&lt;string, int&gt;&quot;. It&#39;s quite another to have &quo=
t;tuple&lt;string&gt;&quot; secretly mean &quot;tuple&lt;string, int&gt;&qu=
ot;.</div><span class=3D"HOEnZb"></span></div></div></div></blockquote></di=
v><br></div><div class=3D"gmail_extra">That was the major reason for not do=
ing so<br>automatically when discussing CTAD for<br></div><div class=3D"gma=
il_extra">C++17.=C2=A0 However, if we can specify deduction<br></div><div c=
lass=3D"gmail_extra">guides to match the template argument lists<br></div><=
div class=3D"gmail_extra">and place a tiebreaker between the two<br></div><=
div class=3D"gmail_extra">kinds of deduction guides, it works safely,<br></=
div><div class=3D"gmail_extra">and enables array&lt;int&gt;{ &#39;a&#39;, &=
#39;b&#39; }, which may<br></div><div class=3D"gmail_extra">looks saner for=
 you ;)<br clear=3D"all"></div><div class=3D"gmail_extra"><br>-- <br><div c=
lass=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr=
"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div>Zhihao Yuan, ID lichray<=
br>The best way to predict the future is to invent it.<br>_________________=
______________________________<br></div></div></div></div></div></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/CAGsORuAxMh2hgSgZHRijmuCJPk2F4%3Dr8TN=
jU7x1CjW1zTAdBdQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAGsORuAxMh2hgS=
gZHRijmuCJPk2F4%3Dr8TNjU7x1CjW1zTAdBdQ%40mail.gmail.com</a>.<br />

--94eb2c05f6d6cf096a055ce1ea53--

.