template<typename T> T f(T i) { return i+1; }
int f(int i) { return i-1; }
f(2);
Is this undefined behaviour (note that int f(int)
is not a specialization) ? If yes, then please point out where standard carries such case.
template<typename T> T f(T i) { return i+1; }
int f(int i) { return i-1; }
f(2);
Is this undefined behaviour (note that int f(int)
is not a specialization) ? If yes, then please point out where standard carries such case.
There is no ambiguity here. If there is an invocation of f
with an int
, the non-template version of the overload will always be chosen as long as both declarations are visible at the point of use.
It is not UB and not even ambiguous, it is just overload resolution:
both are exact match, but one is template function whereas the other is not:
int f(int)
is selected.