开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜