std::ifstream file;
file.open("filename");
std::getline(file, str);
std::cout << "Size of last get op: " << file.gcount() << std::endl;
This invariably gives '0' whether the read line was empty or not which might be understood considering std::getline() is NOT a member of the istream-class. However the doc for istream::gcount() states
[...] Returns the number of characters extracted by the last unformatted input operation performed on the object. [...]
Whereas the std::getline() doc states:
istream& getline ( istream& is, string& str, char delim );
[...]
Parameters:
is istream object on which the extraction operation is performed.[...]
Putting these two together I thought gcount() should also work for the global function std::getline().
* Is this standard behavior or just a quirk of my compiler?
* If it is standard, please help me to recognize this as consistent behavior.
* And lastly, if this is standard, please explicitly state in the docs of
std::getline() and istream::gcount() that they won't work together