Debian Codegraph @

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

raw
1 // P0847R7
2 // { dg-do run { target c++23 } }
3
4 // defaulted comparison operators
5
6 #include <compare>
7
8 struct S {
9 int _v;
10 bool operator==(this S const&, S const&) = default;
11 auto operator<=>(this S const&, S const&) = default;
12 };
13
14 int main()
15 {
16 S const a_10{10};
17 S const b_10{10};
18 S const c_20{20};
19 S const d_5{5};
20
21 if (a_10 != b_10)
22 __builtin_abort ();
23 if (c_20 == a_10)
24 __builtin_abort ();
25 if (!(a_10 == b_10))
26 __builtin_abort ();
27 if (!(c_20 != a_10))
28 __builtin_abort ();
29
30 if (a_10 < b_10)
31 __builtin_abort ();
32 if (a_10 > b_10)
33 __builtin_abort ();
34 if (!(a_10 <= b_10))
35 __builtin_abort ();
36 if (!(a_10 >= b_10))
37 __builtin_abort ();
38
39 if (!(a_10 < c_20))
40 __builtin_abort ();
41 if (a_10 > c_20)
42 __builtin_abort ();
43 if (!(a_10 <= c_20))
44 __builtin_abort ();
45 if (a_10 >= c_20)
46 __builtin_abort ();
47
48 if (a_10 < d_5)
49 __builtin_abort ();
50 if (!(a_10 > d_5))
51 __builtin_abort ();
52 if (a_10 <= d_5)
53 __builtin_abort ();
54 if (!(a_10 >= d_5))
55 __builtin_abort ();
56 }
57