Topic: template argument deduction guides for type aliases
Author: florian.csdt@gmail.com
Date: Fri, 13 Apr 2018 10:12:16 -0700 (PDT)
Raw View
------=_Part_9721_450996706.1523639536050
Content-Type: multipart/alternative;
boundary="----=_Part_9722_34480306.1523639536051"
------=_Part_9722_34480306.1523639536051
Content-Type: text/plain; charset="UTF-8"
Hello everyone,
I was wondering, is there any proposal out there about deduction guides for
type aliases?
I needed this with the following example:
template <class T, int N> struct vec_helper { using type = /* some custom
fallback */; }
template <> struct vec_helper<float, 4> { using type = __m128; };
/* other similar specializations */
template <class T, int N>
using vec = typename vec_helper<T, N>::type;
template <class T, int N>
vec<T, N> vadd(vec<T, N> a, vec<T, N> b);
__m128 a, b;
// vadd(a, b); // could not deduce T nor N
With this example, I cannot call the template function vadd because T and N
could not be deduced.
I completely understand why it cannot be deduced. But there is currently no
way to make this deducible.
Could we have something similar to template class deduction guides?
Is there any proposal for that already?
Florian
--
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/cf52e13f-f1c8-4da4-9a86-0c725bc93efd%40isocpp.org.
------=_Part_9722_34480306.1523639536051
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello everyone,<br><br>I was wondering, is there any propo=
sal out there about deduction guides for type aliases?<br><br>I needed this=
with the following example:<br><div style=3D"background-color: rgb(250, 25=
0, 250); border-color: rgb(187, 187, 187); border-style: solid; border-widt=
h: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"pr=
ettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> vec_helper </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> type </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">/* some custom fall=
back */</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n 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"co=
lor: #008;" class=3D"styled-by-prettify">template</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"><></span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> vec_helper</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">float</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">4</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> type </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> __m128</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">/* other similar specialization=
s */</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> N</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">using<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> vec </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> vec_helper</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> N</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">>::</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">type</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">template</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> N</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>v=
ec</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> N</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> vadd</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">vec</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> N</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> vec</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
N</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br>__m128 a</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// vadd(a, b); // could not deduce T nor</span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify"> N</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><b=
r>With this example, I cannot call the template function vadd because T and=
N could not be deduced.<br>I completely understand why it cannot be deduce=
d. But there is currently no way to make this deducible.<br><br>Could we ha=
ve something similar to template class deduction guides?<br>Is there any pr=
oposal for that already?<br><br>Florian<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/cf52e13f-f1c8-4da4-9a86-0c725bc93efd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/cf52e13f-f1c8-4da4-9a86-0c725bc93efd=
%40isocpp.org</a>.<br />
------=_Part_9722_34480306.1523639536051--
------=_Part_9721_450996706.1523639536050--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Fri, 13 Apr 2018 16:30:45 -0700
Raw View
--00000000000017b0480569c34412
Content-Type: text/plain; charset="UTF-8"
On 13 April 2018 at 10:12, <florian.csdt@gmail.com> wrote:
> Hello everyone,
>
> I was wondering, is there any proposal out there about deduction guides
> for type aliases?
>
> I needed this with the following example:
> template <class T, int N> struct vec_helper { using type = /* some custom
> fallback */; }
> template <> struct vec_helper<float, 4> { using type = __m128; };
> /* other similar specializations */
>
> template <class T, int N>
> using vec = typename vec_helper<T, N>::type;
>
> template <class T, int N>
> vec<T, N> vadd(vec<T, N> a, vec<T, N> b);
>
> __m128 a, b;
> // vadd(a, b); // could not deduce T nor N
>
> With this example, I cannot call the template function vadd because T and
> N could not be deduced.
> I completely understand why it cannot be deduced. But there is currently
> no way to make this deducible.
>
> Could we have something similar to template class deduction guides?
> Is there any proposal for that already?
>
I know this is something that at least Faisal Vali has shown interested in,
but I don't know if he (or anyone else) has put together a proposal.
You actually need two extensions to make the above work:
* "class" template deduction being extended to cover alias templates
* use of the class (and now alias) template deduction rules when
performing deduction for function templates
These are mostly independent extensions: the first would allow
vec v = a; // ok, deduce using 'vec's deduction guides
.... and the second would allow ...
template<typename T> void f(std::vector<T>);
f({1, 2, 3, 4}); // ok, deduce T=int
They both seem like good things to me.
--
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/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_caYeiQ3cXS7xdLzYHQ%40mail.gmail.com.
--00000000000017b0480569c34412
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 1=
3 April 2018 at 10:12, <span dir=3D"ltr"><<a href=3D"mailto:florian.csd=
t@gmail.com" target=3D"_blank">florian.csdt@gmail.com</a>></span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello everyone,<br><br>=
I was wondering, is there any proposal out there about deduction guides for=
type aliases?<br><br>I needed this with the following example:<br><div sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px" class=3D"m_9041357740552045350prettyprint">=
<code class=3D"m_9041357740552045350prettyprint"><div class=3D"m_9041357740=
552045350subprettyprint"><span style=3D"color:#008" class=3D"m_904135774055=
2045350styled-by-prettify">template</span><span style=3D"color:#000" class=
=3D"m_9041357740552045350styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_9041357740552045350styled-by-prettify"><</span><span sty=
le=3D"color:#008" class=3D"m_9041357740552045350styled-by-prettify">class</=
span><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-pre=
ttify"> T</span><span style=3D"color:#660" class=3D"m_9041357740552045350st=
yled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_90413577405=
52045350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_9=
041357740552045350styled-by-prettify">int</span><span style=3D"color:#000" =
class=3D"m_9041357740552045350styled-by-prettify"> N</span><span style=3D"c=
olor:#660" class=3D"m_9041357740552045350styled-by-prettify">></span><sp=
an style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"> =
</span><span style=3D"color:#008" class=3D"m_9041357740552045350styled-by-p=
rettify">struct</span><span style=3D"color:#000" class=3D"m_904135774055204=
5350styled-by-prettify"> vec_helper </span><span style=3D"color:#660" class=
=3D"m_9041357740552045350styled-by-prettify">{</span><span style=3D"color:#=
000" class=3D"m_9041357740552045350styled-by-prettify"> </span><span style=
=3D"color:#008" class=3D"m_9041357740552045350styled-by-prettify">using</sp=
an><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prett=
ify"> type </span><span style=3D"color:#660" class=3D"m_9041357740552045350=
styled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_9041357=
740552045350styled-by-prettify"> </span><span style=3D"color:#800" class=3D=
"m_9041357740552045350styled-by-prettify">/* some custom fallback */</span>=
<span style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify=
">;</span><span style=3D"color:#000" class=3D"m_9041357740552045350styled-b=
y-prettify"> </span><span style=3D"color:#660" class=3D"m_90413577405520453=
50styled-by-prettify">}</span><span style=3D"color:#000" class=3D"m_9041357=
740552045350styled-by-prettify"><br></span><span style=3D"color:#008" class=
=3D"m_9041357740552045350styled-by-prettify">template</span><span style=3D"=
color:#000" class=3D"m_9041357740552045350styled-by-prettify"> </span><span=
style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify"><=
;></span><span style=3D"color:#000" class=3D"m_9041357740552045350styled=
-by-prettify"> </span><span style=3D"color:#008" class=3D"m_904135774055204=
5350styled-by-prettify">struct</span><span style=3D"color:#000" class=3D"m_=
9041357740552045350styled-by-prettify"> vec_helper</span><span style=3D"col=
or:#660" class=3D"m_9041357740552045350styled-by-prettify"><</span><span=
style=3D"color:#008" class=3D"m_9041357740552045350styled-by-prettify">flo=
at</span><span style=3D"color:#660" class=3D"m_9041357740552045350styled-by=
-prettify">,</span><span style=3D"color:#000" class=3D"m_904135774055204535=
0styled-by-prettify"> </span><span style=3D"color:#066" class=3D"m_90413577=
40552045350styled-by-prettify">4</span><span style=3D"color:#660" class=3D"=
m_9041357740552045350styled-by-prettify">></span><span style=3D"color:#0=
00" class=3D"m_9041357740552045350styled-by-prettify"> </span><span style=
=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify">{</span><=
span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"=
> </span><span style=3D"color:#008" class=3D"m_9041357740552045350styled-by=
-prettify">using</span><span style=3D"color:#000" class=3D"m_90413577405520=
45350styled-by-prettify"> type </span><span style=3D"color:#660" class=3D"m=
_9041357740552045350styled-by-prettify">=3D</span><span style=3D"color:#000=
" class=3D"m_9041357740552045350styled-by-prettify"> __m128</span><span sty=
le=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify">;</span=
><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettif=
y"> </span><span style=3D"color:#660" class=3D"m_9041357740552045350styled-=
by-prettify">};</span><span style=3D"color:#000" class=3D"m_904135774055204=
5350styled-by-prettify"><br></span><span style=3D"color:#800" class=3D"m_90=
41357740552045350styled-by-prettify">/* other similar specializations */</s=
pan><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-pret=
tify"><br><br></span><span style=3D"color:#008" class=3D"m_9041357740552045=
350styled-by-prettify">template</span><span style=3D"color:#000" class=3D"m=
_9041357740552045350styled-by-prettify"> </span><span style=3D"color:#660" =
class=3D"m_9041357740552045350styled-by-prettify"><</span><span style=3D=
"color:#008" class=3D"m_9041357740552045350styled-by-prettify">class</span>=
<span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify=
"> T</span><span style=3D"color:#660" class=3D"m_9041357740552045350styled-=
by-prettify">,</span><span style=3D"color:#000" class=3D"m_9041357740552045=
350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_904135=
7740552045350styled-by-prettify">int</span><span style=3D"color:#000" class=
=3D"m_9041357740552045350styled-by-prettify"> N</span><span style=3D"color:=
#660" class=3D"m_9041357740552045350styled-by-prettify">></span><span st=
yle=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"><br></=
span><span style=3D"color:#008" class=3D"m_9041357740552045350styled-by-pre=
ttify">using</span><span style=3D"color:#000" class=3D"m_904135774055204535=
0styled-by-prettify"> vec </span><span style=3D"color:#660" class=3D"m_9041=
357740552045350styled-by-prettify">=3D</span><span style=3D"color:#000" cla=
ss=3D"m_9041357740552045350styled-by-prettify"> </span><span style=3D"color=
:#008" class=3D"m_9041357740552045350styled-by-prettify">typename</span><sp=
an style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"> =
vec_helper</span><span style=3D"color:#660" class=3D"m_9041357740552045350s=
tyled-by-prettify"><</span><span style=3D"color:#000" class=3D"m_9041357=
740552045350styled-by-prettify">T</span><span style=3D"color:#660" class=3D=
"m_9041357740552045350styled-by-prettify">,</span><span style=3D"color:#000=
" class=3D"m_9041357740552045350styled-by-prettify"> N</span><span style=3D=
"color:#660" class=3D"m_9041357740552045350styled-by-prettify">>::</span=
><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettif=
y">type</span><span style=3D"color:#660" class=3D"m_9041357740552045350styl=
ed-by-prettify">;</span><span style=3D"color:#000" class=3D"m_9041357740552=
045350styled-by-prettify"><br><br></span><span style=3D"color:#008" class=
=3D"m_9041357740552045350styled-by-prettify">template</span><span style=3D"=
color:#000" class=3D"m_9041357740552045350styled-by-prettify"> </span><span=
style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify"><=
;</span><span style=3D"color:#008" class=3D"m_9041357740552045350styled-by-=
prettify">class</span><span style=3D"color:#000" class=3D"m_904135774055204=
5350styled-by-prettify"> T</span><span style=3D"color:#660" class=3D"m_9041=
357740552045350styled-by-prettify">,</span><span style=3D"color:#000" class=
=3D"m_9041357740552045350styled-by-prettify"> </span><span style=3D"color:#=
008" class=3D"m_9041357740552045350styled-by-prettify">int</span><span styl=
e=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"> N</span=
><span style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettif=
y">></span><span style=3D"color:#000" class=3D"m_9041357740552045350styl=
ed-by-prettify"><br>vec</span><span style=3D"color:#660" class=3D"m_9041357=
740552045350styled-by-prettify"><</span><span style=3D"color:#000" class=
=3D"m_9041357740552045350styled-by-prettify">T</span><span style=3D"color:#=
660" class=3D"m_9041357740552045350styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"> N</span>=
<span style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify=
">></span><span style=3D"color:#000" class=3D"m_9041357740552045350style=
d-by-prettify"> vadd</span><span style=3D"color:#660" class=3D"m_9041357740=
552045350styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_=
9041357740552045350styled-by-prettify">vec</span><span style=3D"color:#660"=
class=3D"m_9041357740552045350styled-by-prettify"><</span><span style=
=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify">T</span><=
span style=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify"=
>,</span><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by=
-prettify"> N</span><span style=3D"color:#660" class=3D"m_90413577405520453=
50styled-by-prettify">></span><span style=3D"color:#000" class=3D"m_9041=
357740552045350styled-by-prettify"> a</span><span style=3D"color:#660" clas=
s=3D"m_9041357740552045350styled-by-prettify">,</span><span style=3D"color:=
#000" class=3D"m_9041357740552045350styled-by-prettify"> vec</span><span st=
yle=3D"color:#660" class=3D"m_9041357740552045350styled-by-prettify"><</=
span><span style=3D"color:#000" class=3D"m_9041357740552045350styled-by-pre=
ttify">T</span><span style=3D"color:#660" class=3D"m_9041357740552045350sty=
led-by-prettify">,</span><span style=3D"color:#000" class=3D"m_904135774055=
2045350styled-by-prettify"> N</span><span style=3D"color:#660" class=3D"m_9=
041357740552045350styled-by-prettify">></span><span style=3D"color:#000"=
class=3D"m_9041357740552045350styled-by-prettify"> b</span><span style=3D"=
color:#660" class=3D"m_9041357740552045350styled-by-prettify">);</span><spa=
n style=3D"color:#000" class=3D"m_9041357740552045350styled-by-prettify"><b=
r><br>__m128 a</span><span style=3D"color:#660" class=3D"m_9041357740552045=
350styled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_904135=
7740552045350styled-by-prettify"> b</span><span style=3D"color:#660" class=
=3D"m_9041357740552045350styled-by-prettify">;</span><span style=3D"color:#=
000" class=3D"m_9041357740552045350styled-by-prettify"><br></span><span sty=
le=3D"color:#800" class=3D"m_9041357740552045350styled-by-prettify">// vadd=
(a, b); // could not deduce T nor</span><span style=3D"color:#800" class=3D=
"m_9041357740552045350styled-by-prettify"> N</span><span style=3D"color:#00=
0" class=3D"m_9041357740552045350styled-by-prettify"><br></span></div></cod=
e></div><br>With this example, I cannot call the template function vadd bec=
ause T and N could not be deduced.<br>I completely understand why it cannot=
be deduced. But there is currently no way to make this deducible.<br><br>C=
ould we have something similar to template class deduction guides?<br>Is th=
ere any proposal for that already?</div></blockquote><div><br></div><div>I =
know this is something that at least Faisal Vali has shown interested in, b=
ut I don't know if he (or anyone else) has put together a proposal.</di=
v><div><br></div><div>You actually need two extensions to make the above wo=
rk:</div><div>=C2=A0* "class" template deduction being extended t=
o cover alias templates</div><div>=C2=A0* use of the class (and now alias) =
template deduction rules when performing deduction for function templates</=
div><div><br></div><div>These are mostly independent extensions: the first =
would allow</div><div><br></div><div>vec v =3D a;=C2=A0 // ok, deduce using=
'vec's deduction guides</div><div><br></div><div>... and the secon=
d would allow ...</div><div><br></div><div>template<typename T> void =
f(std::vector<T>);</div><div>f({1, 2, 3, 4});=C2=A0 // ok, deduce T=
=3Dint</div><div><br></div><div>They both seem like good things to me.</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" 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/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_ca=
YeiQ3cXS7xdLzYHQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqnT_z1Px9=
f1d3vhP3%2B20O6j2x1_caYeiQ3cXS7xdLzYHQ%40mail.gmail.com</a>.<br />
--00000000000017b0480569c34412--
.
Author: John McFarlane <john@mcfarlane.name>
Date: Sat, 14 Apr 2018 23:59:33 +0000
Raw View
--94eb2c14c4de5c688b0569d7c807
Content-Type: text/plain; charset="UTF-8"
On Fri, Apr 13, 2018 at 4:31 PM Richard Smith <richard@metafoo.co.uk> wrote:
> On 13 April 2018 at 10:12, <florian.csdt@gmail.com> wrote:
>
>> Hello everyone,
>>
>> I was wondering, is there any proposal out there about deduction guides
>> for type aliases?
>>
>> I needed this with the following example:
>> template <class T, int N> struct vec_helper { using type = /* some
>> custom fallback */; }
>> template <> struct vec_helper<float, 4> { using type = __m128; };
>> /* other similar specializations */
>>
>> template <class T, int N>
>> using vec = typename vec_helper<T, N>::type;
>>
>> template <class T, int N>
>> vec<T, N> vadd(vec<T, N> a, vec<T, N> b);
>>
>> __m128 a, b;
>> // vadd(a, b); // could not deduce T nor N
>>
>> With this example, I cannot call the template function vadd because T and
>> N could not be deduced.
>> I completely understand why it cannot be deduced. But there is currently
>> no way to make this deducible.
>>
>> Could we have something similar to template class deduction guides?
>> Is there any proposal for that already?
>>
>
> I know this is something that at least Faisal Vali has shown interested
> in, but I don't know if he (or anyone else) has put together a proposal.
>
> You actually need two extensions to make the above work:
> * "class" template deduction being extended to cover alias templates
> * use of the class (and now alias) template deduction rules when
> performing deduction for function templates
>
> These are mostly independent extensions: the first would allow
>
> vec v = a; // ok, deduce using 'vec's deduction guides
>
> ... and the second would allow ...
>
> template<typename T> void f(std::vector<T>);
> f({1, 2, 3, 4}); // ok, deduce T=int
>
> They both seem like good things to me.
>
I have a specific feature which would greatly benefit from the former
extension involving numeric types which are composed using aliases, e.g.:
https://godbolt.org/g/QxjQxv
> --
> 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/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_caYeiQ3cXS7xdLzYHQ%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_caYeiQ3cXS7xdLzYHQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnRnDOcfJ%3D8MrEphFLbA1CLyTNukxRKbnNjWV4is-QzuhA%40mail.gmail.com.
--94eb2c14c4de5c688b0569d7c807
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_quote"><div dir=3D"ltr">On Fri, Apr 13=
, 2018 at 4:31 PM Richard Smith <<a href=3D"mailto:richard@metafoo.co.uk=
">richard@metafoo.co.uk</a>> wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
On 13 April 2018 at 10:12, <span dir=3D"ltr"><<a href=3D"mailto:florian=
..csdt@gmail.com" target=3D"_blank">florian.csdt@gmail.com</a>></span> wr=
ote:<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">Hello everyone,<br>=
<br>I was wondering, is there any proposal out there about deduction guides=
for type aliases?<br><br>I needed this with the following example:<br><div=
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);b=
order-style:solid;border-width:1px" class=3D"m_-8435805654511548937m_904135=
7740552045350prettyprint"><code class=3D"m_-8435805654511548937m_9041357740=
552045350prettyprint"><div class=3D"m_-8435805654511548937m_904135774055204=
5350subprettyprint"><span style=3D"color:#008" class=3D"m_-8435805654511548=
937m_9041357740552045350styled-by-prettify">template</span><span style=3D"c=
olor:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pr=
ettify"> </span><span style=3D"color:#660" class=3D"m_-8435805654511548937m=
_9041357740552045350styled-by-prettify"><</span><span style=3D"color:#00=
8" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">=
class</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_904=
1357740552045350styled-by-prettify"> T</span><span style=3D"color:#660" cla=
ss=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">,</spa=
n><span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552=
045350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-84=
35805654511548937m_9041357740552045350styled-by-prettify">int</span><span s=
tyle=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350sty=
led-by-prettify"> N</span><span style=3D"color:#660" class=3D"m_-8435805654=
511548937m_9041357740552045350styled-by-prettify">></span><span style=3D=
"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-=
prettify"> </span><span style=3D"color:#008" class=3D"m_-843580565451154893=
7m_9041357740552045350styled-by-prettify">struct</span><span style=3D"color=
:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pretti=
fy"> vec_helper </span><span style=3D"color:#660" class=3D"m_-8435805654511=
548937m_9041357740552045350styled-by-prettify">{</span><span style=3D"color=
:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pretti=
fy"> </span><span style=3D"color:#008" class=3D"m_-8435805654511548937m_904=
1357740552045350styled-by-prettify">using</span><span style=3D"color:#000" =
class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify"> ty=
pe </span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_90413=
57740552045350styled-by-prettify">=3D</span><span style=3D"color:#000" clas=
s=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify"> </span=
><span style=3D"color:#800" class=3D"m_-8435805654511548937m_90413577405520=
45350styled-by-prettify">/* some custom fallback */</span><span style=3D"co=
lor:#660" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pre=
ttify">;</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_=
9041357740552045350styled-by-prettify"> </span><span style=3D"color:#660" c=
lass=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">}</s=
pan><span style=3D"color:#000" class=3D"m_-8435805654511548937m_90413577405=
52045350styled-by-prettify"><br></span><span style=3D"color:#008" class=3D"=
m_-8435805654511548937m_9041357740552045350styled-by-prettify">template</sp=
an><span style=3D"color:#000" class=3D"m_-8435805654511548937m_904135774055=
2045350styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-8=
435805654511548937m_9041357740552045350styled-by-prettify"><></span><=
span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045=
350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-84358=
05654511548937m_9041357740552045350styled-by-prettify">struct</span><span s=
tyle=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350sty=
led-by-prettify"> vec_helper</span><span style=3D"color:#660" class=3D"m_-8=
435805654511548937m_9041357740552045350styled-by-prettify"><</span><span=
style=3D"color:#008" class=3D"m_-8435805654511548937m_9041357740552045350s=
tyled-by-prettify">float</span><span style=3D"color:#660" class=3D"m_-84358=
05654511548937m_9041357740552045350styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-=
by-prettify"> </span><span style=3D"color:#066" class=3D"m_-843580565451154=
8937m_9041357740552045350styled-by-prettify">4</span><span style=3D"color:#=
660" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify=
">></span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_90=
41357740552045350styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">{</spa=
n><span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552=
045350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-84=
35805654511548937m_9041357740552045350styled-by-prettify">using</span><span=
style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350s=
tyled-by-prettify"> type </span><span style=3D"color:#660" class=3D"m_-8435=
805654511548937m_9041357740552045350styled-by-prettify">=3D</span><span sty=
le=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350style=
d-by-prettify"> __m128</span><span style=3D"color:#660" class=3D"m_-8435805=
654511548937m_9041357740552045350styled-by-prettify">;</span><span style=3D=
"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-=
prettify"> </span><span style=3D"color:#660" class=3D"m_-843580565451154893=
7m_9041357740552045350styled-by-prettify">};</span><span style=3D"color:#00=
0" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">=
<br></span><span style=3D"color:#800" class=3D"m_-8435805654511548937m_9041=
357740552045350styled-by-prettify">/* other similar specializations */</spa=
n><span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552=
045350styled-by-prettify"><br><br></span><span style=3D"color:#008" class=
=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">template=
</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_90413577=
40552045350styled-by-prettify"> </span><span style=3D"color:#660" class=3D"=
m_-8435805654511548937m_9041357740552045350styled-by-prettify"><</span><=
span style=3D"color:#008" class=3D"m_-8435805654511548937m_9041357740552045=
350styled-by-prettify">class</span><span style=3D"color:#000" class=3D"m_-8=
435805654511548937m_9041357740552045350styled-by-prettify"> T</span><span s=
tyle=3D"color:#660" class=3D"m_-8435805654511548937m_9041357740552045350sty=
led-by-prettify">,</span><span style=3D"color:#000" class=3D"m_-84358056545=
11548937m_9041357740552045350styled-by-prettify"> </span><span style=3D"col=
or:#008" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pret=
tify">int</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m=
_9041357740552045350styled-by-prettify"> N</span><span style=3D"color:#660"=
class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">&g=
t;</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_904135=
7740552045350styled-by-prettify"><br></span><span style=3D"color:#008" clas=
s=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">using</=
span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740=
552045350styled-by-prettify"> vec </span><span style=3D"color:#660" class=
=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">=3D</spa=
n><span style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552=
045350styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-84=
35805654511548937m_9041357740552045350styled-by-prettify">typename</span><s=
pan style=3D"color:#000" class=3D"m_-8435805654511548937m_90413577405520453=
50styled-by-prettify"> vec_helper</span><span style=3D"color:#660" class=3D=
"m_-8435805654511548937m_9041357740552045350styled-by-prettify"><</span>=
<span style=3D"color:#000" class=3D"m_-8435805654511548937m_904135774055204=
5350styled-by-prettify">T</span><span style=3D"color:#660" class=3D"m_-8435=
805654511548937m_9041357740552045350styled-by-prettify">,</span><span style=
=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-=
by-prettify"> N</span><span style=3D"color:#660" class=3D"m_-84358056545115=
48937m_9041357740552045350styled-by-prettify">>::</span><span style=3D"c=
olor:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pr=
ettify">type</span><span style=3D"color:#660" class=3D"m_-84358056545115489=
37m_9041357740552045350styled-by-prettify">;</span><span style=3D"color:#00=
0" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">=
<br><br></span><span style=3D"color:#008" class=3D"m_-8435805654511548937m_=
9041357740552045350styled-by-prettify">template</span><span style=3D"color:=
#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettif=
y"> </span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_9041=
357740552045350styled-by-prettify"><</span><span style=3D"color:#008" cl=
ass=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">class=
</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_90413577=
40552045350styled-by-prettify"> T</span><span style=3D"color:#660" class=3D=
"m_-8435805654511548937m_9041357740552045350styled-by-prettify">,</span><sp=
an style=3D"color:#000" class=3D"m_-8435805654511548937m_904135774055204535=
0styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-8435805=
654511548937m_9041357740552045350styled-by-prettify">int</span><span style=
=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-=
by-prettify"> N</span><span style=3D"color:#660" class=3D"m_-84358056545115=
48937m_9041357740552045350styled-by-prettify">></span><span style=3D"col=
or:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pret=
tify"><br>vec</span><span style=3D"color:#660" class=3D"m_-8435805654511548=
937m_9041357740552045350styled-by-prettify"><</span><span style=3D"color=
:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pretti=
fy">T</span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_904=
1357740552045350styled-by-prettify">,</span><span style=3D"color:#000" clas=
s=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify"> N</spa=
n><span style=3D"color:#660" class=3D"m_-8435805654511548937m_9041357740552=
045350styled-by-prettify">></span><span style=3D"color:#000" class=3D"m_=
-8435805654511548937m_9041357740552045350styled-by-prettify"> vadd</span><s=
pan style=3D"color:#660" class=3D"m_-8435805654511548937m_90413577405520453=
50styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_-843580=
5654511548937m_9041357740552045350styled-by-prettify">vec</span><span style=
=3D"color:#660" class=3D"m_-8435805654511548937m_9041357740552045350styled-=
by-prettify"><</span><span style=3D"color:#000" class=3D"m_-843580565451=
1548937m_9041357740552045350styled-by-prettify">T</span><span style=3D"colo=
r:#660" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prett=
ify">,</span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_90=
41357740552045350styled-by-prettify"> N</span><span style=3D"color:#660" cl=
ass=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify">><=
/span><span style=3D"color:#000" class=3D"m_-8435805654511548937m_904135774=
0552045350styled-by-prettify"> a</span><span style=3D"color:#660" class=3D"=
m_-8435805654511548937m_9041357740552045350styled-by-prettify">,</span><spa=
n style=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350=
styled-by-prettify"> vec</span><span style=3D"color:#660" class=3D"m_-84358=
05654511548937m_9041357740552045350styled-by-prettify"><</span><span sty=
le=3D"color:#000" class=3D"m_-8435805654511548937m_9041357740552045350style=
d-by-prettify">T</span><span style=3D"color:#660" class=3D"m_-8435805654511=
548937m_9041357740552045350styled-by-prettify">,</span><span style=3D"color=
:#000" class=3D"m_-8435805654511548937m_9041357740552045350styled-by-pretti=
fy"> N</span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_90=
41357740552045350styled-by-prettify">></span><span style=3D"color:#000" =
class=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify"> b<=
/span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_904135774=
0552045350styled-by-prettify">);</span><span style=3D"color:#000" class=3D"=
m_-8435805654511548937m_9041357740552045350styled-by-prettify"><br><br>__m1=
28 a</span><span style=3D"color:#660" class=3D"m_-8435805654511548937m_9041=
357740552045350styled-by-prettify">,</span><span style=3D"color:#000" class=
=3D"m_-8435805654511548937m_9041357740552045350styled-by-prettify"> b</span=
><span style=3D"color:#660" class=3D"m_-8435805654511548937m_90413577405520=
45350styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_-843=
5805654511548937m_9041357740552045350styled-by-prettify"><br></span><span s=
tyle=3D"color:#800" class=3D"m_-8435805654511548937m_9041357740552045350sty=
led-by-prettify">// vadd(a, b); // could not deduce T nor</span><span style=
=3D"color:#800" class=3D"m_-8435805654511548937m_9041357740552045350styled-=
by-prettify"> N</span><span style=3D"color:#000" class=3D"m_-84358056545115=
48937m_9041357740552045350styled-by-prettify"><br></span></div></code></div=
><br>With this example, I cannot call the template function vadd because T =
and N could not be deduced.<br>I completely understand why it cannot be ded=
uced. But there is currently no way to make this deducible.<br><br>Could we=
have something similar to template class deduction guides?<br>Is there any=
proposal for that already?</div></blockquote><div><br></div></div></div></=
div><div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
<div>I know this is something that at least Faisal Vali has shown intereste=
d in, but I don't know if he (or anyone else) has put together a propos=
al.</div><div><br></div><div>You actually need two extensions to make the a=
bove work:</div><div>=C2=A0* "class" template deduction being ext=
ended to cover alias templates</div><div>=C2=A0* use of the class (and now =
alias) template deduction rules when performing deduction for function temp=
lates</div><div><br></div><div>These are mostly independent extensions: the=
first would allow</div><div><br></div><div>vec v =3D a;=C2=A0 // ok, deduc=
e using 'vec's deduction guides</div><div><br></div><div>... and th=
e second would allow ...</div><div><br></div><div>template<typename T>=
; void f(std::vector<T>);</div><div>f({1, 2, 3, 4});=C2=A0 // ok, ded=
uce T=3Dint</div><div><br></div><div>They both seem like good things to me.=
</div></div></div></div></blockquote><div><br></div><div>I have a specific =
feature which would greatly benefit from the former extension involving num=
eric types which are composed using aliases, e.g.:<br><a href=3D"https://go=
dbolt.org/g/QxjQxv">https://godbolt.org/g/QxjQxv</a></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_ca=
YeiQ3cXS7xdLzYHQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAOfiQqnT_z1Px9f1d3vhP3%2B20O6j2x1_caYeiQ3cXS7xdLzYHQ%40mail.gmail.c=
om</a>.<br>
</blockquote></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/CABPJVnRnDOcfJ%3D8MrEphFLbA1CLyTNukxR=
KbnNjWV4is-QzuhA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CABPJVnRnDOcfJ%=
3D8MrEphFLbA1CLyTNukxRKbnNjWV4is-QzuhA%40mail.gmail.com</a>.<br />
--94eb2c14c4de5c688b0569d7c807--
.
Author: florian.csdt@gmail.com
Date: Sun, 15 Apr 2018 04:50:08 -0700 (PDT)
Raw View
------=_Part_17858_1365313483.1523793008718
Content-Type: multipart/alternative;
boundary="----=_Part_17859_1960752116.1523793008718"
------=_Part_17859_1960752116.1523793008718
Content-Type: text/plain; charset="UTF-8"
@John I fail to see how it helps...
@Richard I don't get why the two deduction should be different
mechanisms... Or maybe you're seeing much ahead that I can do, and thinking
about the standard itself.
Could you elaborate a bit more?
--
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/eca2e59a-5119-4977-bf05-838581b3f452%40isocpp.org.
------=_Part_17859_1960752116.1523793008718
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">@John I fail to see how it helps...<br><br>@Richard I don&=
#39;t get why the two deduction should be different mechanisms... Or maybe =
you're seeing much ahead that I can do, and thinking about the standard=
itself.<br>Could you elaborate a bit more?<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/eca2e59a-5119-4977-bf05-838581b3f452%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eca2e59a-5119-4977-bf05-838581b3f452=
%40isocpp.org</a>.<br />
------=_Part_17859_1960752116.1523793008718--
------=_Part_17858_1365313483.1523793008718--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Sun, 15 Apr 2018 14:27:45 -0700
Raw View
--000000000000ef67510569e9c71b
Content-Type: text/plain; charset="UTF-8"
On 15 April 2018 at 04:50, <florian.csdt@gmail.com> wrote:
> @John I fail to see how it helps...
>
> @Richard I don't get why the two deduction should be different
> mechanisms... Or maybe you're seeing much ahead that I can do, and thinking
> about the standard itself.
> Could you elaborate a bit more?
>
Which two deductions? I'm not saying there should be different mechanisms,
I'm saying there should probably be only one mechanism. But there are (at
least) two different places where we have multiple mechanisms that would
need to be unified to support your example, as described in my prior email.
--
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/CAOfiQq%3D-ArUpZSjiBug9FB0KWxiiyKCWPV2oWowkwU7c4JnALw%40mail.gmail.com.
--000000000000ef67510569e9c71b
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 1=
5 April 2018 at 04:50, <span dir=3D"ltr"><<a href=3D"mailto:florian.csd=
t@gmail.com" target=3D"_blank">florian.csdt@gmail.com</a>></span> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">@John I fail to see how=
it helps...<br><br>@Richard I don't get why the two deduction should b=
e different mechanisms... Or maybe you're seeing much ahead that I can =
do, and thinking about the standard itself.<br>Could you elaborate a bit mo=
re?</div></blockquote><div><br></div><div>Which two deductions? I'm not=
saying there should be different mechanisms, I'm saying there should p=
robably be only one mechanism. But there are (at least) two different place=
s where we have multiple mechanisms that would need to be unified to suppor=
t your example, as described in my prior email.<br></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" 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/CAOfiQq%3D-ArUpZSjiBug9FB0KWxiiyKCWPV=
2oWowkwU7c4JnALw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQq%3D-ArUp=
ZSjiBug9FB0KWxiiyKCWPV2oWowkwU7c4JnALw%40mail.gmail.com</a>.<br />
--000000000000ef67510569e9c71b--
.
Author: florian.csdt@gmail.com
Date: Sun, 15 Apr 2018 15:29:56 -0700 (PDT)
Raw View
------=_Part_19813_692297439.1523831396509
Content-Type: multipart/alternative;
boundary="----=_Part_19814_1408424888.1523831396509"
------=_Part_19814_1408424888.1523831396509
Content-Type: text/plain; charset="UTF-8"
Ok, now I get it. There is two different contexts where the deduction could
take place.
To be fair, the "auto"-like deduction might be simpler to standardize (no
need to extract template parameters), but right now I would be more
interested in the template parameter deduction.
Is the template class deduction guide syntax, somehow, applicable to
template aliases? What would be the problems?
--
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/bdae2d64-0800-4d07-bbd8-44a9622090d2%40isocpp.org.
------=_Part_19814_1408424888.1523831396509
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Ok, now I get it. There is two different contexts where th=
e deduction could take place.<br>To be fair, the "auto"-like dedu=
ction might be simpler to standardize (no need to extract template paramete=
rs), but right now I would be more interested in the template parameter ded=
uction.<br><br>Is the template class deduction guide syntax, somehow, appli=
cable to template aliases? What would be the problems?<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/bdae2d64-0800-4d07-bbd8-44a9622090d2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/bdae2d64-0800-4d07-bbd8-44a9622090d2=
%40isocpp.org</a>.<br />
------=_Part_19814_1408424888.1523831396509--
------=_Part_19813_692297439.1523831396509--
.