
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 0.55 KB | hits: 8 | expires: Never
Boost.python overloaded constructor for numpy array and python list
using boost;
using boost::python;
shared_ptr<MyClass> CreateWithList(list lst)
{
// construct with a list here
}
shared_ptr<MyClass> CreateWithPyArrayObject(PyArrayObject* obj)
{
// construct with numpy array here
}
BOOST_PYTHON_MODULE(mymodule)
{
class_<MyClass, boost::noncopyable, boost::shared_ptr<MyClass> >
("MyClass", no_init)
.def("__init__", make_constructor(&CreateWithList))
.def("__init__", make_constructor(&CreateWithPyArrayObject))
}