簡単なコード:
std::ifstream file("file.txt");
std::string line;
while(getline(file,line))
; //exhaust file
//in this sample code, for simplicity assert that the only possible "fail"
//is EOF (which it will always be under normal circumstances).
assert(!file.fail() || file.eof());
assert(file.peek() == EOF); //does this always hold?
最後のアサートは常に成功しますか?
質問の言い換え: EOF の後の場所も EOF を返しますか?
ドキュメントには、ストリームが ALREADY AT EOF のときに peek() が何をするかが明確に記載されていないため、私の質問です。