I want to question about overload resolution accompanying an implicit type conversion.
It seems that an implicit conversion sequence has at most three steps to convert an type T1
(argument type) to T2
(parameter type):
- zero or one standard conversion sequence;
zero or one user-defined conversion; (I want to ignore this step because it isn't related to this question.)- zero or one standard conversion sequence.
An implicit conversion sequence can be categorized as one of:
- a standard conversion sequence (I am interested this fundamental type conversions case only.)
a user-defined conversion sequencean ellipsis conversion sequence
And, each type of standard conversion sequence is assigned one of three ranks:
- Exact match
- Promotion
- Conversion
I think there will be a case where two implicit conversion sequences have its constituent standard conversion sequence steps which have different ranks each other. So, IMHO it is hard for me to determine which implicit conversion sequence is preferred than the other.
For example(Unfortunately, i couldn't come up with a concrete example.),
An implicit conversion sequence (A) consists of
- standard conversion sequence (A-1) which is rank exact match.
- no user-defined conversion sequence
- standard conversion sequence (A-2) which is rank conversion.
The other implicit conversion sequence (B) consists of
- standard conversion sequence (B-1) which is rank conversion.
- no user-defined conversion sequence
- standard conversion sequence (B-2) which is rank exact match.
In this case, A-1 is preferred than B-1 but B-2 is preferred than A-2. So, each of A and B have own preferences. -> ambiguous call?
OR... A-1 and B-1 should be compared first than A-2 and B-2. So, should we stop comparing each other here for greedy comparison? -> The A is chosen?
Aucun commentaire:
Enregistrer un commentaire