sdm@cs.brown.edu (Scott Meyers) (02/22/90)
// I'm having trouble making g++ wrappers work correctly. The only // documentation I have to go on is the "User's Guide to GNU C++," the // paper "Solving the RPC problem in GNU C++" from the Denver USENIX C++ // Conference, and the program twrapper.cc from the test directory of // libg++ (1.36.3). Unfortunately, the User's Guide and the paper seem to // be out of date, because g++ insists that wrappers take an int as their // first argument, and the example program offers no insight into when // wrappers are called and when they're not. // // Questions: // - In the program below, why doesn't the statement "object.f()" call // the wrapper? // - In the program below, why does the statement "object.WrapperTest::f()" // elicit an error? #include <stream.h> class WrapperTest { public: void f() { cout << "** In f **\n"; } void ()WrapperTest(int, void (WrapperTest::*pf)()) { cout << "Entering wrapper...\n"; (this->*f)(); cout << "Exiting wrapper...\n"; } }; main() { WrapperTest object; object.f(); // calls f, but not the wrapper object.WrapperTest::()f(); // error: no member function // `WrapperTest::wrapper for `f'' } // More questions: // - Why do wrappers have to have an int as a first argument? // - What are anti-wrappers (mentioned in the source code to g++)? // - Under what conditions are wrappers called, if it's no longer under // control of the wrapper predicate (which does not seem to be the case // in the above example)? // // // All illumination appreciated, // // Scott // sdm@cs.brown.edu