I'm quite sure it's already sorted out how closing the filestream closes the buffers. So, now, the buffers:
draft of Std'1998: 27.8.1.3.6: basic_filebuf* close();
6 Effects: If is_open() == false, returns a null pointer. If a put area exists, calls overflow(EOF) to flush characters. (...) Finally it closes the file (‘‘as if’’ by calling std::fclose(file)).308) If any of the calls to overflow or std::fclose fails then close fails.
Now, see the overflow()
: 27.8.1.4.8 (...)
I've then tried to trace it further, somewhere down there were some references to sync
and sputc
, but I was unable to trace the exact wording for how overflow
guarantees flushing. It surely does, but sorry, my time's up today :/