| 1 |
// PR c++/105842 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
template<class T> |
| 5 |
struct S { |
| 6 |
static void func1() requires __is_same(T, int); |
| 7 |
static void func1() requires (!__is_same(T, int)); |
| 8 |
|
| 9 |
static void func2() requires false && false; |
| 10 |
static void func2() requires false; |
| 11 |
|
| 12 |
template<class...> static void tmpl1() requires __is_same(T, int); |
| 13 |
template<class...> static void tmpl1() requires (!__is_same(T, int)); |
| 14 |
|
| 15 |
template<class... Us> static void tmpl2() requires (sizeof...(Us) == 1); |
| 16 |
template<class... Us> static void tmpl2() requires (sizeof...(Us) == 2); |
| 17 |
|
| 18 |
static void foo() { |
| 19 |
// Both calls resolve to the first overload at instantiation time. |
| 20 |
func1(); |
| 21 |
tmpl1(); |
| 22 |
} |
| 23 |
|
| 24 |
static void bar() { |
| 25 |
// We can check and reject both calls ahead of time since the functions' |
| 26 |
// constraints don't depend on outer template parameters. |
| 27 |
func2(); // { dg-error "no match" } |
| 28 |
tmpl2(); // { dg-error "no match" } |
| 29 |
} |
| 30 |
}; |
| 31 |
|
| 32 |
int main() { |
| 33 |
S<int>::foo(); |
| 34 |
} |