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