| 1 |
// { dg-do run } |
| 2 |
// prms-id: 5840 |
| 3 |
|
| 4 |
class Signal { |
| 5 |
public: |
| 6 |
int Name(void) { return 1; } |
| 7 |
}; |
| 8 |
|
| 9 |
class Derived : public Signal { |
| 10 |
public: |
| 11 |
int Name(void) { return 2; } |
| 12 |
}; |
| 13 |
|
| 14 |
template <class Foo , int (Foo::*Id)(void)> |
| 15 |
class Bar |
| 16 |
{ |
| 17 |
public: |
| 18 |
int value (Foo* a) { return (a->*Id)(); } |
| 19 |
}; |
| 20 |
|
| 21 |
/* The following line is illegal under the new rules for non-type |
| 22 |
template arguments in the standard, so it is commented out. */ |
| 23 |
/* template class Bar <Derived, &Signal::Name>; */ |
| 24 |
template class Bar <Signal, &Signal::Name>; |
| 25 |
template class Bar <Derived, &Derived::Name>; |
| 26 |
|
| 27 |
Derived a; |
| 28 |
|
| 29 |
/* Bar<Derived, &Signal::Name> dispatcher1; */ |
| 30 |
Bar<Derived, &Derived::Name> dispatcher2; |
| 31 |
|
| 32 |
int main() { |
| 33 |
/* int i1 = dispatcher1.value(&a); */ |
| 34 |
int i2 = dispatcher2.value(&a); |
| 35 |
return /* i1 != 1 || */ i2 != 2; |
| 36 |
} |