Topic: Variadic template template problem: the issue


Author: Marc <marc.glisse@gmail.com>
Date: Fri, 13 Sep 2013 03:46:04 -0700 (PDT)
Raw View
------=_Part_1129_8812509.1379069164636
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Le vendredi 13 septembre 2013 12:24:38 UTC+2, VinceRev a =E9crit :

>
> A very common problem with templates templates can be illustrated with th=
e=20
> following:
>
> #include <iostream>
> #include <array>
> #include <tuple>
>
> template <template<class...> class T, class... U>
> void f(const T<U...>& x)
> {std::cout<<std::get<0>(x)<<std::endl;}
>
> int main()
> {
>    std::tuple<int, int> tuple{};
>    std::array<int, 2> array{};
>    f(tuple);
>    f(array); // Big problem here
>    return 0;
> }
>
> As an array has a non-type template parameter, everything fails.
>

Yes, that's a common pitfall that can indeed be a pain to work around. But=
=20
you are giving an example where you only use T and U as T<U...> so you=20
might as well declare f(Z const&). You really should give a few examples=20
where you need T and U separately and show how a new syntax could actually=
=20
work for them.

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_1129_8812509.1379069164636
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Le vendredi 13 septembre 2013 12:24:38 UTC+2, VinceRev a =
=E9crit&nbsp;:<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><br>A very common problem with templates templates can be illustrated =
with the following:<br><br><span style=3D"font-family:courier new,monospace=
">#include &lt;iostream&gt;<br>#include &lt;array&gt;<br>#include &lt;tuple=
&gt;<br><br>template &lt;template&lt;class...&gt; class T, class... U&gt;<b=
r>void f(const T&lt;U...&gt;&amp; x)<br>{std::cout&lt;&lt;std::get&lt;0&gt;=
(x)&lt;&lt;<wbr>std::endl;}<br><br>int main()<br>{<br>&nbsp;&nbsp; std::tup=
le&lt;int, int&gt; tuple{};<br>&nbsp;&nbsp; std::array&lt;int, 2&gt; array{=
};<br>&nbsp;&nbsp; f(tuple);<br>&nbsp;&nbsp; f(array); // Big problem here<=
br>&nbsp;&nbsp; return 0;<br>}</span><br><br>As an array has a non-type tem=
plate parameter, everything fails.<br></div></blockquote><div><br>Yes, that=
's a common pitfall that can indeed be a pain to work around. But you are g=
iving an example where you only use T and U as T&lt;U...&gt; so you might a=
s well declare f(Z const&amp;). You really should give a few examples where=
 you need T and U separately and show how a new syntax could actually work =
for them.<br></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1129_8812509.1379069164636--

.


Author: David Krauss <potswa@gmail.com>
Date: Fri, 13 Sep 2013 05:31:30 -0700 (PDT)
Raw View
------=_Part_1359_14354495.1379075490072
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable



On Friday, September 13, 2013 6:46:04 PM UTC+8, Marc wrote:
>
> Le vendredi 13 septembre 2013 12:24:38 UTC+2, VinceRev a =E9crit :
>
>>
>> A very common problem with templates templates can be illustrated with=
=20
>> the following:
>>
>> #include <iostream>
>> #include <array>
>> #include <tuple>
>>
>> template <template<class...> class T, class... U>
>> void f(const T<U...>& x)
>> {std::cout<<std::get<0>(x)<<std::endl;}
>>
>> int main()
>> {
>>    std::tuple<int, int> tuple{};
>>    std::array<int, 2> array{};
>>    f(tuple);
>>    f(array); // Big problem here
>>    return 0;
>> }
>>
>> As an array has a non-type template parameter, everything fails.
>>
>
> Yes, that's a common pitfall that can indeed be a pain to work around. Bu=
t=20
> you are giving an example where you only use T and U as T<U...> so you=20
> might as well declare f(Z const&). You really should give a few examples=
=20
> where you need T and U separately and show how a new syntax could actuall=
y=20
> work for them.
>

It's exacerbated by the way default arguments fail to affect template=20
template parameter parameters. (Not a st st stutter.)

template< typename, typename, int =3D 0 >
class x {};

template< typename t, typename u >
using a =3D x< t, u >;

template< template< typename, typename > class >
class q {};

template< template< typename ... > class >
class r {};

q< x > o1; // Error
q< a > o2; // OK

r< x > o3; // Error
r< a > o4; // OK

Despite a parameter being "optional," and in practice even a mere=20
implementation detail (e.g. idiomatic SFINAE), it must be accessible=20
through the template template parameter. But since an alias template is a=
=20
valid template template parameter argument, you can restrict the template=
=20
before passing it, which makes it work.

It's an unnecessary hoop to jump through. The template template parameter=
=20
should define a protocol, and accept arguments that conform to that=20
protocol, not any argument for which that protocol can generate the full=20
range of specializations, plus invalid specializations in the case of a=20
variadic template template parameter matched to an n-adic argument.

On the bright side=85

Given a template (even from a library) with a non-type argument, you can=20
define an alias template mapping that non-type to std::integral_constant.

template< typename, typename, int >
class x {}; // The library type

template< typename t, typename u, typename v >
using a =3D x< t, u, v::value >; // v is (similar to) an integral_constant<=
=20
int, N >

Marc sort-of has a point=85 without a default argument or compatibility=20
mapping to integral_constant, there is little you could do with an=20
unspecializable template template parameter. There is at least one=20
application though: mapping templates to types.

template< template< ... > class >
struct template_tag {}; // A unique, empty type for any template.

template< template< ... > class t >
struct template_identity
    { using template_ =3D t; }; // Template identity function: do not=20
(re)bind any arguments.


--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_1359_14354495.1379075490072
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, September 13, 2013 6:46:04 PM UTC+8, Ma=
rc 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">Le v=
endredi 13 septembre 2013 12:24:38 UTC+2, VinceRev a =E9crit&nbsp;:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br>A very common prob=
lem with templates templates can be illustrated with the following:<br><br>=
<span style=3D"font-family:courier new,monospace">#include &lt;iostream&gt;=
<br>#include &lt;array&gt;<br>#include &lt;tuple&gt;<br><br>template &lt;te=
mplate&lt;class...&gt; class T, class... U&gt;<br>void f(const T&lt;U...&gt=
;&amp; x)<br>{std::cout&lt;&lt;std::get&lt;0&gt;(x)&lt;&lt;<wbr>std::endl;}=
<br><br>int main()<br>{<br>&nbsp;&nbsp; std::tuple&lt;int, int&gt; tuple{};=
<br>&nbsp;&nbsp; std::array&lt;int, 2&gt; array{};<br>&nbsp;&nbsp; f(tuple)=
;<br>&nbsp;&nbsp; f(array); // Big problem here<br>&nbsp;&nbsp; return 0;<b=
r>}</span><br><br>As an array has a non-type template parameter, everything=
 fails.<br></div></blockquote><div><br>Yes, that's a common pitfall that ca=
n indeed be a pain to work around. But you are giving an example where you =
only use T and U as T&lt;U...&gt; so you might as well declare f(Z const&am=
p;). You really should give a few examples where you need T and U separatel=
y and show how a new syntax could actually work for them.<br></div></div></=
blockquote><div><br>It's exacerbated by the way default arguments fail to a=
ffect template template parameter parameters. (Not a st st stutter.)<br><br=
><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); =
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; w=
ord-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><s=
pan 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"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">typename</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> t</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> u </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> x</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><spa=
n 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"> u </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">template</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&lt;</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"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan 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"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">cl=
ass</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> q </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">template</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">template</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> r </span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br>q</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 x </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> o1</span><sp=
an 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=
: #800;" class=3D"styled-by-prettify">// Error</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br>q</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> o2</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: #800;" class=3D"styled-by-prettify">// OK</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>r</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> o3</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: #800;" class=3D"styled-b=
y-prettify">// Error</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>r</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> o4</span><spa=
n 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=
: #800;" class=3D"styled-by-prettify">// OK</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span></div></code></div><br>Despite =
a parameter being "optional," and in practice even a mere implementation de=
tail (e.g. idiomatic SFINAE), it must be accessible through the template te=
mplate parameter. But since an alias template is a valid template template =
parameter argument, you can restrict the template before passing it, which =
makes it work.<br><br>It's an unnecessary hoop to jump through. The templat=
e template parameter should define a protocol, and accept arguments that co=
nform to that protocol, not any argument for which that protocol can genera=
te the full range of specializations, plus invalid specializations in the c=
ase of a variadic template template parameter matched to an n-adic argument=
..<br><br>On the bright side=85<br><br>Given a template (even from a library=
) with a non-type argument, you can define an alias template mapping that n=
on-type to <span style=3D"font-family: courier new,monospace;">std::integra=
l_constant</span>.<br><br><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">template</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">typ=
ename</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
x </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">// The library type</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"colo=
r: #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"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> u</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: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> v </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&lt;</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"> u</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> v</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">value </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"sty=
led-by-prettify">// v is (similar to) an integral_constant&lt; int, N &gt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
</div></code></div><br>Marc sort-of has a point=85 without a default argume=
nt or compatibility mapping to integral_constant, there is little you could=
 do with an unspecializable template template parameter. There is at least =
one application though: mapping templates to types.<br><br><div class=3D"pr=
ettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">template</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> template_tag </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: #800;" class=3D"s=
tyled-by-prettify">// A unique, empty type for any template.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">template</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> t </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> template_identity<br>&nbsp; &nbsp; </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> template_ </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" c=
lass=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"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">// Template ide=
ntity function: do not (re)bind any arguments.</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span></div></code></div><br><br><=
/div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1359_14354495.1379075490072--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 17 Sep 2013 22:16:12 -0700 (PDT)
Raw View
------=_Part_235_1733993.1379481372220
Content-Type: text/plain; charset=ISO-8859-1



On Friday, September 13, 2013 8:31:30 PM UTC+8, David Krauss wrote:
>
>
> template< template< ... > class >
> struct template_tag {}; // A unique, empty type for any template.
>
> template< template< ... > class t >
> struct template_identity
>     { using template_ = t; }; // Template identity function: do not
> (re)bind any arguments.
>

Forgot one. Unlike the above, this is actually a real example from my
utility library:

template< template< typename ... > class a, template< typename ... > classb
>
struct is_same_template : std::false_type {};

template< template< typename ... > class a >
struct is_same_template< a, a > : std::true_type {};



--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_235_1733993.1379481372220
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, September 13, 2013 8:31:30 PM UTC+8, Da=
vid Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><br><div><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><=
code><div><span style=3D"color:#008">template</span><span style=3D"color:#6=
60">&lt;</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">template</span><span style=3D"color:#660">&lt;</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">...</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">&gt;</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">class</span><span style=3D"color:#000"=
> </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=
"> template_tag </span><span style=3D"color:#660">{};</span><span style=3D"=
color:#000"> </span><span style=3D"color:#800">// A unique, empty type for =
any template.</span><span style=3D"color:#000"><br><br></span><span style=
=3D"color:#008">template</span><span style=3D"color:#660">&lt;</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">template</span><spa=
n style=3D"color:#660">&lt;</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">...</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">&gt;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> t </span><span styl=
e=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span sty=
le=3D"color:#008">struct</span><span style=3D"color:#000"> template_identit=
y<br>&nbsp; &nbsp; </span><span style=3D"color:#660">{</span><span style=3D=
"color:#000"> </span><span style=3D"color:#008">using</span><span style=3D"=
color:#000"> template_ </span><span style=3D"color:#660">=3D</span><span st=
yle=3D"color:#000"> t</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">};</span><span style=3D"=
color:#000"> </span><span style=3D"color:#800">// Template identity functio=
n: do not (re)bind any arguments.</span><span style=3D"color:#000"><br></sp=
an></div></code></div></div></div></blockquote><div><br>Forgot one. Unlike =
the above, this is actually a real example from my utility library:<br><br>=
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wo=
rd-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">typename</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: #660;" class=3D"styled-by-prett=
ify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</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: #0=
08;" class=3D"styled-by-prettify">template</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">typename</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span=
><span style=3D"color: #000;" 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"> b </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> is_same_template </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">false_type </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">{};</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">template</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</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"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">...</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> is_same_template</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> a </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">true_type </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{};</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></c=
ode></div><br>&nbsp;<br></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_235_1733993.1379481372220--

.


Author: Morwenn <morwenn29@gmail.com>
Date: Fri, 12 Feb 2016 13:47:09 -0800 (PST)
Raw View
------=_Part_1358_2073445441.1455313629185
Content-Type: multipart/alternative;
 boundary="----=_Part_1359_1867076666.1455313629185"

------=_Part_1359_1867076666.1455313629185
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

No advance on this idea? I also have some related problems from time to=20
time. As long as it is in the implementation, I can work around problems=20
with std::integral_constant, but I don't want users of my libraries to be=
=20
forced to use this kind of trick; it's not really clean. From time to time=
=20
I also wish it was possible to pass either a function pointer or a function=
=20
object type as a template parameter, so that I can either call=20
foobar<&some_function> or foobar<some_function_object_class>. From a=20
syntactic point of view, it could be easy to write it as follows:

template<...>
struct foobar;

template<typename T>
struct foobar<T> { /* ... */ };

template<int(*fptr)(int)>
struct foobar<fptr> { /* ... */ };

I don't think it would cause actual ambiguities nor would it open wholes in=
=20
the type system. The bare ... without any quaifier is the best thing I can=
=20
think of to represent =C2=AB anything =C2=BB without repurposing or introdu=
cing any=20
new keyword. Any thought or any news concerning a similar idea?

--=20

---=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.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.

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

<div dir=3D"ltr">No advance on this idea? I also have some related problems=
 from time to time. As long as it is in the implementation, I can work arou=
nd problems with <span style=3D"font-family: courier new,monospace;">std::i=
ntegral_constant</span>, but I don&#39;t want users of my libraries to be f=
orced to use this kind of trick; it&#39;s not really clean. From time to ti=
me I also wish it was possible to pass either a function pointer or a funct=
ion object type as a template parameter, so that I can either call <span st=
yle=3D"font-family: courier new,monospace;">foobar&lt;&amp;some_function&gt=
;</span> or <span style=3D"font-family: courier new,monospace;">foobar&lt;s=
ome_function_object_class&gt;</span>. From a syntactic point of view, it co=
uld be easy to write it as follows:<br><br><div style=3D"margin-left: 40px;=
"><span style=3D"font-family: courier new,monospace;">template&lt;...&gt;<b=
r>struct foobar;<br><br>template&lt;typename T&gt;<br>struct foobar&lt;T&gt=
; { /* ... */ };<br><br>template&lt;int(*fptr)(int)&gt;<br>struct foobar&lt=
;fptr&gt; { /* ... */ };</span><br></div><br>I don&#39;t think it would cau=
se actual ambiguities nor would it open wholes in the type system. The bare=
 ... without any quaifier is the best thing I can think of to represent =C2=
=AB anything =C2=BB without repurposing or introducing any new keyword. Any=
 thought or any news concerning a similar idea?<br></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_1359_1867076666.1455313629185--
------=_Part_1358_2073445441.1455313629185--

.