Reputation: 1506
In the code
void Fnc( long = 10 ) { }
void Fnc( ) = delete;
int main( int, char** )
{
Fnc( );
return 0;
}
At the Func call my compiler complains about an ambiguous call. Help! I don't understand why that happens.
Upvotes: 2
Views: 117
Reputation: 962
According to Delete Function Definition:
The definition form "=delete;" indicates that the function may not be used. However, all lookup and overload resolution occurs before the deleted definition is noted. That is, it is the definition that is deleted, not the symbol; overloads that resolve to that definition are ill-formed.
That's why you're getting ambiguous call.
Upvotes: 4
Reputation: 92271
A deleted function is not removed, but tells the compiler that trying to call it is an error.
Your Fnc();
could call either of the functions, and the compiler cannot tell which one you intended. That one of them is deleted doesn't matter until it is the single best match. Then it will be an error, not a hint to select some other function.
Upvotes: 4