Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/explicit-obj-basic5.C

raw
1 // P0847R7
2 // { dg-do run { target c++23 } }
3
4 // conversion operators with xobj parameter
5
6 inline constexpr int magic = 42;
7
8 struct S0 {
9 operator int(this S0 const&) {
10 return magic;
11 }
12 };
13
14 struct S1 {
15 int _v;
16 int f(this int self) {
17 return self;
18 }
19 operator int(this S1 const& self) {
20 return self._v;
21 }
22 };
23
24 int main()
25 {
26 if (S0{} != magic)
27 __builtin_abort ();
28
29 S1 s{42};
30 if (static_cast<int>(s) != magic)
31 __builtin_abort ();
32 }
33