[C++-sig] C++ object pointers contained in a vector
noah.schwartz1 at gmail.com
Wed Oct 18 22:15:49 CEST 2006
On Wednesday 18 October 2006 16:09, Roman Yakovenko wrote:
> On 10/18/06, Noah Schwartz <noah.schwartz1 at gmail.com> wrote:
> > Hi,
> > I've used the vector_indexing_suite to expose vectors containing pointers
> > to some class. I see that I can't iterate over this vector in Python like
> > I can with say, a vector of floats. I get the following error:
> > TypeError: No to_python (by-value) converter found for C++ type: MyClass*
> > MyClass is already exposed properly. I can even use a MyClass* fine in
> > Python when other C++ functions return a pointer to one.
> > I am guessing that I need to define a to_python converter either in
> > MyClass or in a new class, MyClass*. Not really sure how that works
> > though.
> Try to set NoProxy to true
> Does it help?
So, something like this?
class_<std::vector<MyClass *> >("VectorMyClassP")
.def(vector_indexing_suite<std::vector<MyClass *>, true >())
More information about the Cplusplus-sig