by UncleMeat · 3y ago · 0 comments
C++ does not really permit this. It is incredibly hard to do type punning from void* without hitting UB. You really are only allowed to access objects through their names according to their lifetimes.
Here (https://www.youtube.com/watch?v=IAdLwUXRUvg) is a fun talk that involves trying to do a pretty basic kind of arbitrary memory access and concluding that it is simply not possible in C++.
I'm sure with C++ it's more complicated, but not impossible. With Rust it gets really funny. You have to subscribe to a completely unrelated mental model to read some numbers from a tape.