c++ - boost::python argument type did not match -
i export class wrapper:
#include <boost/python.hpp> namespace { namespace bp = boost::python; class { public: a(){} virtual ~a(){} }; struct a_wrap: a, bp::wrapper<a>{ //ctr a_wrap():a(){} //dtr ~a_wrap(){} //func void foo(){ pysys_writestdout("test in"); } }; a* make_a(){ return new a(); } boost_python_module(a){ bp::class_<a_wrap, boost::noncopyable>("a_wrap", bp::init<>()) .def("foo", &a_wrap::foo) ; bp::def("make_a", &make_a, bp::return_value_policy<bp::manage_new_object>()); } } in python:
import a = a.make_a() a.foo() results in error:
traceback (most recent call last): file "<stdin>", line 1, in <module> boost.python.argumenterror: python argument types in a_wrap.foo(a_wrap) did not match c++ signature: foo((anonymous namespace)::a_wrap {lvalue}) im wondering why missmatch?
i know might unusable, exact same problem arises on similar method useable me. simplified way reproduced problem.
thanks.
you're trying do:
void foo(a_wrap* ) { } a* = new a; foo(a); // invalid conversion a* a_wrap* that wouldn't work in c++ either. meant make_a return a_wrap:
a* make_a() { return new a_wrap(); } that makes code work me:
>>> import >>> = a.make_a() >>> a.foo() test in>>> >>>
Comments
Post a Comment