| 1 |
// PR c++/96242 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
#include <compare> |
| 5 |
|
| 6 |
template<bool B> |
| 7 |
struct X { |
| 8 |
auto operator<=>(const X&) const noexcept(B) = default; |
| 9 |
bool operator==(const X&) const noexcept(!B) = default; |
| 10 |
}; |
| 11 |
|
| 12 |
X<true> x_t; |
| 13 |
static_assert(noexcept(x_t <=> x_t)); |
| 14 |
static_assert(noexcept(x_t < x_t)); |
| 15 |
static_assert(!noexcept(x_t == x_t)); |
| 16 |
static_assert(!noexcept(x_t != x_t)); |
| 17 |
|
| 18 |
X<false> x_f; |
| 19 |
static_assert(!noexcept(x_f <=> x_f)); |
| 20 |
static_assert(!noexcept(x_f < x_f)); |
| 21 |
static_assert(noexcept(x_f == x_f)); |
| 22 |
static_assert(noexcept(x_f != x_f)); |