111
|
1 // { dg-options "-std=c++17 -fconcepts" }
|
|
2
|
|
3 template<typename T>
|
|
4 concept bool Class() { return __is_class(T); }
|
|
5
|
|
6 template<typename T>
|
|
7 concept bool Union() { return __is_union(T); }
|
|
8
|
|
9
|
|
10 // Check ordering of specializations
|
|
11 template<typename T>
|
|
12 concept bool One() { return sizeof(T) >= 4; }
|
|
13
|
|
14 template<typename T>
|
|
15 concept bool Two() { return One<T>() && sizeof(T) >= 8; }
|
|
16
|
|
17 // Check non-overlapping specializations
|
|
18 template<typename T>
|
|
19 struct S1 { static const int value = 0; };
|
|
20
|
|
21 template<Class T>
|
|
22 struct S1<T> { static const int value = 1; };
|
|
23
|
|
24 template<Union T>
|
|
25 struct S1<T> { static const int value = 2; };
|
|
26
|
|
27 struct S { };
|
|
28 union U { };
|
|
29
|
|
30 static_assert(S1<int>::value == 0, "");
|
|
31 static_assert(S1<S>::value == 1, "");
|
|
32 static_assert(S1<U>::value == 2, "");
|
|
33
|
|
34
|
|
35 // Check ordering of partial specializaitons
|
|
36 template<typename T>
|
|
37 struct S2 { static const int value = 0; };
|
|
38
|
|
39 template<One T>
|
|
40 struct S2<T> { static const int value = 1; };
|
|
41
|
|
42 template<Two T>
|
|
43 struct S2<T> { static const int value = 2; };
|
|
44
|
|
45 struct one_type { char x[4]; };
|
|
46 struct two_type { char x[8]; };
|
|
47
|
|
48 static_assert(S2<char>::value == 0, "");
|
|
49 static_assert(S2<one_type>::value == 1, "");
|
|
50 static_assert(S2<two_type>::value == 2, "");
|
|
51
|
|
52 int main() { }
|