[C++-sig] Re: yet another: TypeError: No to_python (by-value) converter found for C++ type:

tALSit de CoD talsit at talsit.org
Mon Aug 23 09:06:44 CEST 2004

Hmm... i've been trying to understand it, i've read the docs... but... 
ummm... i can't quite understand it very well...

Does this mean that when my class does:

const std::vector <cNodeDescriptor *> cRegistry::getDescriptors ();

i have to replace that with this:

cRegistry::getDescriptors ();

Or am i just totally missing the point?

Most of the template magic voodoo still baffels me... :D

David Abrahams wrote:
> "tALSit de CoD" <talsit at talsit.org> writes:
>>Hey guys!
>>I know this has been answered to some extent before, but I just can't 
get to grips with it, so i know i'm doing something wrong...
>>I export the following:
class_ <cNodeDescriptor, boost::noncopyable> ("cNodeDescriptor",
>>	.def ("getClassId",&cNodeDescriptor::getClassId)
>>	.def ("getName",&cNodeDescriptor::getName, return_value_policy
>><copy_const_reference> ())
>>	;
class_ <std::vector <cNodeDescriptor *> > ("cNodeDescriptorList")
>>	.def ("__iter__",	iterator <std::vector <cNodeDescriptor *> > ()) ;
>>And then, in python, i grab a cNodeDescriptorList, and when i try to 
iterate through it, it spits out:
>>TypeError: No to_python (by-value) converter found for C++ type: class 
kikura::cNodeDescriptor *
>>So... what am i doing wrong?
>>If more info is needed, i'd be glad to supply it...
> Try using range
> (http://www.boost.org/libs/python/doc/v2/iterator.html#range-spec) with
a functions that return
> boost::indirect_iterator<std::vector<cNodeDescriptor*>::iterator>
wrapped around the vector's begin() and end().
> (http://www.boost.org/libs/iterator/doc/indirect_iterator.html)
> HTH,

// talsit.org

More information about the Cplusplus-sig mailing list