gcc/testsuite/g++.old-deja/g++.mike/pmf7.C
raw| 1 | // { dg-do run } |
| 2 | class A; |
| 3 | typedef int (A::*f_ptr) (void); |
| 4 | |
| 5 | class B { |
| 6 | public: |
| 7 | B() {} ~B() {} |
| 8 | B& dummy(f_ptr cb) { return *this; } |
| 9 | }; |
| 10 | |
| 11 | template<class SP, class CB> SP& call_dummy(SP* sp, CB cb) { |
| 12 | sp->dummy(cb); |
| 13 | return *sp; |
| 14 | } |
| 15 | |
| 16 | class A { |
| 17 | public: |
| 18 | A() {} ~A() {} |
| 19 | int ok() { return 0; } |
| 20 | A& call_it(B* s) { |
| 21 | call_dummy(s, &A::ok); |
| 22 | return *this; |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | int main() { |
| 27 | A a; B b; |
| 28 | a.call_it(&b); |
| 29 | return 0; |
| 30 | } |