In this section, the reader will learn how to map memory using C++ patterns. You will learn how to map memory (a common system-programming technique), while doing so using C++ patterns.
Learning about mapping and permissions
The basics
malloc()/free(), new()/delete(), and std::unique_ptr{}/std::shared_ptr{} are not the only methods for allocating memory on a POSIX system. C++-style allocators are another, more complicated, method for allocating memory that will be discussed in greater detail in Chapter 9, A Hands-On Approach to Allocators. A more direct, POSIX style for allocating memory is to use mmap():
#include <iostream>
#include <sys/mman.h>
constexpr auto PROT_RW = PROT_READ | PROT_WRITE;
constexpr auto MAP_ALLOC...