user997112
user997112

Reputation: 30615

Iterate through boost mapped_region/memory-mapped file?

I have the following code which loads a file into a boost mapped_region:

file_mapping fm(FilePath, read_only);
mapped_region region(fm, read_only);
char * const data = static_cast<char *>(region.get_address());

Upvotes: 0

Views: 714

Answers (1)

ronag
ronag

Reputation: 51253

file_mapping fm(FilePath, read_only);
mapped_region region(fm, read_only);
char * const data = reinterpret_cast<char*>(region.get_address());

// Iterate through the data obtained, character (c) by character.
for(std::size_t n = 0; n < region.get_size(); ++n)
{
      char c = data[n];
}

Upvotes: 1

Related Questions