tags:

views:

53

answers:

1

I'm wondering if I need an RAII wrapper around std::fstream....

+6  A: 

No you don't. It closes the file. § 27.8.1.2:

virtual ˜basic_filebuf();  

Effects: Destroys an object of class basic_filebuf. Calls close().

(which is contained as an object within std::fstream (§ 27.8.1.11), thus being destructed when the fstream is destructed).

Johannes Schaub - litb