1 // RUN: %clang_cc1 -std=c++2a -verify %s
4 struct strong_ordering
{
6 constexpr operator int() const { return n
; }
7 static const strong_ordering less
, equal
, greater
;
9 constexpr strong_ordering
strong_ordering::less
{-1}, strong_ordering::equal
{0}, strong_ordering::greater
{1};
14 std::strong_ordering
operator<=>(const A
&) const = default;
17 static_assert(A
{1, 2, 3, 4, 5} <= A
{1, 2, 3, 4, 5});
18 static_assert(A
{1, 2, 3, 4, 5} <= A
{0, 20, 3, 4, 5}); // expected-error {{failed}}
19 static_assert(A
{1, 2, 3, 4, 5} <= A
{1, 0, 30, 4, 5}); // expected-error {{failed}}
20 static_assert(A
{1, 2, 3, 4, 5} <= A
{1, 2, 0, 40, 5}); // expected-error {{failed}}
21 static_assert(A
{1, 2, 3, 4, 5} <= A
{1, 2, 3, 0, 50}); // expected-error {{failed}}
22 static_assert(A
{1, 2, 3, 4, 5} <= A
{1, 2, 3, 4, 0}); // expected-error {{failed}}
24 struct reverse_compare
{
26 constexpr explicit reverse_compare(std::strong_ordering o
) : n(-o
.n
) {}
27 constexpr operator int() const { return n
; }
32 friend reverse_compare
operator<=>(const B
&, const B
&) = default;
34 static_assert(B
{1, 2, 3, 4, 5} >= B
{1, 2, 3, 4, 5});
35 static_assert(B
{1, 2, 3, 4, 5} >= B
{0, 20, 3, 4, 5}); // expected-error {{failed}}
36 static_assert(B
{1, 2, 3, 4, 5} >= B
{1, 0, 30, 4, 5}); // expected-error {{failed}}
37 static_assert(B
{1, 2, 3, 4, 5} >= B
{1, 2, 0, 40, 5}); // expected-error {{failed}}
38 static_assert(B
{1, 2, 3, 4, 5} >= B
{1, 2, 3, 0, 50}); // expected-error {{failed}}
39 static_assert(B
{1, 2, 3, 4, 5} >= B
{1, 2, 3, 4, 0}); // expected-error {{failed}}