C++ Logo


Advanced search

Re: [over.ics.rank] standard conversion tie-breakers from different source types

From: language.lawyer_at <language.lawyer_at_[hidden]>
Date: Tue, 10 Jan 2023 20:57:30 +0500
> I would like an example of a function call to an overloaded function,
> where the most viable function is determined by the rules listed from
> [over.ics.rank]/4.4.5 to [over.ics.rank]/4.4.8:
> https://timsong-cpp.github.io/cppwp/n4868/over.ics.rank#4.4.5
> These are four different tie-breakers for ranking standard conversions
> from different source types, assuming the following class hierarchy:
> struct A {}; struct B : C {}; struct C : B {};
> (4.4.5) conversion of B* to A* is better than conversion of C* to A*,
> (4.4.6) binding of an expression of type B to a reference to type A is
> better than binding an expression of type C to a reference to type A,
> (4.4.7) conversion of B​::​* to C​::​* is better than conversion of
> A​::​* to C​::​*, and
> (4.4.8) conversion of B to A is better than conversion of C to A.
> The note says that these are only used for tie-breakers in the second
> conversion sequence of user-defined conversions:
> https://timsong-cpp.github.io/cppwp/n4868/over.ics.rank#note-1

I think it is just a wrong Note.
CD2 (November 96 https://www.open-std.org/jtc1/sc22/wg21/docs/wp/html/cd2/over.html#over.ics.rank) Note was saying:
> [Note: it is necessary to compare conversions with different target
> types in the context of an initialization by user-defined conver-
> sion; see _over.match.best_. ]

Which also seems not 100% correct (incomplete?), because it mentions (only?) target, and not source types.

The next WP (Oct'97 https://www.open-std.org/jtc1/sc22/wg21/docs/wp/html/oct97/over.html#over.ics.rank) Note gained its current (defective) wording.

(The bullets themselves have been added by https://www.open-std.org/JTC1/sc22/wg21/docs/papers/1995/N0661.asc)

So, ecatmur's example seems to be relevant here, except that the Note is not about the second standard conversion sequence after different user conversion functions, but about https://timsong-cpp.github.io/cppwp/n4868/over.match.best#general-2.2

Received on 2023-01-10 15:57:36