I'm reading the C++ standard but I can't figure this out. I am looking at code in some of our source files from many years ago:
streampos pos = inputfile.tellg();
if(pos < 0)
// an error
or
streampos pos = outputfile.tellp();
if(pos < 0)
// an error
I have 2 questions. The first is whether or not that code is ok and why, and the second does any C++ standard imply whether streampos is always signed or unsigned? I can't find where in the C++ 03 standard it says that. inputfile/outputfile are ifstream/ofstream. The closest thing I can find is not in the standard but cplusplus.com which says "Objects of this class support construction and conversion from int". Does that mean this comparison is fine?