I suspect that the net cast by rule 14â€“8â€“1 is too wide. For example, I don't think it's helpful to label the following as "non-compliant":
Code: Select all
template <typename T> void f ( T ); // #1 template <typename T> void f ( T*, T ); // #2 template <> void f<int32_t*> ( int32_t* ); // non-compliant with 14â€“8â€“1
In the actual example given for 14â€“8â€“1, it is helpful to claim that the specialization is suspect because there is another template that would have been a better match if only the explicit template argument list <int32_t*> had not been given, and a user (especially someone writing a call to the template) may not have an understanding of the type deduction rules sufficient to know which template would be selected when there are multiple matches and only one match is selected by partial ordering.
But who, without the assistance of medication, would not just assume that #1 (in the example above) is being specialized in the explicit-specialization? Likewise, who, in the absence of default arguments and in the absence of any other overload, would not just assume that #1 would be called when the call expression contains only one argument?
I recommend changing the wording of the rule to:
An overloaded function template shall not be explicitly
specialized if, in the absence of an explicit
template-argument-list, at least one template other than
the selected template would succeed at type deduction against
the function type given by the explicit specialization.