| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
// We wrongly considered D to be ne_comparable because we were looking for a |
| 4 |
// corresponding op!= for N::op== in ::, because ::op== happened to be the |
| 5 |
// first thing in the lookup set. |
| 6 |
|
| 7 |
template<bool, typename _Tp = void> |
| 8 |
struct enable_if; |
| 9 |
|
| 10 |
template<typename _Tp> |
| 11 |
struct enable_if<true, _Tp> |
| 12 |
{ typedef _Tp type; }; |
| 13 |
|
| 14 |
template <class T, class U> struct A { }; |
| 15 |
|
| 16 |
namespace N { |
| 17 |
struct X { }; |
| 18 |
template <class T> auto operator== (const A<T,X>&, const A<T,X>&) |
| 19 |
-> typename enable_if<sizeof(T() == T()), bool>::type; |
| 20 |
template <class T> auto operator!= (const A<T,X>&, const A<T,X>&) |
| 21 |
-> typename enable_if<sizeof(T() != T()), bool>::type; |
| 22 |
} |
| 23 |
|
| 24 |
template<typename T, typename U = T> |
| 25 |
concept ne_comparable |
| 26 |
= requires (const A<T,N::X>& t, const A<U,N::X>& u) { |
| 27 |
t != u; |
| 28 |
}; |
| 29 |
|
| 30 |
struct D { }; |
| 31 |
int operator==(D, D); |
| 32 |
bool operator!=(D, D) = delete; |
| 33 |
static_assert( ! ne_comparable<D> ); |