The following overloaded function,
void foo(const void*)
{
printf("first");
}
void foo(unsigned int)
{
printf("second");
}
generates an ambiguous overload in this case
foo((int)0);
but not in this one
foo((int)1);
Why? Is it because people still use NULL
? And what's the best way to get around the problem, without explicit cast?
(I'm compiling with GCC 8.3.0-C++11 on Ubuntu 18.04)
EDIT
As some of you pointed out in the comments, (int)0
compiles without errors, actually (at least on GCC 8.3.0, with C++11 std). The problem I had was only with foo(0)
, and I get why now.