Topic: Variadic template template problem: the issue with


Author: VinceRev <vince.rev@gmail.com>
Date: Fri, 13 Sep 2013 03:24:38 -0700 (PDT)
Raw View
------=_Part_58_24709920.1379067878481
Content-Type: text/plain; charset=ISO-8859-1

Hello.

A very common problem with templates templates can be illustrated with 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.
A standard approach is to avoid non-type parameters by using
std::integral_constant but when you use a library that uses non-type
parameters then you cannot do anything (appart maybe with some awful
tricks).
My question is quite simple: is there an easy workaround or proposed
workaround for 2017 to solve this problem?
If not I think we should address this issue as soon as possible.

(we can think of a syntax like:
template <template<auto...> class T, auto... U> void f(const T<U...>& x)
or
template <template<...> class T> void f(const T<...>& x)
)

What's your opinion on that?
Thanks.

--
Vincent Reverdy*
Phd Student @ Laboratory Universe and Theories**
Cosmology and General Relativity Group
Observatory of Paris-Meudon, France*

--

---
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_58_24709920.1379067878481
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello.<br><br>A very common problem with templates templat=
es can be illustrated with the following:<br><br><span style=3D"font-family=
: courier new,monospace;">#include &lt;iostream&gt;<br>#include &lt;array&g=
t;<br>#include &lt;tuple&gt;<br><br>template &lt;template&lt;class...&gt; c=
lass 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;std::endl;}<br><br>int main()<br>{<br>&n=
bsp;&nbsp; std::tuple&lt;int, int&gt; tuple{};<br>&nbsp;&nbsp; std::array&l=
t;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 template parameter, everything fails. <br>A standard approa=
ch is to avoid non-type parameters by using <span style=3D"font-family: cou=
rier new,monospace;">std::integral_constant</span> but when you use a libra=
ry that uses non-type parameters then you cannot do anything (appart maybe =
with some awful tricks).<br>My question is quite simple: is there an easy w=
orkaround or proposed workaround for 2017 to solve this problem?<br>If not =
I think we should address this issue as soon as possible.<br><br>(we can th=
ink of a syntax like: <span style=3D"font-family: courier new,monospace;"><=
br>template &lt;template&lt;auto...&gt; class T, auto... U&gt;</span> <span=
 style=3D"font-family: courier new,monospace;">void f(const T&lt;U...&gt;&a=
mp; x)</span><br>or<br><span style=3D"font-family: courier new,monospace;">=
template &lt;template&lt;...&gt; class T&gt;</span> <span style=3D"font-fam=
ily: courier new,monospace;">void f(const T&lt;...&gt;&amp; x)</span><br>)<=
br><br>What's your opinion on that?<br>Thanks.<br><br>-- <br>Vincent Reverd=
y<i><br>Phd Student @ Laboratory Universe and Theories</i><i><br>Cosmology =
and General Relativity Group<br>Observatory of Paris-Meudon, France</i><br>=
</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_58_24709920.1379067878481--

.