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

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.3 Call to object of class type [over.call.object]

If the postfix-expression Ein the function call syntax evaluates to a class object of type “cv T”, then the set of candidate functions includes at least the function call operators of T.

The function call operators of Tare the results of a search for the name operator()in the scope of T.

In addition, for each non-explicit conversion function declared in T of the form

where the optionalcv-qualifier-seqis the same cv-qualification as, or a greater cv-qualification than,cv, and whereconversion-type-iddenotes the type “pointer to function of () returning R”, or the type “reference to pointer to function of () returning R”, or the type “reference to function of () returning R”, a surrogate call function with the unique name_call-function_and having the form

R call-function ( conversion-type-id F, P a, …, P a) { return F (a, …, a); }

is also considered as a candidate function.

Similarly, surrogate call functions are added to the set of candidate functions for each non-explicit conversion function declared in a base class ofTprovided the function is not hidden withinTby another intervening declaration.102

The argument list submitted to overload resolution consists of the argument expressions present in the function call syntax preceded by the implied object argument(E).

[Note 1:

When comparing the call against the function call operators, the implied object argument is compared against the object parameter of the function call operator.

When comparing the call against a surrogate call function, the implied object argument is compared against the first parameter of the surrogate call function.

— _end note_]

[Example 1: int f1(int);int f2(float);typedef int (*fp1)(int);typedef int (*fp2)(float);struct A { operator fp1() { return f1; } operator fp2() { return f2; } } a;int i = a(1); — _end example_]