The natural way, if that's what you want to do, would be an iterator that emits lines *including* the final newline (or without it, for lines that have no terminator).
Your problem is that the line iterator drops the newlines, so that you don't see directly if any newlines were present to begin with. And to get that information back, you want it to return an empty lines at the end for the common case of files that are properly terminated.
I find that interface really strange and ugly. If a file contains ten lines, I'd expect a line_iterator to emit exactly ten lines, no more, no less.
/ Niels Möller ()
Previous text:
2002-12-31 00:04: Subject: stdin->line_iterator
It's still a DWIM that makes it impossible to iterate over a file and rebuild it (possibly with modifications) in the state it was to begin with.
/ Peter Bortas