Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-pr67684.C

raw
1 // { dg-do compile { target c++20 } }
2 // { dg-additional-options "-fconcepts" }
3
4 template<class T>
5 class A {
6 public:
7 template<int I, class S>
8 requires (I > 0)
9 friend int f1(const A<S>&);
10
11 template<int I, class S>
12 friend int f2(const A<S>&) requires (I > 0);
13
14 private:
15 int x = 2;
16 };
17
18 template<int I, class S>
19 requires (I > 0)
20 int f1(const A<S>& a) {
21 return a.x;
22 }
23
24 template<int I, class S>
25 int f2(const A<S>& a) requires (I > 0) {
26 return a.x;
27 }
28
29 class B {
30 public:
31 template<int I>
32 requires (I > 0)
33 friend int f3(const B&);
34
35 template<int I>
36 friend int f4(const B&) requires (I > 0);
37
38 private:
39 int x = 2;
40 };
41
42 template<int I>
43 requires (I > 0)
44 int f3(const B& a) {
45 return a.x;
46 }
47
48 template<int I>
49 int f4(const B& a) requires (I > 0) {
50 return a.x;
51 }
52
53 int main() {
54 A<double> a;
55 f1<2>(a);
56 f2<2>(a);
57
58 B b;
59 f3<2>(b);
60 f4<2>(b);
61
62 return 0;
63 }