2
我想知道這裏有沒有人能幫我解決以下問題。從不可複製的實例中創建一個boost :: python :: object
我似乎無法從C++類創建boost :: python :: object我已綁定到不可複製的python。下面是一個簡化的例子..
#include <boost/python.hpp>
class A
{
public:
static A*
create() {return new A;}
protected:
A(){}
};
void
doSomething(const A& a)
{
boost::python::object obj(a);
}
BOOST_PYTHON_MODULE(test)
{
boost::python::class_<A, boost::noncopyable>("A", boost::python::no_init)
.def("__init__", boost::python::make_constructor(&A::create));
boost::python::def("doSomething", &doSomething);
}
然後在運行時在python
import test
a = test.A()
test.doSomething(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: No to_python (by-value) converter found for C++ type: A
我知道了boost ::不可複製參數防止to_python轉換器,用於甲正在註冊。有誰知道我可能能夠從A實例創建boost :: python :: object?
在此先感謝!