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

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", 
>               make_function(
>                 (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,
> make_function 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:


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?


More information about the Cplusplus-sig mailing list