| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
template <class T, class U> concept same_as = __is_same(T, U); |
| 4 |
|
| 5 |
// this constrained placeholder type should get resolved at parse time |
| 6 |
template <class T> same_as<bool> auto x = true; |
| 7 |
|
| 8 |
template <auto V> same_as<int> auto y = V; // { dg-error "constraint" } |
| 9 |
|
| 10 |
template <class> |
| 11 |
struct A { |
| 12 |
template <auto V> static inline same_as<int> auto z = V; // { dg-error "constraint" } |
| 13 |
}; |
| 14 |
|
| 15 |
int main() { |
| 16 |
x<int>; // { dg-bogus "" } |
| 17 |
y<0>; // { dg-bogus "" } |
| 18 |
y<'0'>; // { dg-message "required from here" } |
| 19 |
A<void>::z<0>; // { dg-bogus "" } |
| 20 |
A<void>::z<'0'>; // { dg-message "required from here" } |
| 21 |
} |
| 22 |
|
| 23 |
// unsatisfied placeholder type constraint diagnosed at parse time |
| 24 |
template <class T> same_as<int> auto w = true; // { dg-error "constraint" } |