Better way to determine length of a std::istream?
The "best" way is to avoid needing the length :)
- Not all streams are seekable (For example, imagine an istream on a network socket)
- The return type from tellg() is not necessarily numeric (the only requirement is that it can be passed back to seekg() to return to the same position)
- Even if it is numeric, it is not necessarily a number of bytes. For example, it could be a "magic" value meaning "at the end"
- For fstreams, issues like case and linefeed conversion can screw things up