boost.python - Virtual Functions with Default Implementations

Sam sam at
Fri Apr 25 00:07:33 CEST 2003

I'm trying to get virtual functions with default implementations to be
exposed to Python.  When I follow the examples given on the

...I get the following error:
: error C2440: 'return' : cannot convert from 'int (__thiscall
giPython::BaseWrap::*const )(void)' to 'const char *'
        There is no context in which this conversion is possible
: while compiling class-template member function 'const char
*__thiscall boost::python::detail::def_helper<int (__thiscall
boost::python::detail::not_specified>::doc(void) const'

Anyone have any ideas?  Here is my code:

using namespace boost::python;
namespace giPython
    struct Base
        virtual int f() { return 0; }

    struct BaseWrap : Base
        BaseWrap(PyObject* self_)
            : self(self_) {}
        int f() { return call_method<int>(self, "f"); }
        int default_f() { return Base::f(); }
        PyObject* self;

void SetupPythonWrappers (scope& this_module)
    class_<Base, BaseWrap>("Base")
    .def("f", &Base::f, &BaseWrap::default_f);

} // namespace giPython

More information about the Python-list mailing list