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

David Abrahams dave at boost-consulting.com
Mon Aug 23 17:09:53 CEST 2004

"tALSit de CoD" <talsit at talsit.org> writes:

> 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:
> boost::indirect_iterator<std::vector<cNodeDescriptor*>::iterator> 
> cRegistry::getDescriptors ();

I have no idea what getDescriptors is, so it's hard to comment.

> Or am i just totally missing the point?
> Most of the template magic voodoo still baffels me... :D

There's no template magic voodoo to understand this.

  Try using range

Do you understand what range does?

   with functions that return
   wrapped around the vector's begin() and end().

By this I mean
  my_begin(std::vector<cNodeDescriptor*>& v)
       return boost::make_indirect_iterator(v.begin());

  my_end(std::vector<cNodeDescriptor*>& v)
       return boost::make_indirect_iterator(v.end());

so, something like:

  class_ <std::vector <cNodeDescriptor *> > ("cNodeDescriptorList")
	  .def("__iter__", range(my_begin, my_end))


Dave Abrahams
Boost Consulting

More information about the Cplusplus-sig mailing list