Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/spaceship-synth4.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // Test with all operators explicitly defaulted. | |
2 // { dg-do run { target c++2a } } | |
3 | |
4 #include <compare> | |
5 | |
6 struct D | |
7 { | |
8 int i; | |
9 friend auto operator<=>(const D& x, const D& y) = default; | |
10 friend bool operator==(const D& x, const D& y) = default; | |
11 friend bool operator!=(const D& x, const D& y) = default; | |
12 friend bool operator<(const D& x, const D& y) = default; | |
13 friend bool operator<=(const D& x, const D& y) = default; | |
14 friend bool operator>(const D& x, const D& y) = default; | |
15 friend bool operator>=(const D& x, const D& y) = default; | |
16 }; | |
17 | |
18 #define assert(X) do { if (!(X)) __builtin_abort(); } while (0) | |
19 | |
20 int main() | |
21 { | |
22 D d{42}; | |
23 D d2{24}; | |
24 | |
25 assert (is_eq (d <=> d)); | |
26 assert (is_lteq (d <=> d)); | |
27 assert (is_gteq (d <=> d)); | |
28 assert (is_lt (d2 <=> d)); | |
29 assert (is_lteq (d2 <=> d)); | |
30 assert (is_gt (d <=> d2)); | |
31 assert (is_gteq (d <=> d2)); | |
32 | |
33 assert (d == d); | |
34 assert (!(d2 == d)); | |
35 assert (!(d == d2)); | |
36 assert (d != d2); | |
37 assert (!(d2 != d2)); | |
38 | |
39 assert (d2 < d); | |
40 assert (d2 <= d); | |
41 assert (d > d2); | |
42 assert (d >= d2); | |
43 } |