aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/explicit-obj-basic5.C
blob: 9cf23d990479e23b6986642706594239bcf5ed99 (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
29
30
31
32
33
// P0847R7
// { dg-do run { target c++23 } }

// conversion operators with xobj parameter

inline constexpr int magic = 42;

struct S0 {
  operator int(this S0 const&) {
    return magic;
  }
};

struct S1 {
  int _v;
  int f(this int self) {
    return self;
  }
  operator int(this S1 const& self) {
    return self._v;
  }
};

int main()
{
  if (S0{} != magic)
    __builtin_abort ();

  S1 s{42};
  if (static_cast<int>(s) != magic)
    __builtin_abort ();
}