Are boost mapped files RAII?
From what I can tell from documentation they aren't, on the other hand RAII is the one of the features of modern cpp.
http://www.boost.org/doc/libs/1_47_0/libs/iostreams/doc/classes/mapped_file.html
EDIT: It turns out that the answer is yes, but 开发者_运维百科please please dont forget to use .is_open().
Looking at the implementation, the mapped_source/mapped_sink both contain a shared pointer to the underlying mapped_file_impl (See here for the mapped_file_impl source)
As you can see, once the last reference is destroyed, it calls the destructor which detaches from the mapped file. However, it does not destroy the mapped file, no more than destroying an ofstream
deletes the underlying file.
精彩评论