[C++-sig] Boost python exposing abstract class , function returning boost::shared_ptr
Holger Joukl
Holger.Joukl at LBBW.de
Fri Mar 27 16:45:00 CET 2015
Hi,
> [...]
> // expose to python
> BOOST_PYTHON_MODULE(grids)
> {
> class_<A2Wrap, boost::shared_ptr<A2Wrap> , boost::noncopyable >("A2")
> .def("ret",pure_virtual(&A2::ret));
>
> class_<B2,boost::shared_ptr<B2>,bases<A2>>("B2");
> def("f1",f1);
> }
>
>
> I get the following result on execution :
>
> >import grids
> >>> a = grids.f1()
>
> Traceback (most recent call last):
>
> File "<stdin>", line 1, in <module>
> TypeError: No to_python (by-value) converter found for C++ type:
> boost::shared_ptr<A2>
What happens if you expose like this:
class_<A2, boost::shared_ptr<A2Wrap> , boost::noncopyable >("A2")
^^
|- original class here, not the callback-wrapper class
?
Holger
Landesbank Baden-Wuerttemberg
Anstalt des oeffentlichen Rechts
Hauptsitze: Stuttgart, Karlsruhe, Mannheim, Mainz
HRA 12704
Amtsgericht Stuttgart
More information about the Cplusplus-sig
mailing list