aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/template/memfriend3.C
blob: 3ea8c84cf25164be0925064e64f75929e32bcce4 (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
// { dg-do compile }

// Copyright (C) 2003 Free Software Foundation
// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>

// Member function of class template as friend

template<class T> struct A
{
  void f(T);
};

class C {
  int i;
  template<class T> friend void A<T>::f(T);
};

template<class T> struct A<T*>
{
  void f(T*);
};

template<> struct A<char>
{
  void f(char);
};

template<class T> void A<T>::f(T)
{
  C c;
  c.i = 0;
}

template<class T> void A<T*>::f(T*)
{
  C c;
  c.i = 0;
}

void A<char>::f(char)
{
  C c;
  c.i = 0;
}

int main()
{
  A<int> a1;
  a1.f(0);
  A<int *> a2;
  int *p = 0;
  a2.f(p);
  A<char> a3;
  a3.f('a');
}