|
Boost Users : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2004-12-05 10:04:37
David Abrahams wrote:
> It's intentional. When your iterator's reference type is not
> value_type& or value_type const&, your reference type is the same as the
> value_type or you are using a proxy reference. Either way, if your
> iterator is readable, the reference is implicitly convertible to
> value_type. If your iterator is writable, it can be assigned from the
> value_type. No persistent object (lvalue) of type value_type is
> revealed by dereferencing the iterator; you can at best see a temporary.
> If iterator_facde handed you a pointer to non-const value_type, it
> would allow you to modify this temporary, which would then disappear.
> We don't do that for the same reasons the language won't bind a
> non-const reference to a temporary.
I see - thanks for your detailed reply.
When using proxy classes as references the assumption that modifications
of a temporary object are lost at the end of this very object's lifetime
does not apply - modification of the proxy object actually means
changing the stored data internally referenced by it.
In this case it would be OK if not preferable to have operator-> return
a pointer to non-const...
Is there any way to achieve this (besides hand-coding the whole iterator) ?
Or any hope that there will be a parameter to explicitly disable this
extra-safety ?
And why does operator* give me a mutable (temporary) object then, by the
way ?
-- Tobias
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