Consider the following example:
template<class T> struct A {
template<class U> void f();
};
template<> template<class U>
void A<int>::f() {} //(1)
template<> template<>
void A<int>::f<char>() {} //(2)
My first question is: are these both explicit specializations for f?
In (1) it seems more like f was specialized to be still a function template in the specialized version of A (A< int >), while in (2) it seems like f is itself specialized for its own set template parameters (char).
I find there to be a difference between these specializations (again, (1) feels like declaring a new version of f to be used for a "special version" of its "enclosing template" A
, while (2) feels like a specialization regarding f itself (or regarding its own template parameters).
Furthermore, consider this example:
template<class T> struct A{
int f() { return 1; }
}
template<>
int A<int>::f() { return 2; }//(3)
To me (1) and (3) are the same "kind of specialization", one that is linked to a special version of the "enclosing template", while (2) is a specialization of the entity (template) itself.
Does the standard mention this difference or are these two kinds of specializations referred to as the same?
This question started when I read this paragraph of the current C++ standard draft, realizing that I do not know exactly what it means to specialize a member template ( (1), (2) or both? )
Thank you.