« first day (14 days earlier)    last day (15 days later) » 

3:05 PM
@geza: "Here, at i!=input.end(), iterator must read from input" Streams can already tell when they're at the end of file or not. You would simply use that mechanism to determine whether an iterator is at the end.
So there is no need to store anything which is not already stored by the stream referenced by the iterator.
Also, I've come to realize that I was wrong earlier; making iterators store a value is actually better than returning it. Why? Because of memory allocations.
Consider an InputIterator whose value_type is a string, like your line iterator. Each iteration will store a new value in that string, but it will always be reusing the same object. This means that it can reuse the same allocated string buffer.
By contrast, if you're returning the string as a prvalue, then every iteration allocates memory, returns the string, and deallocates it.
So having to store that value is an advantage, not a detriment. And if your interface is given a value to copy into rather than one that is returned, then you're losing nothing by having the iterator store the value. You still have to have something store the value. Why not make it the iterator?
 

« first day (14 days earlier)    last day (15 days later) »