Iterators that additionally satisfy the requirements of output iterators are called mutable iterators. Immutable iterators are called constant iterators. [24.2.1: 4]
This suggests that you can have a variable input iterator that satisfies the requirements of both input and output iterators.
After increasing the input iterator, copies of its old value should not be sought [24.2.3]. However, the standard does not say the same for output iterators; in fact, the operational semantics for postfix incrementation are given as { X tmp = r; ++r; return tmp; } { X tmp = r; ++r; return tmp; } { X tmp = r; ++r; return tmp; } , assuming that output iterators cannot invalidate (copies) of old iterator values.
So, can the increment of a volatile input-iterator invalidate old copies of the iterator?
If so, how would you support code like X a(r++); *a = t X a(r++); *a = t or X::reference p(*r++); p = t X::reference p(*r++); p = t with (for example) a proxy object?
If not, why does boost::iterator claim that it needs a proxy object? (Link is code, scroll down to read comments on struct writable_postfix_increment_proxy and postfix_increment_result ). That is, if you can return a (dereferenced) copy of the old iterator value, why do you need to wrap this copy in a proxy?
c ++ iterator
nknight
source share