Using VS2008, why is this OK (not allowed to use 2010).
void assert(int exp, int actual) {if (exp!=actual) printf("assert failed\n");}
void assert(unsigned int exp, unsigned int actual) {if (exp!=actual) printf("assert failed\n");}
But this is ambiguous.
void assert(__int64 exp, __int64 actual) {if (exp!=actual) printf("assert failed\n");}
void assert(unsigned __int64 exp, unsigned __int64 actual) {if (exp!=actual) printf("assert failed\n");}
Sample error text
d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(31) : error C2668: 'assert' : ambiguous call to overloaded function
d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(12): could be 'void assert(unsigned __int64,unsigned __int64)'
d:\my documents\visual studio 2008\projects\classtest\classtest\classtest.cpp(10): or 'void assert(__int64,__int64)'
while trying to match the argument list '(int, int)'
It only gets ambiguous with regards to the 'unsigned' overload. Having and "int" version and an "__int64" version is not ambiguous.
Your code is actually using int and int as the parameters. In the first case it has an exact match. In the second case it does not, and it treats int->uint64 and int->int64 as equally valid conversions so it doesn't know which one to pick.