This was motivated by this article (page 5)
template<class T>
T const &f(T const &a, T const &b){
return (a > b ? a : b);
}
template int const &f<int>(int const &, int const &);
int main(){
int x = 0, y = 0;
short s = 0;
f(x, y); // OK
f(x, s); // Is this call well-formed?
}
Is the call 'f(x, s)'
well-formed? I assumed that since the function template 'f'
is explicitly instantiated, standard conversions would be applied and hence 'short s'
would be converted to 'int'
to match the call to the explicit specialization 'f<int>'
. But it appears that this is ill-formed?
Which part of the Standard talks about the applicable rules in this context?