Boost logo

Boost Users :

Subject: Re: [Boost-users] [Iterators] How to implement proxy iterators?
From: Oswin Krause (Oswin.Krause_at_[hidden])
Date: 2012-02-24 14:15:39


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!

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

Greetings,
Oswin


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