I was wondering if any one here might be able to help me out with the following problem I'm having.
I seem unable to create a boost::python::object from a c++ class I've bound to python that is noncopyable. Here is a simplified example..
#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);
}
Then at runtime in 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
I realise that the boost::noncopyable parameter prevents a to_python converter for A being registered. Does anyone know how I might be able to create a boost::python::object from an A instance ?
thanks in advance!