| 1 |
// PR c++/97121 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
#include <compare> |
| 5 |
|
| 6 |
class MyClass |
| 7 |
{ |
| 8 |
int mValue; // { dg-error "three-way comparison of 'MyClass::mValue' has type 'std::strong_ordering', which does not convert to 'bool'" } |
| 9 |
|
| 10 |
public: |
| 11 |
MyClass(int value): mValue(value) {} |
| 12 |
|
| 13 |
bool operator<=>(const MyClass&) const = default; // { dg-error "invalid 'static_cast' from type 'const std::strong_ordering' to type 'bool'" } |
| 14 |
}; |
| 15 |
|
| 16 |
int main() |
| 17 |
{ |
| 18 |
MyClass a = 10, b = 15; |
| 19 |
return (a < b); // { dg-error "use of deleted function 'constexpr bool MyClass::operator<=>\\\(const MyClass&\\\) const'" } |
| 20 |
} |