- Why the following sample code is not ambiguous.
It's not a mistake. The parameter type const int*&is a reference to non-const, which cannot be bound to an object with a different type ( int*). (An implicit conversion is required, and the created temporary cannot be bound to a non-const reference.)
const:
void foo(const int* const&)
const int*:
const int* i=nullptr;
foo(i);
.
, , :
const int* i=nullptr;
static_cast<void(*)(const int*&)>(&foo)(i);