Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec4.C

raw
1 // { dg-do compile { target c++20 } }
2
3 template <class T> concept is_int = __is_same_as(T,int);
4
5 template <class T> struct A { };
6 template <is_int T> struct A<T*> {
7 typedef int I1;
8 static const A<T*>::I1 j1 = 0;
9 static int f();
10 };
11 template <is_int T> int A<T*>::f()
12 { A<T*>::I1 i; return j1; }
13
14 template <class T> struct A<T*> {
15 typedef int I2;
16 static const A<T*>::I2 j2 = 0;
17 static int f();
18 };
19 template <class T> int A<T*>::f()
20 { A<T*>::I2 i; return j2; }
21
22 const int i1 = A<int*>::j1;
23 const int i2 = A<float*>::j2;
24
25 template <class T> struct B;
26
27 template <is_int T> struct B<T> {
28 typedef int I4;
29 static const B<T>::I4 j4 = 0;
30 static int f();
31 };
32 template <is_int T> int B<T>::f()
33 { B<T>::I4 i; return j4; }
34
35 template <class T> struct B {
36 typedef int I5;
37 static const B<T>::I5 j5 = 0;
38 static int f();
39 };
40 template <class T> int B<T>::f()
41 { B<T>::I5 i; return j5; }
42
43 int i4 = B<int>::j4;
44 int i5 = B<float>::j5;
45 int main()
46 {
47 B<int>::f();
48 B<float>::f();
49 }