Boost logo

Geometry :

Subject: [ggl] pre-/post-increment op on iterators
From: Barend Gehrels (Barend.Gehrels)
Date: 2009-04-30 07:23:53

Hi Mateusz,

Mateusz Loskot wrote:
> Barend Gehrels wrote:
>> Mateusz Loskot wrote:
>>> I think it can be solved with a thin iterator adapter that
>>> dereferences to segment, instead of to point.
>>> The adapter, or a view as called in some situations, should do the job.
>> It will probably be something like that. However, it'll need a local
>> variable "segment" which is then dereferenced. What if the iterator goes
>> next? Is the local variable copied? Didn't do such a thing before.
> We definitely don't want to dereference by-value (make a copy of segment
> object) but by reference, so we need to cache segment object
> created/filled with coordinates read from the adapted vector..
> The cache is simply a member variable of adaptor iterator.
> Roughly drawing the idea, it could be something like this:
> struct segment; // our segment type
> template <typename Iterator>
> struct segment_iterator
> ...snipped... What you think about this idea?
Great! I didn't try it yet, did you?
I first implemented iterators like this but changed them using
Boost.Iterator adaptors. That avoids repeating increments and all the
usual stuff of iterators for each new iterator. It is probably possible
to use this as well, here.

Regards, Barend

-------------- next part --------------
An HTML attachment was scrubbed...

Geometry list run by mateusz at