Debian Codegraph @

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

raw
1 // { dg-do compile }
2
3 // Copyright (C) 2003 Free Software Foundation
4 // Contributed by Kriang Lerdsuwanakij <[email protected]>
5
6 // Member function of class template as friend
7
8 template<class T> struct A
9 {
10 template <T t> void f();
11 };
12
13 class C {
14 int i;
15 template<class T> template <T t> friend void A<T>::f();
16 };
17
18 template<class T> struct A<T*>
19 {
20 template <T* t> void f();
21 };
22
23 template<> struct A<char>
24 {
25 template <char t> void f();
26 };
27
28 template<class T> template <T t> void A<T>::f()
29 {
30 C c;
31 c.i = 0;
32 }
33
34 template<class T> template <T* t> void A<T*>::f()
35 {
36 C c;
37 c.i = 0;
38 }
39
40 template <char t> void A<char>::f()
41 {
42 C c;
43 c.i = 0;
44 }
45
46 template <> void A<char>::f<'b'>()
47 {
48 C c;
49 c.i = 0;
50 }
51
52 int d2 = 0;
53
54 int main()
55 {
56 A<int> a1;
57 a1.f<0>();
58 A<int *> a2;
59 a2.f<&d2>();
60 A<char> a3;
61 a3.f<'a'>();
62 a3.f<'b'>();
63 }