且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++内存映射文件实现

更新时间:2022-06-27 01:05:53

您可以使用 placement new 运算符,或者您可以将地址转换为要使用的结构或类。放置new的优点是类的构造函数将被调用。如果你使用从那时指针,你不需要复制数据,但读写直接到它。

You can use the placement new operator or you can cast the address to a structure or class you want to use. The advantage of placement new is that the constructor of the class will be called. If you use from then on that pointer you don't need to copy the data but read and write directly to it.