boost.python - Virtual Functions with Default Implementations

Sam sam at insidegabriel.com
Thu Apr 24 18:07:33 EDT 2003


I'm trying to get virtual functions with default implementations to be
exposed to Python.  When I follow the examples given on the boost.org
site...
http://www.boost.org/libs/python/doc/tutorial/doc/virtual_functions_with_default_implementations.html

...I get the following error:
c:\projects\publiclibs\boost\boost_1_29_0\boost\python\detail\def_helper.hpp(131)
: 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
        c:\projects\publiclibs\boost\boost_1_29_0\boost\python\detail\def_helper.hpp(130)
: while compiling class-template member function 'const char
*__thiscall boost::python::detail::def_helper<int (__thiscall
giPython::BaseWrap::*)(void),struct
boost::python::detail::not_specified,struct
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