I\'m trying to get Boost Python to play nicely with std::shared_ptr. Currently, I\'m receiving this error:
Traceback (most recent call last):
File \"test.py\",
A snippet from http://boost.2283326.n4.nabble.com/No-automatic-upcasting-with-std-shared-ptr-in-function-calls-td4573165.html:
/* make boost::python understand std::shared_ptr */
namespace boost {
template
T *get_pointer(std::shared_ptr p)
{
return p.get();
}
}
Worked for me. You would define your classes like:
class_>("Foo", ...);
With this, other methods returning std::shared_ptr
will Just Work.
Some magic may be required for virtual functions/polymorphism, that should be covered in the thread I linked to.