boost文件内存映射的使用方法
boost_mapping_file.cpp
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>
using namespace boost::interprocess;
int main()
{
char file_name[64] = {0};
int count = 1;
int file_size = 1024 * 1024 * 1024 * 1; // GB
for(int i=0; i<count; ++i)
{
sprintf(file_name, "./files/f_%d", i);
boost::interprocess::file_handle_t _handle = ipcdetail::create_or_open_file(file_name, read_write, permissions(),false);
boost::interprocess::ipcdetail::truncate_file(_handle, file_size);
boost::interprocess::ipcdetail::close_file(_handle);
file_mapping *mf = new file_mapping(file_name, read_write);
mapped_region *region = new mapped_region(*mf, read_write);
void *addr = region->get_address();
std::cout << addr << std: