[C++-sig] Re: custom iterator object
Mike Rovner
mike at bindkey.com
Thu Nov 7 21:03:42 CET 2002
> > I have the following class, implementing my iterator protocol:
> >
> > template<class T>
> > class Iter
> > {
> > T* First();
> > T* Next();
> > }
> > returning 0, when iteration is done.
> >
> Boost.Python provides several ways to wrap regular C++ iterators as
> Python iterators. Did you consider using those?
Sure I did, but couldn't figure out how to do it ;)
IMHO it's NOT a regular iterator because operations '*' and '++' are
combined into 'Next'.
> > I'm trying to wrap it to Python iterator protocol:
> What's "not good" about it?
I have problems with return value. In __iter__ I have to return self, but
there is no Python self yet in wrapping class.
So probably I have to duplicate part of the BPL iterator guts, but I got
lost :(
Mike
More information about the Cplusplus-sig
mailing list