Iterators that further satisfy the requirements of output iterators are called mutable iterators. Nonmutable iterators are referred to as constant iterators. [24.2.1:4]
This suggests you could have a mutable input iterator, which meets the requirements of both input and output iterators.
After incrementing an input iterator, copies of its old value need not be dereferenceable [24.2.3]. However, the standard does not say the same for output iterators; in fact, the operational semantics for postfix increment are given as { X tmp = r; ++r; return tmp; }
, suggesting that output iterators may not invalidate (copies of) old iterator values.
So, can incrementing a mutable input iterator invalidate old iterator copies?
If so, how would you support code like X a(r++); *a = t
or X::reference p(*r++); p = t
with (e.g.) a proxy object?
If not, then why does boost::iterator
claim it needs a proxy object? (Link is code; scroll down to read the comments on struct
s writable_postfix_increment_proxy
and postfix_increment_result
). That is, if you can return a (dereferenceable) copy of the old iterator value, why would you need to wrap this copy in a proxy?