template-templates

Help with c++ template templates.

Ok, so I wrote an stl-like algorithm called cartesian_product. For those who don't know, the cartesian product is every possible pair of elements from two sets. So the cartesian product of {1, 2, 3} and {10, 20, 30} is {(1,10), (1,20), (1,30), (2,10), (2,20), (2,30), (3,10), (3,20), (3,30)} So the function looks like template <typenam...

Partial template specialization: matching on properties of specialized template parameter

template <typename X, typename Y> class A { // Use Y::Q, a useful property, not used for specialization. }; enum Property {P1,P2}; template <Property P> class B {}; class C {}; Is there any way to define a partial specialization of A such that A<C, B<P1> > would be A's normal template, but A<C, B<P2> > would be the specialization? ...

Template class that refers to itself as a template template parameter?

This code: template <template <typename> class T> class A { }; template <typename T> class B { A<B> x; }; doesn't compile, I suppose since A<B> is interpreted as A<B<T> > within B's scope. So, how do you pass B as a template template parameter within it's scope? ...