A complete specialization is not a template, but a class. When you type:
template <>
int const A<int,int>::foo(int const & rhs) {
return rhs;
};
The compiler sees that you want to specialize (template <>
) a member function of a template A
that takes two arguments. The member you are trying to specialize is for an specialization of the template where both arguments are int
. The compiler tries to find the best match and cannot find it, since there are two equally good candidates: A<X,int>
and A<int,Y>
that could use that member function specialization. At that point it gives up.
Since what you want to provide is the definition of the member for A<int,int>
, and that is a full specialization (no longer a template) you need to use the usual syntax: return type::member(args):
int const A<int,int>::foo(int const & rhs) {
return rhs;
};