[over.match.best] (original) (raw)
12.2.4.1 General [over.match.best.general]
Define as the implicit conversion sequence that converts the argument in the list to the type of the parameter of viable function F.
[over.best.ics] defines the implicit conversion sequences and [over.ics.rank]defines what it means for one implicit conversion sequence to be a better conversion sequence or worse conversion sequence than another.
Given these definitions, a viable function is defined to be abetterfunction than another viable function if for all arguments i, is not a worse conversion sequence than , and then
- for some argument j, is a better conversion sequence than, or, if not that,
- the context is an initialization by user-defined conversion (see [dcl.init],[over.match.conv], and [over.match.ref]) and the standard conversion sequence from the result of to the destination type (i.e., the type of the entity being initialized) is a better conversion sequence than the standard conversion sequence from the result of to the destination type
[Example 1: struct A { A();operator int();operator double();} a;int i = a; float x = a; — _end example_]
or, if not that, - the context is an initialization by conversion function for direct reference binding of a reference to function type, the return type of is the same kind of reference (lvalue or rvalue) as the reference being initialized, and the return type of is not
[Example 2: template <class T> struct A { operator T&(); operator T&&(); };typedef int Fn(); A<Fn> a; Fn& lf = a; Fn&& rf = a; — _end example_]
or, if not that, - is not a function template specialization andis a function template specialization, or, if not that,
- andare function template specializations, and the function template foris more specialized than the template foraccording to the partial ordering rules described in [temp.func.order], or, if not that,
- and are non-template functions and is more partial-ordering-constrained than ([temp.constr.order])
[Example 3: template <typename T = int> struct S { constexpr void f(); constexpr void f(this S&) requires true; };void test() { S<> s; s.f(); } — _end example_]
or, if not that, - is a constructor for a class D, is a constructor for a base class B of D, and for all arguments the corresponding parameters of and have the same type
[Example 4: struct A { A(int = 0);};struct B: A { using A::A; B();};int main() { B b; } — _end example_]
or, if not that, - is a rewritten candidate ([over.match.oper]) and is not
[Example 5: struct S { friend auto operator<=>(const S&, const S&) = default; friend bool operator<(const S&, const S&); };bool b = S() < S(); — _end example_]
or, if not that, - and are rewritten candidates, and is a synthesized candidate with reversed order of parameters and is not
[Example 6: struct S { friend std::weak_ordering operator<=>(const S&, int); friend std::weak_ordering operator<=>(int, const S&); };bool b = 1 < S(); — _end example_]
or, if not that, - and are generated from class template argument deduction ([over.match.class.deduct]) for a class D, and is generated from inheriting constructors from a base class of Dwhile is not, and for each explicit function argument, the corresponding parameters of and are either both ellipses or have the same type, or, if not that,
- is generated from adeduction-guide ([over.match.class.deduct]) and is not, or, if not that,
- is the copy deduction candidateand is not, or, if not that,
- is generated from a non-template constructor and is generated from a constructor template.
[Example 7: template <class T> struct A { using value_type = T; A(value_type); A(const A&); A(T, T, int); template<class U> A(int, T, U); }; A x(1, 2, 3); template <class T>A(T) -> A<T>; A a(42); A b = a; template <class T>A(A<T>) -> A<A<T>>; A b2 = a; — _end example_]
If there is exactly one viable function that is a better function than all other viable functions, then it is the one selected by overload resolution; otherwise the call is ill-formed.105
[Example 8: void Fcn(const int*, short);void Fcn(int*, int);int i;short s = 0;void f() { Fcn(&i, s); Fcn(&i, 1L); Fcn(&i, 'c'); } — _end example_]
If the best viable function resolves to a function for which multiple declarations were found, and if any two of these declarations inhabit different scopes and specify a default argument that made the function viable, the program is ill-formed.
[Example 9: namespace A { extern "C" void f(int = 5);} namespace B { extern "C" void f(int = 5);} using A::f;using B::f;void use() { f(3); f(); } — _end example_]
12.2.4.2 Implicit conversion sequences [over.best.ics]
12.2.4.2.1 General [over.best.ics.general]
An implicit conversion sequenceis a sequence of conversions used to convert an argument in a function call to the type of the corresponding parameter of the function being called.
The sequence of conversions is an implicit conversion as defined in[conv], which means it is governed by the rules for initialization of an object or reference by a single expression ([dcl.init], [dcl.init.ref]).
Implicit conversion sequences are concerned only with the type, cv-qualification, and value category of the argument and how these are converted to match the corresponding properties of the parameter.
[Note 1:
Other properties, such as the lifetime, storage duration, linkage, alignment, accessibility of the argument, whether the argument is a bit-field, and whether a function is deleted, are ignored.
So, although an implicit conversion sequence can be defined for a given argument-parameter pair, the conversion from the argument to the parameter might still be ill-formed in the final analysis.
— _end note_]
A well-formed implicit conversion sequence is one of the following forms:
- a standard conversion sequence,
- a user-defined conversion sequence, or
- an ellipsis conversion sequence.
However, if the target is
- the first parameter of a constructor or
- the object parameter of a user-defined conversion function
and the constructor or user-defined conversion function is a candidate by
- [over.match.ctor], when the argument is the temporary in the second step of a class copy-initialization,
- [over.match.copy], [over.match.conv], or [over.match.ref](in all cases), or
- the second phase of [over.match.list]when the initializer list has exactly one element that is itself an initializer list, and the target is the first parameter of a constructor of class X, and the conversion is to X or reference to cv X,
user-defined conversion sequences are not considered.
[Note 2:
These rules prevent more than one user-defined conversion from being applied during overload resolution, thereby avoiding infinite recursion.
— _end note_]
[Example 1: struct Y { Y(int); };struct A { operator int(); }; Y y1 = A(); struct X { X(); };struct B { operator X(); }; B b; X x{{b}}; — _end example_]
For the case where the parameter type is a reference, see [over.ics.ref].
When the parameter type is not a reference, the implicit conversion sequence models a copy-initialization of the parameter from the argument expression.
The implicit conversion sequence is the one required to convert the argument expression to a prvalue of the type of the parameter.
[Note 3:
When the parameter has a class type, this is a conceptual conversion defined for the purposes of [over]; the actual initialization is defined in terms of constructors and is not a conversion.
— _end note_]
Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion.
[Example 2:
A parameter of typeAcan be initialized from an argument of typeconst A.
The implicit conversion sequence for that case is the identity sequence; it contains no “conversion” fromconst AtoA.
— _end example_]
When the parameter has a class type and the argument expression has the same type, the implicit conversion sequence is an identity conversion.
When the parameter has a class type and the argument expression has a derived class type, the implicit conversion sequence is a derived-to-baseconversion from the derived class to the base class.
A derived-to-base conversion has Conversion rank ([over.ics.scs]).
[Note 4:
There is no such standard conversion; this derived-to-base conversion exists only in the description of implicit conversion sequences.
— _end note_]
When the parameter is the implicit object parameter of a static member function, the implicit conversion sequence is a standard conversion sequence that is neither better nor worse than any other standard conversion sequence.
In all contexts, when converting to the implicit object parameter or when converting to the left operand of an assignment operation only standard conversion sequences are allowed.
[Note 5:
When a conversion to the explicit object parameter occurs, it can include user-defined conversion sequences.
— _end note_]
If no conversions are required to match an argument to a parameter type, the implicit conversion sequence is the standard conversion sequence consisting of the identity conversion ([over.ics.scs]).
If no sequence of conversions can be found to convert an argument to a parameter type, an implicit conversion sequence cannot be formed.
If there are multiple well-formed implicit conversion sequences converting the argument to the parameter type, the implicit conversion sequence associated with the parameter is defined to be the unique conversion sequence designated theambiguous conversion sequence.
For the purpose of ranking implicit conversion sequences as described in [over.ics.rank], the ambiguous conversion sequence is treated as a user-defined conversion sequence that is indistinguishable from any other user-defined conversion sequence.
[Note 6:
This rule prevents a function from becoming non-viable because of an ambiguous conversion sequence for one of its parameters.
[Example 3: class B;class A { A (B&);};class B { operator A (); };class C { C (B&); };void f(A) { } void f(C) { }B b; f(b); void f(B) { }f(b); — _end example_]
— _end note_]
If a function that uses the ambiguous conversion sequence is selected as the best viable function, the call will be ill-formed because the conversion of one of the arguments in the call is ambiguous.
The three forms of implicit conversion sequences mentioned above are defined in the following subclauses.
12.2.4.2.2 Standard conversion sequences [over.ics.scs]
Table 19summarizes the conversions defined in [conv] and partitions them into four disjoint categories: Lvalue Transformation, Qualification Adjustment, Promotion, and Conversion.
[Note 1:
These categories are orthogonal with respect to value category, cv-qualification, and data representation: the Lvalue Transformations do not change the cv-qualification or data representation of the type; the Qualification Adjustments do not change the value category or data representation of the type; and the Promotions and Conversions do not change the value category or cv-qualification of the type.
— _end note_]
[Note 2:
As described in [conv], a standard conversion sequence either is the Identity conversion by itself (that is, no conversion) or consists of one to three conversions from the other four categories.
If there are two or more conversions in the sequence, the conversions are applied in the canonical order:Lvalue Transformation,PromotionorConversion,Qualification Adjustment.
— _end note_]
Each conversion in Table 19also has an associated rank (Exact Match, Promotion, or Conversion).
These are used to rank standard conversion sequences.
The rank of a conversion sequence is determined by considering the rank of each conversion in the sequence and the rank of any reference binding.
If any of those has Conversion rank, the sequence has Conversion rank; otherwise, if any of those has Promotion rank, the sequence has Promotion rank; otherwise, the sequence has Exact Match rank.
12.2.4.2.3 User-defined conversion sequences [over.ics.user]
A user-defined conversion sequence consists of an initial standard conversion sequence followed by a user-defined conversion ([class.conv]) followed by a second standard conversion sequence.
If the user-defined conversion is specified by a constructor ([class.conv.ctor]), the initial standard conversion sequence converts the source type to the type of the first parameter of that constructor.
If the user-defined conversion is specified by a conversion function, the initial standard conversion sequence converts the source type to the type of the object parameter of that conversion function.
The second standard conversion sequence converts the result of the user-defined conversion to the target type for the sequence; any reference binding is included in the second standard conversion sequence.
Since an implicit conversion sequence is an initialization, the special rules for initialization by user-defined conversion apply when selecting the best user-defined conversion for a user-defined conversion sequence (see [over.match.best] and [over.best.ics]).
If the user-defined conversion is specified by a specialization of a conversion function template, the second standard conversion sequence shall have Exact Match rank.
A conversion of an expression of class type to the same class type is given Exact Match rank, and a conversion of an expression of class type to a base class of that type is given Conversion rank, in spite of the fact that a constructor (i.e., a user-defined conversion function) is called for those cases.
12.2.4.2.4 Ellipsis conversion sequences [over.ics.ellipsis]
An ellipsis conversion sequence occurs when an argument in a function call is matched with the ellipsis parameter specification of the function called (see [expr.call]).
12.2.4.2.5 Reference binding [over.ics.ref]
When a parameter of type “reference to cv T” binds directly ([dcl.init.ref]) to an argument expression:
- If the argument expression has a type that is a derived class of the parameter type, the implicit conversion sequence is a derived-to-base conversion ([over.best.ics]).
- Otherwise, if the type of the argument is possibly cv-qualified T, or if T is an array type of unknown bound with element type U and the argument has an array type of known bound whose element type is possibly cv-qualified U, the implicit conversion sequence is the identity conversion.
- Otherwise, if T is a function type, the implicit conversion sequence is a function pointer conversion.
- Otherwise, the implicit conversion sequence is a qualification conversion.
[Example 1: struct A {};struct B : public A {} b;int f(A&);int f(B&);int i = f(b); void g() noexcept;int h(void (&)() noexcept); int h(void (&)()); int j = h(g); — _end example_]
If the parameter binds directly to the result of applying a conversion function to the argument expression, the implicit conversion sequence is a user-defined conversion sequence ([over.ics.user]) whose second standard conversion sequence is determined by the above rules.
When a parameter of reference type is not bound directly to an argument expression, the conversion sequence is the one required to convert the argument expression to the referenced type according to [over.best.ics].
Conceptually, this conversion sequence corresponds to copy-initializing a temporary of the referenced type with the argument expression.
Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion.
Except for an implicit object parameter, for which see [over.match.funcs], an implicit conversion sequence cannot be formed if it requires binding an lvalue reference other than a reference to a non-volatile const type to an rvalue or binding an rvalue reference to an lvalue of object type.
[Note 1:
This means, for example, that a candidate function cannot be a viable function if it has a non-const lvalue reference parameter (other than the implicit object parameter) and the corresponding argument would require a temporary to be created to initialize the lvalue reference (see [dcl.init.ref]).
— _end note_]
Other restrictions on binding a reference to a particular argument that are not based on the types of the reference and the argument do not affect the formation of an implicit conversion sequence, however.
[Example 2:
A function with an “lvalue reference to int” parameter can be a viable candidate even if the corresponding argument is anintbit-field.
The formation of implicit conversion sequences treats theintbit-field as anintlvalue and finds an exact match with the parameter.
If the function is selected by overload resolution, the call will nonetheless be ill-formed because of the prohibition on binding a non-const lvalue reference to a bit-field ([dcl.init.ref]).
— _end example_]
12.2.4.2.6 List-initialization sequence [over.ics.list]
When an argument is an initializer list ([dcl.init.list]), it is not an expression and special rules apply for converting it to a parameter type.
If the initializer list is a designated-initializer-listand the parameter is not a reference, a conversion is only possible if the parameter has an aggregate type that can be initialized from the initializer list according to the rules for aggregate initialization ([dcl.init.aggr]), in which case the implicit conversion sequence is a user-defined conversion sequence whose second standard conversion sequence is an identity conversion.
[Note 1:
Aggregate initialization does not require that the members are declared in designation order.
If, after overload resolution, the order does not match for the selected overload, the initialization of the parameter will be ill-formed ([dcl.init.list]).
[Example 1: struct A { int x, y; };struct B { int y, x; };void f(A a, int); void f(B b, ...); void g(A a); void g(B b); void h() { f({.x = 1, .y = 2}, 0); f({.y = 2, .x = 1}, 0); g({.x = 1, .y = 2}); } — _end example_]
— _end note_]
Otherwise, if the parameter type is an aggregate class X and the initializer list has a single element of type cv U, where U is Xor a class derived from X, the implicit conversion sequence is the one required to convert the element to the parameter type.
Otherwise, if the parameter type is a character array106and the initializer list has a single element that is an appropriately-typedstring-literal ([dcl.init.string]), the implicit conversion sequence is the identity conversion.
Otherwise, if the parameter type is std::initializer_list<X>and all the elements of the initializer list can be implicitly converted to X, the implicit conversion sequence is the worst conversion necessary to convert an element of the list to X, or if the initializer list has no elements, the identity conversion.
This conversion can be a user-defined conversion even in the context of a call to an initializer-list constructor.
[Example 2: void f(std::initializer_list<int>); f( {} ); f( {1,2,3} ); f( {'a','b'} ); f( {1.0} ); struct A { A(std::initializer_list<double>); A(std::initializer_list<std::complex<double>>); A(std::initializer_liststd::string\); }; A a{ 1.0,2.0 }; void g(A); g({ "foo", "bar" }); typedef int IA[3];void h(const IA&); h({ 1, 2, 3 }); — _end example_]
Otherwise, if the parameter type is “array of N X” or “array of unknown bound of X”, if there exists an implicit conversion sequence from each element of the initializer list (and from {} in the former case if N exceeds the number of elements in the initializer list) to X, the implicit conversion sequence is the worst such implicit conversion sequence.
Otherwise, if the parameter is a non-aggregate class X and overload resolution per [over.match.list] chooses a single best constructor C ofX to perform the initialization of an object of type X from the argument initializer list:
- If C is not an initializer-list constructor and the initializer list has a single element of type cv U, where U is X or a class derived from X, the implicit conversion sequence has Exact Match rank if U is X, or Conversion rank if U is derived from X.
- Otherwise, the implicit conversion sequence is a user-defined conversion sequence whose second standard conversion sequence is an identity conversion.
If multiple constructors are viable but none is better than the others, the implicit conversion sequence is the ambiguous conversion sequence.
User-defined conversions are allowed for conversion of the initializer list elements to the constructor parameter types except as noted in [over.best.ics].
[Example 3: struct A { A(std::initializer_list<int>);};void f(A); f( {'a', 'b'} ); struct B { B(int, double);};void g(B); g( {'a', 'b'} ); g( {1.0, 1.0} ); void f(B); f( {'a', 'b'} ); struct C { C(std::string);};void h(C); h({"foo"}); struct D { D(A, C);};void i(D); i({ {1,2}, {"bar"} }); — _end example_]
Otherwise, if the parameter has an aggregate type which can be initialized from the initializer list according to the rules for aggregate initialization ([dcl.init.aggr]), the implicit conversion sequence is a user-defined conversion sequence whose second standard conversion sequence is an identity conversion.
[Example 4: struct A { int m1;double m2;};void f(A); f( {'a', 'b'} ); f( {1.0} ); — _end example_]
Otherwise, if the parameter is a reference, see [over.ics.ref].
[Note 2:
The rules in this subclause will apply for initializing the underlying temporary for the reference.
— _end note_]
[Example 5: struct A { int m1;double m2;};void f(const A&); f( {'a', 'b'} ); f( {1.0} ); void g(const double &); g({1}); — _end example_]
Otherwise, if the parameter type is not a class:
- if the initializer list has one element that is not itself an initializer list, the implicit conversion sequence is the one required to convert the element to the parameter type;
[Example 6: void f(int); f( {'a'} ); f( {1.0} ); — _end example_] - if the initializer list has no elements, the implicit conversion sequence is the identity conversion.
[Example 7: void f(int); f( { } ); — _end example_]
In all cases other than those enumerated above, no conversion is possible.
12.2.4.3 Ranking implicit conversion sequences [over.ics.rank]
This subclause defines a partial ordering of implicit conversion sequences based on the relationshipsbetter conversion sequenceandbetter conversion.
If an implicit conversion sequence S1 is defined by these rules to be a better conversion sequence than S2, then it is also the case that S2 is aworse conversion sequencethan S1.
If conversion sequence S1 is neither better than nor worse than conversion sequence S2, S1 and S2 are said to beindistinguishable conversion sequences.
When comparing the basic forms of implicit conversion sequences (as defined in [over.best.ics])
- a standard conversion sequence is a better conversion sequence than a user-defined conversion sequence or an ellipsis conversion sequence, and
- a user-defined conversion sequence is a better conversion sequence than an ellipsis conversion sequence.
Two implicit conversion sequences of the same form are indistinguishable conversion sequences unless one of the following rules applies:
- List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if
- L1 converts to std::initializer_list<X> for some X andL2 does not, or, if not that,
- L1 and L2 convert to arrays of the same element type, and either the number of elements initialized by L1is less than the number of elements initialized by L2, or andL2 converts to an array of unknown bound and L1 does not,
even if one of the other rules in this paragraph would otherwise apply.
[Example 1: void f1(int); void f1(std::initializer_list<long>); void g1() { f1({42}); } void f2(std::pair<const char*, const char*>); void f2(std::initializer_liststd::string\); void g2() { f2({"foo","bar"}); } — end example_]
[_Example 2: void f(int (&&)[] ); void f(double (&&)[] ); void f(int (&&)[2]); f( {1} ); f( {1.0} ); f( {1.0, 2.0} ); f( {1, 2} ); — _end example_]
- Standard conversion sequenceS1is a better conversion sequence than standard conversion sequenceS2if
- S1is a proper subsequence ofS2(comparing the conversion sequences in the canonical form defined by [over.ics.scs], excluding any Lvalue Transformation; the identity conversion sequence is considered to be a subsequence of any non-identity conversion sequence) or, if not that,
- the rank ofS1is better than the rank ofS2, orS1andS2have the same rank and are distinguishable by the rules in the paragraph below, or, if not that,
- S1 and S2 include reference bindings ([dcl.init.ref]) and neither refers to an implicit object parameter of a non-static member function declared without a ref-qualifier, and S1 binds an rvalue reference to an rvalue and S2 binds an lvalue reference
[Example 3: int i;int f1();int&& f2();int g(const int&);int g(const int&&);int j = g(i); int k = g(f1()); int l = g(f2()); struct A { A& operator<<(int);void p() &;void p() &&;}; A& operator<<(A&&, char); A() << 1; A() << 'c'; A a; a << 1; a << 'c'; A().p(); a.p(); — _end example_]
or, if not that, - S1 and S2 include reference bindings ([dcl.init.ref]) andS1 binds an lvalue reference to an lvalue of function type andS2 binds an rvalue reference to an lvalue of function type
[Example 4: int f(void(&)()); int f(void(&&)()); void g();int i1 = f(g); — _end example_]
or, if not that, - S1 and S2 differ only in their qualification conversion ([conv.qual]) and yield similar types T1 and T2, respectively (where a standard conversion sequence that is a reference binding is considered to yield the cv-unqualified referenced type), where T1 and T2 are not the same type, andconst T2 is reference-compatible with T1 ([dcl.init.ref])
[Example 5: int f(const volatile int *);int f(const int *);int i;int j = f(&i); int g(const int*);int g(const volatile int* const&);int* p;int k = g(p); — _end example_]
or, if not that, - S1andS2bind “reference to T1” and “reference to T2”, respectively ([dcl.init.ref]), where T1 and T2 are not the same type, andT2 is reference-compatible with T1
[Example 6: int f(const int &);int f(int &);int g(const int &);int g(int);int i;int j = f(i); int k = g(i); struct X { void f() const;void f();};void g(const X& a, X b) { a.f(); b.f(); } int h(int (&)[]);int h(int (&)[1]);void g2() { int a[1]; h(a); } — _end example_]
or, if not that, - S1 and S2bind the same reference type “reference to T” and have source types V1 and V2, respectively, where the standard conversion sequence from V1* to T*is better than the standard conversion sequence from V2* to T*.
[Example 7: struct Z {};struct A { operator Z&();operator const Z&(); };struct B { operator Z();operator const Z&&(); };const Z& r1 = A(); const Z&& r2 = B(); — _end example_]
- User-defined conversion sequenceU1is a better conversion sequence than another user-defined conversion sequenceU2if they contain the same user-defined conversion function or constructor or they initialize the same class in an aggregate initialization and in either case the second standard conversion sequence ofU1is better than the second standard conversion sequence ofU2.
[Example 8: struct A { operator short();} a;int f(int);int f(float);int i = f(a); — _end example_]
Standard conversion sequences are ordered by their ranks: an Exact Match is a better conversion than a Promotion, which is a better conversion than a Conversion.
Two conversion sequences with the same rank are indistinguishable unless one of the following rules applies:
- A conversion that does not convert a pointer or a pointer to member toboolis better than one that does.
- A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different.
- A conversion in either direction between floating-point type FP1 and floating-point type FP2is better than a conversion in the same direction between FP1 and arithmetic type T3 if
- the floating-point conversion rank ([conv.rank]) of FP1is equal to the rank of FP2, and
- T3 is not a floating-point type, orT3 is a floating-point type whose rank is not equal to the rank of FP1, or the floating-point conversion subrank ([conv.rank]) of FP2is greater than the subrank of T3.
[Example 9: int f(std::float32_t);int f(std::float64_t);int f(long long);float x; std::float16_t y;int i = f(x); int j = f(y); — _end example_]
- If classBis derived directly or indirectly from classA, conversion ofB*toA*is better than conversion ofB*tovoid*, and conversion ofA*tovoid*is better than conversion ofB*tovoid*.
- If classBis derived directly or indirectly from classAand classCis derived directly or indirectly fromB,
- conversion ofC*toB*is better than conversion ofC*toA*,
[Example 10: struct A {};struct B : public A {};struct C : public B {}; C* pc;int f(A*);int f(B*);int i = f(pc); — _end example_] - binding of an expression of typeCto a reference to typeBis better than binding an expression of typeCto a reference to typeA,
- conversion ofA::*toB::*is better than conversion ofA::*toC::*,
- conversion ofCtoBis better than conversion ofCtoA,
- conversion ofB*toA*is better than conversion ofC*toA*,
- binding of an expression of typeBto a reference to typeAis better than binding an expression of typeCto a reference to typeA,
- conversion ofB::*toC::*is better than conversion ofA::*toC::*, and
- conversion ofBtoAis better than conversion ofCtoA.
[Note 1:
Compared conversion sequences will have different source types only in the context of comparing the second standard conversion sequence of an initialization by user-defined conversion (see [over.match.best]); in all other contexts, the source types will be the same and the target types will be different.
— _end note_]
- conversion ofC*toB*is better than conversion ofC*toA*,