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