I have a problem with template templates:
template <typename T> class A { }; template< template <typename> class T> class B { }; template <template <typename> class T, typename parm> class C { typedef T<parm> type; }; template <typename... types> class D { }; template <template <typename...> class T, typename ... parms> class E { typedef T<parms...> type; };
Pass the type to the template first, no problem:
A<int> a;
Now I want to create an instance from B, but not pass the template template template:
B<A> b;
Therefore, I need to expand the list of parameters:
C<A, int> c; // ok, this transport int as parm into A
Now I play with variation templates in a standard way:
D<> d1; // ok D<int, float, double> d2; //ok
The transfer of parameters to the variational part also goes forward:
E<D> e1; //ok E<D, double, float, int> e2; //ok
BUT: If I want to have a list of lists, I find no syntax that I can pass a list of parameters to a list of types. What I intend is something like this. but the above example also shows that B<A<int>> b; is a mistake! So the following example could not work :-(
F< D< int, float>, D< int>, D <float, float, float> > f;
My goal is to expand the list of lists using a specialized specialization. Any clues?
My solution after I understood the problem. Thanks!
Now I can deploy my Variadic variation template, as in the following example. A simple problem was that I was waiting for a template class, not for a simple type. Sometimes a solution can be so simple :-)
Here is my working result:
template <typename ... > class D; template <typename Head, typename... types> class D<Head, types...> { public: static void Do() { cout << "AnyType" << endl; D<types...>::Do(); } }; template<> class D<> { public: static void Do() { cout << "End of D" << endl; } }; template < typename ...T> class H; template < typename Head, typename ...T> class H<Head, T...> { public: static void Do() { cout << "unroll H" << endl; cout << "Subtype " << endl; Head::Do(); H<T...>::Do(); } }; template <> class H<> { public: static void Do() { cout << "End of H" << endl; } }; int main() { H< D<int,int,int>, D<float, double, int> >::Do(); return 0; }