Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/spaceship-synth13.C

raw
1 // { dg-do compile { target c++20 } }
2
3 #include <compare>
4 #include <type_traits>
5
6 struct E;
7 struct D {
8 auto operator<=>(const D&) const = default;
9 float f;
10 };
11 struct E : D {
12 auto operator<=>(const E&) const = default;
13 int i;
14 };
15 extern E e1, e2;
16 auto a = e1 <=> e2;
17 static_assert (std::is_same_v <decltype (a), std::partial_ordering>);
18 struct G;
19 struct H {
20 constexpr auto operator<=>(const H&) const = default;
21 float f;
22 };
23 struct G : H {
24 constexpr auto operator<=>(const G&) const = default;
25 int i;
26 };
27 extern G g1, g2;
28 auto c = g1 <=> g2;
29 static_assert (std::is_same_v <decltype (c), std::partial_ordering>);