| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
template<typename T> |
| 4 |
concept C = __is_class(T); |
| 5 |
|
| 6 |
template<typename T> |
| 7 |
concept D = C<T> && __is_empty(T); |
| 8 |
|
| 9 |
struct X { }; |
| 10 |
struct Y { int n; }; |
| 11 |
|
| 12 |
template<typename T> struct S { void f1() { } }; // #1 |
| 13 |
template<C T> struct S<T> { void f2() { } }; // #2 |
| 14 |
template<D T> struct S<T> { void f3() { } }; // #3 |
| 15 |
|
| 16 |
template struct S<int>; // Instantiate #1 |
| 17 |
template struct S<X>; // Instantiate #2 |
| 18 |
template struct S<Y>; // Instantiate #2 |
| 19 |
|
| 20 |
int main() { |
| 21 |
S<int> i; i.f1(); |
| 22 |
S<X> x; x.f3(); |
| 23 |
S<Y> y; y.f2(); |
| 24 |
} |