This will be our template:
template< typename T>
struct A {
struct B {};
template<class U> struct C { };
};
See the following code:
template<>
struct A<int> {
void f(int);
};
void A<int>::f(int) { }
We do not use template<>when defining a member of a specialization, since this is a normal member class.
But now let's see the following code:
template<>
template<class U> struct A<char>::C {
void f();
};
template<>
template<class U> void A<char>::C<U>::f() { }
Here we specialize in a member template for a given template. That's why we need to use template<>to pass the parameters that are required for this member template. In this case, class Uit is necessary to determine our member template, so for the transfer we need a keyword template<>.
source
share