当我从C ++(11)中读取文件时,我使用以下命令将它们映射到内存中:
boost::interprocess::file_mapping* fm = new file_mapping(path, boost::interprocess::read_only);
boost::interprocess::mapped_region* region = new mapped_region(*fm, boost::interprocess::read_only);
char* bytes = static_cast<char*>(region->get_address());
Run Code Online (Sandbox Code Playgroud)
当我希望非常快地逐字节读取时,这很好。但是,我创建了一个csv文件,该文件要映射到内存,读取每一行并在逗号上分割每一行。
是否可以通过对上面的代码进行一些修改来做到这一点?
(我正在映射到内存,因为我有很多内存,并且我不希望磁盘/ IO流出现任何瓶颈)。