Boost logo

Geometry :

Subject: [ggl] pre-/post-increment op on iterators
From: Mateusz Loskot (mateusz)
Date: 2009-04-30 19:27:36

Bruno Lalande wrote:
>> Iterators of input category may dereference returning element by-value.
>> However, it's unclear what to return from operator-> , pointer to temporary?
>> It looks like we would need to return such pointer
>> wrapped somehow and preserving pointer semantic.
> Yes indeed, I hadn't thought about the operator->. Looks like the
> issue can't be solved without an ugly workaround...
>> Another issue is that returning by value causes number of allocations.
>> Each dereference of iterator/adapter = construction of new segment object.
>> But with cache, we just fill existing object.
> This would need to be tested precisely, it's always difficult to know
> until which point a compiler can optimize, inline or remove
> unnecessary code.

Yes, I agree.
No assumption is certain unless it's tested and measured.

>> For input iterators, it is, but it has drawbacks and problems as
>> mentioned above.
>> To summary, we've two options. Let's discuss which one to use.
> The advantages of my proposition are too uncertain compared to the big
> drawback you mentioned, so I'd eventually stick to your solution.

OK. I will work on it tomorrow.

Best regards,

Mateusz Loskot,
Charter Member of OSGeo,

Geometry list run by mateusz at