std::basic_filebuf<CharT,Traits>::close

If a put area exist (e.g. file was opened for writing), first calls overflow(Traits::eof()) to write all pending output to the file, including any unshift sequences.

# Declarations

std::basic_filebuf<CharT, Traits>* close();

# Return value

this on success, a null pointer on failure.

# Notes

close() is typically called through the destructor of std::basic_filebuf (which, in turn, is typically called by the destructor of std::basic_fstream.

# Example

This section is incompleteReason: no example

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 443C++98the file was written using overflow(EOF)changed to overflow(Traits::eof())
LWG 622C++98it was unclear how to handle theexception thrown during closingit is rethrown after closing the file

# See also