Title
Conversion to function pointer with an explicit object parameter
Status
drafting
Section
12.2.2.2.3 [over.call.object]
Submitter
Christof Meerwald

Created on 2022-04-11.00:00:00 last changed 18 months ago

Messages

Date: 2024-08-20.21:42:59

Subclause 12.2.2.2.3 [over.call.object] paragraph 2 considers only those conversion functions matching a particular grammar pattern. This unintendedly excludes conversion functions with an explicit object parameter (and, as a pre-existing defect, noexcept conversion functions):

In addition, for each non-explicit conversion function declared in T of the form
operator conversion-type-id ( ) cv-qualifier-seqopt ref-qualifieropt noexcept-specifieropt attribute-specifier-seqopt ;
where the optional cv-qualifier-seq 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 declaration. [ Footnote: ...]

For example, there is implementation divergence in handling this example:

  using fn_t = void();
  struct C {
    operator fn_t * (this C const &);
  };

  void foo(C c) {
    c();
  }
History
Date User Action Args
2023-06-20 19:34:52adminsetstatus: open -> drafting
2022-04-11 00:00:00admincreate