aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/p5840.C
blob: 46a161beec89c0a855d5d92d6f955b608a0882f5 (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
// prms-id: 5840

class Signal {
public:
  int Name(void) { return 1; }
};

class Derived : public Signal {
public:
  int Name(void) { return 2; }
};

template <class Foo , int (Foo::*Id)(void)>
class Bar
{
public:
  int value (Foo* a) { return (a->*Id)(); }
};

template class Bar <Derived, &Signal::Name>;
template class Bar <Signal, &Signal::Name>;
template class Bar <Derived, &Derived::Name>;

Derived a;

Bar<Derived, &Signal::Name> dispatcher1;
Bar<Derived, &Derived::Name> dispatcher2;

main() {
  int i1 = dispatcher1.value(&a);
  int i2 = dispatcher2.value(&a);
  return i1 != 1 || i2 != 2;
}