Question

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().

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top