libstdc++-v3/testsuite/20_util/optional/relops/lwg3746.cc
raw| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | // LWG 3746. optional's spaceship with U with a type derived from optional |
| 4 | // causes infinite constraint meta-recursion |
| 5 | |
| 6 | #include <optional> |
| 7 | |
| 8 | struct S : std::optional<char> |
| 9 | { |
| 10 | bool operator==(const S&) const; |
| 11 | bool operator<(const S&) const; |
| 12 | bool operator>(const S&) const; |
| 13 | bool operator<=(const S&) const; |
| 14 | bool operator>=(const S&) const; |
| 15 | }; |
| 16 | |
| 17 | auto cmp(const S& s, const std::optional<char>& o) |
| 18 | { |
| 19 | return s <=> o; |
| 20 | } |