[C++-sig] Can't use make_function to wrap base class method? (original) (raw)

Alex Mohr amohr at pixar.com
Thu Dec 15 19:58:37 CET 2005


You either need to wrap Base or you need to

.def( "method", makefunction( (int (Derived::*)()) &Derived::method ) ) class has the information about the derived class (it's a template argument), so it can do the cast automagically. However, makefunction is just a function, so it can't do anything fancy with Derived. The function pointer's type is int (Base::*)() even when you get it via &Derived::method.

Ahh, that makes perfect sense. Thanks! Does it make sense to add something like:

make_method(&Derived::method)

Which would just call make_function with the appropriate cast? Perhaps I could give it a shot if it seems like a good idea. Or perhaps it would be better to have a form of make_function like this?

Alex



More information about the Cplusplus-sig mailing list