A template argument for a template template parameter is the name of a class template.
template<class T, int i> class A {
int x;
};
template<class T> class A<T, 5> {
short x;
};
template<template<class T> class U> class B1 { };
B1<A> c;
The compiler will not allow the declaration B1<A>
c. Although the partial specialization of A seems
to match the template template parameter U of B1,
the compiler considers only the primary template of A,
which has different template parameters than U.#include <iostream>
using namespace std;
template<class T, class U> class A {
int x;
};
template<class U> class A<int, U> {
short x;
};
template<template<class T, class U> class V> class B {
V<int, char> i;
V<char, char> j;
};
B<A> c;
int main() {
cout << typeid(c.i.x).name() << endl;
cout << typeid(c.j.x).name() << endl;
}
The following is the output of the above example: short intThe declaration V<int, char> i uses the partial specialization while the declaration V<char, char> j uses the primary template.