It's inconsistent, yes, but it's "The Way The Language Is", and you need to handle it, for example. if you want f((unsigned int)0)
call overload long long
, then provide a wrapper,
inline void f(unsigned int x) { f((long long)x); }
C ++ designers would ideally resemble both of your cases to cope with overloading. But there was this legacy (starting with "K & R" C), called "advancement of default arguments", which, in essence, says that the compiler will implicitly convert all integer types narrower than int
to int
if necessary to match function signature, and all floating point types are already double
to double
ditto.
So really, this is the case of f((unsigned short)0)
, which is a strange person.
source share