Is there a way to get the current line without advancing the position in the file?
I have an iterator for files that only calls getline()
when operator*()
is called to avoid needless copying of lines into strings. The iterator simply moves the position with file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
every time operator++
is called, however, this causes a line to be skipped when calling operator*
, as that uses getline()
. Therefore I would like to somehow get the current line but not advance the reading position. Is there a built in function that does this?