libstdc++-v3/testsuite/20_util/optional/relops/104606.cc
raw| 1 | // { dg-do compile { target c++17 } } |
| 2 | |
| 3 | // Bug 104606 comparison operator resolution with std::optional and -std=c++20 |
| 4 | |
| 5 | #include <optional> |
| 6 | #include <variant> |
| 7 | #include <vector> |
| 8 | |
| 9 | struct Value : std::variant<std::vector<Value>> { }; |
| 10 | |
| 11 | struct Comparator { |
| 12 | template <typename T> bool operator<=(const T &) { return true; } |
| 13 | }; |
| 14 | |
| 15 | std::optional<Value> o; |
| 16 | Comparator c; |
| 17 | |
| 18 | auto x = c <= o; |