Member variable offset

Hello,
For example, in this class:
1
2
3
4
5
class A
{
int a;
int b;
};


Is there any standard way to know the memory offset in bytes between member b of class A and the start of class A(like reinterpret_cast<char*>(this) - reinterpret_cast<char*>(&this->b) but without necessarily instanciate an object A)?
The compiler know it so i see no reason we have to instanciate an object to know it.
Last edited on
The offsetof() macro in <cstddef>
Thank you JLBorges
Topic archived. No new replies allowed.