Debian Codegraph @

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

raw
1 // Test virtual <=>.
2 // { dg-do run { target c++20 } }
3
4 #include <compare>
5
6 struct E;
7 struct D {
8 std::partial_ordering operator<=>(const D&) const = default;
9 virtual std::partial_ordering operator<=>(const E&) const = 0;
10 float f;
11 D(float f): f(f) {}
12 };
13 struct E : D {
14 std::partial_ordering operator<=>(const E&) const override = default;
15 int i;
16 E(float f, int i): D(f), i(i) {}
17 };
18
19 int main()
20 {
21 E e1{0.0,42};
22 E e2{1.0,24};
23 auto a = e1 <=> e2;
24 if (!is_lt (e1 <=> e2))
25 __builtin_abort();
26 }