diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp2a/spaceship-synth2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/spaceship-synth2.C | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp2a/spaceship-synth2.C b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth2.C new file mode 100644 index 00000000000..cf23c9771e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/spaceship-synth2.C @@ -0,0 +1,43 @@ +// Test with only spaceship defaulted. +// { dg-do run { target c++2a } } + +#include <compare> + +struct D +{ + int i; + auto operator<=>(const D& x) const = default; + // auto operator==(const D& x) const = default; + // auto operator!=(const D& x) const = default; + // auto operator<(const D& x) const = default; + // auto operator<=(const D& x) const = default; + // auto operator>(const D& x) const = default; + // auto operator>=(const D& x) const = default; +}; + +#define assert(X) do { if (!(X)) __builtin_abort(); } while (0) + +int main() +{ + D d{42}; + D d2{24}; + + assert (is_eq (d <=> d)); + assert (is_lteq (d <=> d)); + assert (is_gteq (d <=> d)); + assert (is_lt (d2 <=> d)); + assert (is_lteq (d2 <=> d)); + assert (is_gt (d <=> d2)); + assert (is_gteq (d <=> d2)); + + assert (d == d); + assert (!(d2 == d)); + assert (!(d == d2)); + assert (d != d2); + assert (!(d2 != d2)); + + assert (d2 < d); + assert (d2 <= d); + assert (d > d2); + assert (d >= d2); +} |