| 1 |
// P0847R7 |
| 2 |
// { dg-do run { target c++23 } } |
| 3 |
|
| 4 |
// explicit object member function pointer type deduction, |
| 5 |
// conversion to function pointer, |
| 6 |
// and calling through pointer to function |
| 7 |
|
| 8 |
struct S { |
| 9 |
int _n; |
| 10 |
int f(this S& self) { return self._n; } |
| 11 |
}; |
| 12 |
|
| 13 |
using f_type = int(*)(S&); |
| 14 |
|
| 15 |
static_assert (__is_same (f_type, decltype (&S::f))); |
| 16 |
|
| 17 |
int main() |
| 18 |
{ |
| 19 |
auto fp0 = &S::f; |
| 20 |
f_type fp1 = &S::f; |
| 21 |
static_assert (__is_same (decltype (fp0), decltype (fp1))); |
| 22 |
S s{42}; |
| 23 |
if (fp0 (s) != 42) |
| 24 |
__builtin_abort (); |
| 25 |
if (fp1 (s) != 42) |
| 26 |
__builtin_abort (); |
| 27 |
} |
| 28 |
|