错误的意思是,缺少to_python的converter在c++代码中。
下面是创建结构体Unit的to_python的converter的示例。
#include <boost/python.hpp>
#include <string>
struct Unit
{
/*...*/
};
struct Unit_to_python
{
static PyObject* convert(Unit const& unit)
{
return boost::python::incref(
boost::python::object(unit).ptr());
}
};
BOOST_PYTHON_MODULE(test)
{
boost::python::class_<Unit>("Unit");
boost::python::to_python_converter<Unit, Unit_to_python>();
}
附加参考资料:https://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/