C++ has a neat feature where you can create an object at a specific memory address as shown here.
This is particularly useful with mmap
like so:
void *ptr = mmap(0, length, prot, flags, fd, offset);
A *ptrA = new (ptr) A;
What is the correct way to replicate this with just C-style structs? Would it just be this?
void *ptr = mmap(0, sizeof(A), prot, flags, fd, offset);
A *ptrA = (A*) ptr;