Debian Codegraph @

libstdc++-v3/testsuite/18_support/comparisons/algorithms/fallback.cc

raw
1 // { dg-do compile { target c++20 } }
2
3 #include <compare>
4
5 using std::strong_ordering;
6 using std::partial_ordering;
7
8 namespace adl
9 {
10 struct S { };
11 void strong_ordering(const S&, const S&);
12 bool operator==(const S&, S&) { return true; }
13 bool operator<(const S&, S&) { return true; }
14 }
15
16 template<typename T, typename U>
17 concept has_strong_order_fallback = requires (T& t, U& u) {
18 std::compare_strong_order_fallback(t, u);
19 };
20
21 template<typename T, typename U>
22 concept has_weak_order_fallback = requires (T& t, U& u) {
23 std::compare_weak_order_fallback(t, u);
24 };
25
26 template<typename T, typename U>
27 concept has_partial_order_fallback = requires (T& t, U& u) {
28 std::compare_partial_order_fallback(t, u);
29 };
30
31 using adl::S;
32
33 static_assert( ! has_strong_order_fallback<S, S> );
34 static_assert( has_strong_order_fallback<const S, S> );
35 static_assert( ! has_strong_order_fallback<const S, const S> );
36 static_assert( ! has_weak_order_fallback<S, S> );
37 static_assert( has_weak_order_fallback<const S, S> );
38 static_assert( ! has_weak_order_fallback<const S, const S> );
39 static_assert( ! has_partial_order_fallback<S, S> );
40 static_assert( ! has_partial_order_fallback<const S, S> ); // LWG 3465
41 static_assert( ! has_partial_order_fallback<const S, const S> );