分类: C/C++
2014-01-28 17:36:35
Call to object of class type [over.call.object] ( ISO/IEC 14882:2011(E) § 13.3.1.1.2 )
1 If the primary-expression E in 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 perators of T. The function call operators of T are obtained by ordinary lookup of the name operator() in the context of (E).operator().
2 In addition, for each non-explicit conversion function declared in T of the form operator conversion-type-id ( ) attribute-specifier-seqopt cv-qualifier ; where cv-qualifier is the same cv-qualification as, or a greater cv-qualification than, cv, and where conversion- type-id denotes the type “pointer to function of (P1,...,Pn) returning R ”, or the type “reference to pointer to function of (P1,...,Pn) returning R ”, or the type “reference to function of (P1,...,Pn) returning R ”, a surrogate call function with the unique name call-function and having the form R call-function ( conversion-type-id F, P1 a1, ... ,Pn an) { return F (a1,... ,an); } 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 of T provided the function is not hidden within T by another intervening declaration128 .
3 If such a surrogate call function is selected by overload resolution, the corresponding conversion function will be called to convert E to the appropriate function pointer or reference, and the function will then be invoked with the arguments of the call. If the conversion function cannot be called (e.g., because of an ambiguity), the program is ill-formed.
4 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:
When comparing the call against the function call operators, the implied object argument is compared against the implicit object parameter of the function call operator. When comparing the call against a surrogate call function, the implied object argument is compared against the ?rst parameter of the surrogate call function. The conversion function from which the surrogate call function was derived will be used in the conversion sequence for that parameter since it converts the implied object argument to the appropriate function pointer or reference required by that ?rst parameter.
— end note ]
[ Example:
点击(此处)折叠或打开
点击(此处)折叠或打开