Boost logo

Boost Users :

Subject: Re: [Boost-users] [Iterators] How to implement proxy iterators?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-02-24 14:21:32


On Fri, Feb 24, 2012 at 11:15 AM, Oswin Krause <
Oswin.Krause_at_[hidden]> wrote:

> Hi,
>
> Thanks for the reply!
>
> >
> >
> http://www.boost.org/doc/libs/1_48_0/libs/iterator/doc/ReadableIterator.html
> >
> > which states that, for a ReadableIterator i, *i must have a type
> > convertible to the iterator's value_type. Further, for iterator_facade,
> > the
> > type of *i is the iterator's reference type. Therefore, reference must be
> > convertible to value_type.
> >
> > Proxy references are perfectly fine, you just have to ensure they
> > interoperate well with (i.e., are convertible to) the iterator's
> > value_type.
> This sounds good.
>
> So when I exchange my MatrixRow as reference type with
>
> struct MatrixRowProxy:public MatrixRow //lazyness for the example :)
> {
> operator Vector(){
> return Vector(*this);
> }
> }
>
> and keep everything else untouched, like this:
>
> struct MatrixIterator:
> public boost::iterator_facade<
> MatrixIterator,
> Vector,
> boost::random_access_traversal_tag,
> MatrixRowProxy
> >{
> //as before
> };
>
> Everything works? That would be really nice!
>

Well, the only way to be sure is to try it :)

In this case I am happy and thank you very much for the hint to the
> Definition :). This helped me a lot.
>

Great. Hopefully everything works out. Let us know if it doesn't.

- Jeff



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net