template<class T>
void fun(T){}
template<>
int fun(int){return 0;}
Consider this example, it is rejected by all implementations. However, I haven't found any persuasive provision in the current standard that specifies this explicit specialization declaration is ill-formed. If it exists, what is the rule?
In addition, the potential relevant rule may be that [temp.deduct.decl#2]
If, for the set of function templates so considered, there is either no match or more than one match after partial ordering has been considered ([temp.func.order]), deduction fails and, in the declaration cases, the program is ill-formed.
I think the meaning of "match" is not sufficiently clear here since "match" didn't clearly define anything.
static_cast<void(*)(int)>(&fun)
do? The compiler would successfully deduceT = int
first, then find the specialization, and then it would have to compare the type of the specialized function against the type in the cast? – Accustomed