| 1 |
// RUN: %clang_cc1 -std=c++2a -verify %s |
| 2 |
|
| 3 |
template<typename T, typename U> |
| 4 |
constexpr static bool is_same_v = false; |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
constexpr static bool is_same_v<T, T> = true; |
| 8 |
|
| 9 |
template<typename T> |
| 10 |
concept AtLeast2 = sizeof(T) >= 2; |
| 11 |
|
| 12 |
template<typename T> |
| 13 |
concept AtMost8 = sizeof(T) <= 8; |
| 14 |
|
| 15 |
template<typename T> |
| 16 |
struct S { |
| 17 |
static int foo() requires AtLeast2<long> && AtMost8<long> { |
| 18 |
return 0; |
| 19 |
} |
| 20 |
|
| 21 |
static double foo() requires AtLeast2<char> { |
| 22 |
return 0.0; |
| 23 |
} |
| 24 |
|
| 25 |
static char bar() requires AtLeast2<char> { |
| 26 |
return 1.0; |
| 27 |
} |
| 28 |
|
| 29 |
static short bar() requires AtLeast2<long> && AtMost8<long> { |
| 30 |
return 0.0; |
| 31 |
} |
| 32 |
|
| 33 |
static int bar() requires AtMost8<long> && AtLeast2<long> { |
| 34 |
return 0.0; |
| 35 |
} |
| 36 |
|
| 37 |
static char baz() requires AtLeast2<char> { |
| 38 |
return 1.0; |
| 39 |
} |
| 40 |
|
| 41 |
static short baz() requires AtLeast2<long> && AtMost8<long> { |
| 42 |
return 0.0; |
| 43 |
} |
| 44 |
|
| 45 |
static int baz() requires AtMost8<long> && AtLeast2<long> { |
| 46 |
return 0.0; |
| 47 |
} |
| 48 |
|
| 49 |
static long baz() requires AtMost8<long> && AtLeast2<long> && AtLeast2<short> { |
| 50 |
return 3.0; |
| 51 |
} |
| 52 |
}; |
| 53 |
|
| 54 |
void a() { |
| 55 |
static_assert(is_same_v<decltype(&S<int>::foo), int(*)()>); |
| 56 |
static_assert(is_same_v<decltype(&S<int>::bar), long(*)()>); |
| 57 |
// expected-error@-1{{reference to overloaded function could not be resolved; did you mean to call it?}} |
| 58 |
static_assert(is_same_v<decltype(&S<int>::baz), long(*)()>); |
| 59 |
} |