aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic2.C
blob: 6b2cad130faf4ba35af580b80d876d272176ac47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// P0847R7
// { dg-do run { target c++23 } }

// explicit object member function pointer type deduction,
// conversion to function pointer,
// and calling through pointer to function

struct S {
  int _n;
  int f(this S& self) { return self._n; }
};

using f_type = int(*)(S&);

static_assert (__is_same (f_type, decltype (&S::f)));

int main()
{
  auto fp0 = &S::f;
  f_type fp1 = &S::f;
  static_assert (__is_same (decltype (fp0), decltype (fp1)));
  S s{42};
  if (fp0 (s) != 42)
    __builtin_abort ();
  if (fp1 (s) != 42)
    __builtin_abort ();
}