Overload resolution – cppreference.com staphylococcus species

• If the expression E has the form PA-B or A.B (where A has class type cv T), then B is looked up as a member function of T. The function declarations found by that lookup are the candidate functions. The argument list for the purpose of overload resolution has the implied object argument of type cv T.

b) all member functions of some class T, in which case, if this is in scope and is a pointer to T or to a derived class of T, *this is used as the implied object argument. Otherwise (if this is not in scope or does not point to T), a fake object of type T is used as the implied object argument, and if overload resolution subsequently selects a non-static member function, the program is ill-formed.

then a surrogate call function with a unique name whose first parameter is the result of the conversion, the remaining parameters are the parameter-list accepted by the result of the conversion, and the return type is the return type of the result of the conversion, is added to the set of candidate functions.


If this surrogate function is selected by the subsequent overload resolution, then the user-defined conversion function will be called and then the result of the conversion will be called.

In any case, the argument list for the purpose of overload resolution is the argument list of the function call expression preceded by the implied object argument E (when matching against the surrogate function, the user-defined conversion will automatically convert the implied object argument to the first argument of the surrogate function).

4) rewritten candidates: For the six relational operator expressions x ==y, x ! =y, x y, and x =y, all member, non-member, and built-in operator ‘s found are added to the set if x y @ 0 is well-formed (meaning, returns std::*_ordering and @ is one of ==, ! =, , =, or returns std::*_equality and @ is one of ==, ! =). Additionally, for the six relational operator expressions x ==y, x ! =y, x y, and x =y as well as the three-way comparison expression x y, a synthesized candidate with the order of the two parameters reversed is added for each member, non-member, and built-in operator ‘s found if 0 @ y x is well-formed. In each case, rewritten candidates are not considered in the context of the rewritten expression. For all other operators, the rewritten candidate set is empty.

The set of candidate functions to be submitted for overload resolution is a union of the sets above. The argument list for the purpose of overload resolution consists of the operands of the operator except for operator-, where the second operand is not an argument for the function call (see member access operator).

If a rewritten candidate is selected by overload resolution for an operator @, x @ y is interpreted as the rewritten expression: 0 @ (y x ) if the selected candidate is a synthesized candidate with reversed order of parameters, or (x y ) @ 0 otherwise, using the selected rewritten operator candidate.

This lookup with the reversed arguments order makes it possible to write just one operatror ( std:: string, const char * ) to generate all comparisons between std:: string and const char *, both ways. See default comparisons for more detail.

When an object of class type is direct-initialized or default-initialized outside a copy-initialization context, the candidate functions are all constructors of the class being initialized. The argument list is the expression list of the initializer.

When an object of class type is copy-initialized from an object of the same or derived class type, or default-initialized in a copy-initialization context, the candidate functions are all converting constructors of the class being initialized. The argument list is the expression of the initializer.

If copy-initialization of an object of class type requires that a user-defined conversion function is called to convert the initializer expression of type cv S to the type cv T of the object being initialized, the following functions are candidate functions:

• the non-explicit conversion functions from S and its base classes (unless hidden) to T or class derived from T or a reference to such. If this copy-initialization is part of the direct-initialization sequence of cv T (initializing a reference to be bound to the first parameter of a constructor that takes a reference to cv T), then explicit conversion functions are also considered.

Either way, the argument list for the purpose of overload resolution consists of a single argument which is the initializer expression, which will be compared against the first argument of the constructor or against the implicit object argument of the conversion function.

• the non-explicit user-defined conversion functions of S and its base classes (unless hidden) that produce type T or a type convertible to T by a standard conversion sequence, or a reference to such type. cv qualifiers on the returned type are ignored for the purpose of selecting candidate functions.

• if this is direct-initialization, the explicit user-defined conversion functions of S and its base classes (unless hidden) that produce type T or a type convertible to T by a qualification conversion, or a reference to such type, are also considered.

6) If any parameter has reference type, reference binding is accounted for at this step: if an rvalue argument corresponds to non-const lvalue reference parameter or an lvalue argument corresponds to rvalue reference parameter, the function is not viable.

User-defined conversions (both converting constructors and user-defined conversion functions) are prohibited from taking part in implicit conversion sequence where it would make it possible to apply more than one user-defined conversion. Specifically, they are not considered if the target of the conversion is the first parameter of a constructor or the implicit object parameter of a user-defined conversion function, and that constructor/user-defined conversion is a candidate for

• initialization by list-initialization where 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 (possibly cv-qualified) X