Thursday, 15 August 2013

c++ - How is ambiguity determined in the overload resolution algorithm? -


I am trying to understand the overloading resolution method.

Why is it unclear:

Void func (int, double, double, double) {} void main () {func (1, 2, 3, 4);>
  Void func (double, int, int, double) {}}   

But is not it? Zero (int, double, double, double) {} zero main () {throw (1, 2, 3, 4)

  zero (int, int, int, double) vic ; }  

In the first case, there are 2 precise parameter matches and 2 conversions against 1 exact match and 3 conversions, and in the second case there are 3 exact matches and 1 conversion with 1 exact match And 3 conversions

So why is not one unclear and one? What is the logic here? Overload resolution rules define partial orders only on all sets of matches - if an overload F1 is not a good match with F2 , this does not mean that F2 is this F1 . The exact partial order can be considered about comparing two points in the k dimension, where the number of logic is k . Define this partial order on the number in k -dim space - (x_1, x_2, ..., x_k). (Y_1, y_2, ..., y_k) if x_i for all i and x_j & lt; = Y_i & lt; For at least one J y_j this is actually a partial order on non-temp function candidates defined by standard.

View your instances:

  Zero function (double, int, int, double) {Vvv vvv vvv Better better equal zero func (int, double, double, Double} {VVV VVV Better Than  

Therefore the surcharge is strictly better than the other.

In your second example:

  zero func (int, int, int, double) {} vvv vvv vvv vvv equals better better zero function (int, double, Double, double)) Vvv equal  

Now, the first surcharge is better than the other one at all, but there is a logic and not worse than the other. Thus, there is no ambiguity. - The partial order actually declares the first one better.

(The above description function does not consider the template. You can find more information.)


No comments:

Post a Comment