这似乎不一致.我为签名类型short,int和long long重载了3个函数.如果你传递一个unsigned short,那么它会被提升为下一个最大的signed类型int.但是,如果你传递unsigned int,那么它不会被提升为signed long long,这是我所期望的,而是编译器抱怨对重载函数的模糊调用.
@H_502_2@void f(short x) { std::printf("f(short)\n"); }
void f(int x) { std::printf("f(int)\n"); }
void f(long long x) { std::printf("f(long long)\n"); }
int main()
{
f((unsigned short)0); // Fine: calls f(int)
// f((unsigned int)0); // Ambiguous: could be f(short),f(int) or f(long long)
}