3 ms·
It's a bit horrible and unsafe, but you can use offsetof and some nasty pointer casting to get from a member of a class back to the class. I've done this, and i
by CJefferson 11y ago
It's a bit horrible and unsafe, but you can use offsetof and some nasty pointer casting to get from a member of a class back to the class. I've done this, and it compiles to extremely efficient code. You can even template a class on the value of offsetof, so you can use the same class as multiple members.
I'm on my phone, so no code examples (sorry). If you want one, reply and I'll write one when I get to a computer!