Date: Mon, 9 Jan 2023 00:22:20 +0100
> What would you say happens for `foo(1, 1)`
The concerns remains the same; int -> void* and int -> int for overload (1); int -> short and int -> short for overload (2).
But this time, there is no known implicit conversion available from int-> void*, because literal 1 is no null pointer constant and therefore it can not be converted to a pointer type implicitly. So, if there is no other implicit conversion for the first argument available, this overload is not considered viable at all but overload (2) still is - and it‘s therefore also the best.
> where does that diverge from the process for `foo(0, 1)`?
It diverge by [conv.ptr/1].
> Let's forget about the second argument for now.
That‘s not possible, since it all depends on the second argument. If we forget about the second argument we would end up with ambiguity because both overloads will have a rank of „conversion“ (only if the argument is literal 0 - else, as explained above, the first overload is not considered viable at all)
For overload (1) from int -> void* => conversion
For overload (2) from int -> short => conversion
The concerns remains the same; int -> void* and int -> int for overload (1); int -> short and int -> short for overload (2).
But this time, there is no known implicit conversion available from int-> void*, because literal 1 is no null pointer constant and therefore it can not be converted to a pointer type implicitly. So, if there is no other implicit conversion for the first argument available, this overload is not considered viable at all but overload (2) still is - and it‘s therefore also the best.
> where does that diverge from the process for `foo(0, 1)`?
It diverge by [conv.ptr/1].
> Let's forget about the second argument for now.
That‘s not possible, since it all depends on the second argument. If we forget about the second argument we would end up with ambiguity because both overloads will have a rank of „conversion“ (only if the argument is literal 0 - else, as explained above, the first overload is not considered viable at all)
For overload (1) from int -> void* => conversion
For overload (2) from int -> short => conversion
Received on 2023-01-08 23:22:27