Debian Codegraph @

libstdc++-v3/testsuite/20_util/variant/relops/115145.cc

raw
1 // { dg-do compile { target c++17 } }
2 // PR libstdc++/115145
3 // lambda in rewritten std::variant comparisons does not specify return type
4
5 #include <variant>
6
7 struct Bool {
8 operator bool() & { return val; }
9 const bool val;
10 };
11
12 Bool t{true}, f{false};
13
14 struct A {
15 Bool& operator==(const A&) const { return t; }
16 Bool& operator!=(const A&) const { return f; }
17 Bool& operator<(const A&) const { return f; }
18 Bool& operator>(const A&) const { return f; }
19 Bool& operator<=(const A&) const { return t; }
20 Bool& operator>=(const A&) const { return t; }
21 };
22
23 bool check_bool(bool);
24 template<typename T> void check_bool(T) = delete;
25
26 void
27 test_pr115145()
28 {
29 std::variant<A> v;
30 check_bool( v == v );
31 check_bool( !(v != v) );
32 check_bool( !(v < v) );
33 check_bool( !(v > v) );
34 check_bool( v <= v );
35 check_bool( v >= v );
36 }