Boost logo

Geometry :

Subject: [ggl] pre-/post-increment op on iterators
From: Bruno Lalande (bruno.lalande)
Date: 2009-04-30 12:26:50

> 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.

> 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.


Geometry list run by mateusz at