summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/spaceship-synth15.C
blob: 00ea6c10474481ae74a02daf184f270bd40b8fcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// PR c++/96242
// { dg-do compile { target c++20 } }

#include <compare>

template<bool B>
struct X {
  auto operator<=>(const X&) const noexcept(B) = default;
  bool operator==(const X&) const noexcept(!B) = default;
};

X<true> x_t;
static_assert(noexcept(x_t <=> x_t));
static_assert(noexcept(x_t < x_t));
static_assert(!noexcept(x_t == x_t));
static_assert(!noexcept(x_t != x_t));

X<false> x_f;
static_assert(!noexcept(x_f <=> x_f));
static_assert(!noexcept(x_f < x_f));
static_assert(noexcept(x_f == x_f));
static_assert(noexcept(x_f != x_f));