Because of popular request, here is the pastebin (as I do not want this anywhere near my github).
Added comments as well to save some headaches
edit: idk how it happened, but a logic bug slipped in. In dynamic_cast, offsetof(To, From) should be changed to offsetof(From, To). Additionally, I forgot to make it type-safe, which can easily be done by changing (char *)(DYNAMIC_CAST_ to (char *)(0 ? (From *) : DYNAMIC_CAST_
edit: I’ve decided to extend it a bit and put it on GitHub as well
View all comments
72
u/TheChief275 Nov 27 '25 edited Dec 01 '25 •
Because of popular request, here is the pastebin (as I do not want this anywhere near my github).
Added comments as well to save some headaches
edit: idk how it happened, but a logic bug slipped in. In dynamic_cast, offsetof(To, From) should be changed to offsetof(From, To). Additionally, I forgot to make it type-safe, which can easily be done by changing (char *)(DYNAMIC_CAST_ to (char *)(0 ? (From *) : DYNAMIC_CAST_
edit: I’ve decided to extend it a bit and put it on GitHub as well