Debian Codegraph @

gcc/testsuite/g++.dg/template/friend81a.C

raw
1 // PR c++/112288
2 // { dg-do link }
3 // A version of friend81.C where A and B have a different number of template
4 // parameters.
5
6 template<class T> struct A;
7 template<class T, class = void> struct B;
8
9 A<int>* a;
10 B<int>* b;
11
12 template<class T, class>
13 struct B {
14 template<class U>
15 friend int f(A<T>*, B*, U);
16 };
17
18 template struct B<int>; // f declared
19 int n = f(a, b, 0); // f<int> specialized
20
21 template<class T>
22 struct A {
23 template<class U>
24 friend int f(A*, B<T>*, U) { return 42; }
25 };
26
27 template struct A<int>; // f defined, need to make existing f<int> point to defn
28 int m = f(a, b, 0); // reuses existing specialization f<int>
29
30 int main() { }