12 Overloading [over]

12.2 Overload resolution [over.match]

12.2.2 Candidate functions and argument lists [over.match.funcs]

12.2.2.2 Function call syntax [over.match.call]

12.2.2.2.2 Call to named function [over.call.func]

Of interest in [over.call.func] are only those function calls in which the postfix-expression ultimately contains an id-expression that denotes one or more functions.
Such a postfix-expression, perhaps nested arbitrarily deep in parentheses, has one of the following forms:
These represent two syntactic subcategories of function calls: qualified function calls and unqualified function calls.
In qualified function calls, the function is named by an id-expression preceded by an -> or . operator.
Since the construct A->B is generally equivalent to (*A).B, the rest of [over] assumes, without loss of generality, that all member function calls have been normalized to the form that uses an object and the . operator.
Furthermore, [over] assumes that the postfix-expression that is the left operand of the . operator has type “cv T” where T denotes a class.107
The function declarations found by name lookup ([class.member.lookup]) constitute the set of candidate functions.
The argument list is the expression-list in the call augmented by the addition of the left operand of the . operator in the normalized member function call as the implied object argument ([over.match.funcs]).
In unqualified function calls, the function is named by a primary-expression.
The function declarations found by name lookup ([basic.lookup]) constitute the set of candidate functions.
Because of the rules for name lookup, the set of candidate functions consists either entirely of non-member functions or entirely of member functions of some class T.
In the former case or if the primary-expression is the address of an overload set, the argument list is the same as the expression-list in the call.
Otherwise, the argument list is the expression-list in the call augmented by the addition of an implied object argument as in a qualified function call.
If the current class is, or is derived from, T, and the keyword this ([expr.prim.this]) refers to it, then the implied object argument is (*this).
Otherwise, a contrived object of type T becomes the implied object argument;108 if overload resolution selects a non-static member function, the call is ill-formed.
[Example 1: struct C { void a(); void b() { a(); // OK, (*this).a() } void c(this const C&); // #1 void c()&; // #2 static void c(int = 0); // #3 void d() { c(); // error: ambiguous between #2 and #3 (C::c)(); // error: as above (&(C::c))(); // error: cannot resolve address of overloaded this->C​::​c ([over.over]) (&C::c)(C{}); // selects #1 (&C::c)(*this); // error: selects #2, and is ill-formed ([over.match.call.general]) (&C::c)(); // selects #3 } void f(this const C&); void g() const { f(); // OK, (*this).f() f(*this); // error: no viable candidate for (*this).f(*this) this->f(); // OK } static void h() { f(); // error: contrived object argument, but overload resolution // picked a non-static member function f(C{}); // error: no viable candidate C{}.f(); // OK } void k(this int); operator int() const; void m(this const C& c) { c.k(); // OK } }; — end example]
107)107)
Note that cv-qualifiers on the type of objects are significant in overload resolution for both glvalue and class prvalue objects.
108)108)
An implied object argument is contrived to correspond to the implicit object parameter attributed to member functions during overload resolution.
It is not used in the call to the selected function.
Since the member functions all have the same implicit object parameter, the contrived object will not be the cause to select or reject a function.