Subject: [ggl] pre-/post-increment op on iterators
From: Bruno Lalande (bruno.lalande)
Date: 2009-04-30 08:56:28
As long as the returned reference is const (which is indeed
preferable), wouldn't it be better to have the operator* returning a
temporary rather than a member? The C++ standard allows a const
reference to be initialized from a temporary and guaranties that the
temporary's lifetime will be the scope of the reference. So:
value_type operator*() const
s.first = *m_prev;
s.second = *m_it;
segment_iterator<my_iterator> i = some_iterator;
const segment& s = *i;
do_something_with(s.first); // OK, s is still alive.
This way we don't carry segments uselessly.
The problem is that I don't know is returning a value_type is
something allowed for an iterator's operator*.
Geometry list run by mateusz at loskot.net