C ++ InputIterator is one of the most limited types of Iterator Concept. It is only guaranteed to support dereferencing, equality comparison, pre-increment and post-increment (and post-increment and dereference)
Since InputIterator objects InputIterator often repeated over an arbitrary stream, you cannot even be sure that iterating twice over the same input will give the same value.
I'm confused, however, if the dereferencing operator * guaranteed to return the same value every time you play it, provided that you never increase the iterator.
For example, if std::begin(some_input_stream) returns an object that meets the requirements of the InputIterator concept, and it not equal or is located beyond the end position:
auto it = std::begin(some_input_stream); auto value1 = *it; auto value2 = *it; assert(value1 == value2);
Is value1 guarantee of the same value as value2 ? (Providing, of course, that any type of *it provides implements the semantics of comparing semantic equality)
source share