-
ifstream::peek() cost
Just a quick question, would it be relatively expensive to call peek() for every byte read in, to check for an upcoming EOF()? Because I need to know a byte in advance. Or should I just find the file size and do a test to see if the number of bytes read has reached that number?
I'm asking because I'm writing a Huffman/other compression codec module for potential use in future programs, and not all bits in the last byte of the file may be used.
-
> would it be relatively expensive to call peek() for every byte read in,
That would depend on the quality of your implementation.
Read the file a block at a time into a buffer, then you'll know well in advance where the real EOF is before your code gets to it.
-