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

Alex Mohr amohr at pixar.com
Tue Dec 13 20:37:25 CET 2005


Seems I can't wrap a base class method of a derived class if I use make_function. Is this expected? Here's an example.

#include <boost/python.hpp> using namespace boost::python;

class Base { public: int method() { return 1; } };

class Derived : public Base {};

BOOST_PYTHON_MODULE(Foo) { class_("Derived", "", init<>()) .def("method", make_function(&Derived::method)) .def("method2", &Derived::method) ; }

from Foo import * Derived().method() Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in Derived.method(Derived) did not match C++ signature: method(Base {lvalue})

Derived().method2() 1

Seems like this should work. Wrapping a method in make_function seems to make it not. This becomes cumbersome since the only way I know of to supply return_value_policies in .add_property is to use make_function.

Thanks,

Alex



More information about the Cplusplus-sig mailing list