I use Boost.Python to create a wrapper for my C ++ library, and I am having problems; searching the site all day has not yielded any results. For example, I have the following code:
class Base { public: virtual void func() = 0; }; class Derived : public Base { public: virtual void func() { cout << "Derived::func()"<< endl; } };
So, I will compile it, import into python and try the following:
b = mylib.Base () b.func ()
d = mylib.makeDerived () d.func ()
The first line, as expected, throws an exception saying that b.func () is purely virtual, and the second line outputs
Derived :: FUNC ()
And this is normal.
But the code
dlist = mylib.makeDerivedVec() for d in dlist: d.func()
does not work, and Python throws an exception:
TypeError: No to_python (by-value) converter found for C++ type: Base*
Why does it correctly process the base * returned by makeDerived () and refuses to work with the base * contained in std :: vector? How can I make it work?
source share