> Nope. For input or output iterators you cannot even read the same place
twice. I might be wrong, but for forward or bidirectional iterators you
may copy the iterator and increment the copy to "take a peek".
That's bad news. The following code would be quite dangerous then:
template<typename Iterator>
Iterator operator+(Iterator const& input,size_t offset) {
Iterator output = input;
while(offset > 0) {
++output;
offset--;
}
return output;
}
I can't find a forward_iterator class to make the above function iterator
type-safe. What's wrong with these STL iterators?
Thanks