summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.brendan/template11.C
blob: bc5724985da05dc6d6b2cd7531380f61ecc0d7f4 (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
// { dg-do assemble  }
// GROUPS passed templates
template <class Called>
class aCallback
{
public:
  aCallback(Called& obj, int (Called::*met)());

  int callback();
  
protected:

private:
  // the object to call
  Called&       object;
  
  // the method to apply
  int (Called::*method)();
  
};

template <class Called>
aCallback<Called>::aCallback(Called& obj,
                             int (Called::*met)()) :
object(obj),
method(met)
{}

template <class Called>
int aCallback<Called>::callback()
{
  return (object.*method)();
}

struct myStruct
{
  int action() {return 24;}
};

int main()
{
  myStruct toto;

  aCallback<myStruct>   cb(toto, &myStruct::action);

  return cb.callback();
}