4 ms·
I guess there could be some fun workarounds with ptrdiff_t instead of pointers. "My child is 1000 bytes that way in memory" etc.
by repsilat 8y ago
I guess there could be some fun workarounds with ptrdiff_t instead of pointers. "My child is 1000 bytes that way in memory" etc.
- a_t48 8y agoThat's a pretty classical file serialization trick to pack a bunch of heterogeneous data in one file. A header/manifest starting the file, with an array of names, offsets, and sizes.
- blattimwind 8y agoActually works somewhat well for mmap'ed access, too, by using a macro or function to "dereference" "pointers" (offsets).
- a_t48 8y agoOr even an OffsetPtr class with overloaded arrow and dereference operator, if you swing that way. :)
- DaiPlusPlus 7y agoWhat’s the runtime performance of that in-practice? Does x86, x64 and ARM have support for relative offset pointers without any performance impact? And do compilers use them?
- blattimwind 7y agoYes, address generation can at the very least do [reg + constant], and on x86, much much more. These are bread and butter optimizations constantly used by compilers all over the place, because this is how field access works.