3 ms·
Indeed, this. If you have data with pointers, you either need to flatten (read: copy) your structure into something appropriate for structuring, or just get a p
by a_t48 8y ago
Indeed, this. If you have data with pointers, you either need to flatten (read: copy) your structure into something appropriate for structuring, or just get a proper serialization layer.
- repsilat 8y agoI 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 8y 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 8y 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.