On
this page describing explicit template specialization there is the following paragraph (emphasis is mine):
When defining a member of an explicitly specialized class template outside the body of the class, the syntax template <> is not used, except if it's a member of an explicitly specialized member class template, which is specialized as a class template, because otherwise, the syntax would require such definition to begin with template<parameters> required by the nested template
I have some questions regarding the whole paragraph.
First, there is the exception: "except if it's a member of an explicitly specialized member class template, which is specialized as a class template". Does "which" refer to the "explicitly specialized member class template"?
Let's look at the example from the site:
template< typename T>
struct A {
struct B {}; // member class
template<class U> struct C { }; // member class template
};
template<> // specialization of a member class template
template<class U> struct A<char>::C {
void f();
};
I believe "which" refers to A<char>::C, but I want to make sure.
My second question is related to the last part of the paragraph: "because otherwise, the syntax would require such definition to begin with template<parameters> required by the nested template". Does "otherwise" refer to the case in which template<> would not be used when "defining a member of an explicitly specialized member class template, which is specialized as a class template"?
If so, what would be the problem with writing
template<class U> void A<char>::C<U>::f() { /* ... */ }
instead of
template<>
template<class U> void A<char>::C<U>::f() { /* ... */ }
?
Thank you.