[over.call.func] (original) (raw)

12 Overloading [over]

12.4 Overload resolution [over.match]

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

12.4.2.2 Function call syntax [over.match.call]

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

Of interest in [over.call.func] are only those function calls in which thepostfix-expressionultimately contains a name that denotes one or more functions.

Such apostfix-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 name to be resolved is anid-expressionand is preceded by an->or.operator.

Since the constructA->Bis 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 thepostfix-expressionthat is the left operand of the.operator has type “cv T” whereTdenotes a class.122

Under this assumption, theid-expressionin the call is looked up as a member function ofTfollowing the rules for looking up names in classes ([class.member.lookup]).

The function declarations found by that lookup constitute the set of candidate functions.

The argument list is theexpression-listin 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 name is not qualified by an->or.operator and has the more general form of aprimary-expression.

The name is looked up in the context of the function call following the normal rules for name lookup in expressions ([basic.lookup]).

The function declarations found by that lookup constitute the set of candidate functions.

Because of the rules for name lookup, the set of candidate functions consists (1) entirely of non-member functions or (2) entirely of member functions of some classT.

In case (1), the argument list is the same as theexpression-listin the call.

In case (2), the argument list is theexpression-listin the call augmented by the addition of an implied object argument as in a qualified function call.

If the keywordthis is in scope and refers to classT, or a derived class ofT, then the implied object argument is(*this).

If the keywordthisis not in scope or refers to another class, then a contrived object of typeTbecomes the implied object argument.123

If the argument list is augmented by a contrived object and overload resolution selects one of the non-static member functions ofT, the call is ill-formed.