Closed wg21bot closed 1 year ago
Before https://github.com/cplusplus/draft/pull/3625, the rule read
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.
Note "corresponding", meaning the overload resolution choice of surrogate call function determines the conversion function to invoke (even if there is a better one available for the conversion).
After that change, the rule is in [over.call] and reads:
If a surrogate call function for a conversion function named operator conversion-type-id is selected, the expression is interpreted as
postfix-expression . operator conversion-type-id () ( expression-listopt )
which does permit a different overload resolution result for the conversion.
CWG2649
CWG 2022-11-08: Accepted.
Contrary to the note in the subject paragraph, overload resolution in selecting a surrogate call function can prefer a different conversion operator for the implicit conversion sequence because the conversion function from which the surrogate call function was derived is not the best viable function.
For example, noting that surrogate call functions are not generated from conversion function templates, the single surrogate call function derived from the (non-template) conversion function below is the sole candidate for the call; however, the specialization of the conversion function template is a better candidate for the implicit conversion sequence during overload resolution:
Remove from the note:
The conversion function from which the surrogate call function was derived will be used in the conversion sequence for that parameter since if converts the implied object argument to the appropriate function pointer or reference required by that first parameter.