Why is this an ambiguous situation?
According to ยง13.3.3/1,
Given these definitions, a viable function F1
is defined to be a
better function than another viable function F2
if for all arguments i, ICS i (F1
) is not a worse conversion sequence than
ICS i (F2
), and then
โ for some argument j, ICS j (F1
) is a better conversion
sequence than ICS j (F2
), or, if not that,
โ [...]
Therefore a call like function(0., 0., 0.)
is ambiguous; Neither of the overloads is a better match than the other.
Consider template argument deduction from a function call - if a template parameter T
is used in several function parameters (like T a, T b, T c
) and for two of the arguments of the call it is deduced as int
, but for the third one as double
, should that really result in a successful deduction with T=int
?
Overload resolution doesn't count the better matches and calls the winner - that wouldn't be decisive enough.
Imagine a jigsaw puzzle - is a piece really a better match for a gap if it fills in better at two ends but worse on another one?