How does std::getline decides to skip last empty line?
问题 I noticed some strange behaviour when reading a file by line. If the file ends with \n (empty line), it may be skipped...but not always, and I don't see what makes it be skipped or not. I wrote this little function splitting a string into lines to reproduce the issue easily: std::vector<std::string> SplitLines( const std::string& inputStr ) { std::vector<std::string> lines; std::stringstream str; str << inputStr; std::string sContent; while ( std::getline( str, sContent ) ) { lines.push_back(