offsetof; what's /really/ POD?

Mar 13, 2012 at 6:29pm
from http://www.cplusplus.com/reference/clibrary/cstddef/offsetof/ :

"...non-derived classes with only public non-virtual member functions and with no constructor and/or destructor would also qualify as POD..."

Then, why does this work?

http://codepad.org/1DpKs9aA
Mar 13, 2012 at 6:43pm
Have you ever done a sizeof operator of an object? This number should differ from c to c++. Offsetof is offset of where it starts. If I remember all constructors and destructors are only are there by default, however they are at the end class/struct. for example do offset(A, &foo); if I remember how to do that correctly. It is in the local scope of A so it should be far from the three variables.
Mar 13, 2012 at 6:47pm
In the C++11 standard it says that the class must be a standard-layout class, which it is, so it should work fine.
Mar 15, 2012 at 3:13pm
Azagaros, I don't think what you suggest is possible:

http://codepad.org/0Z8FiYss

http://codepad.org/A15ZfZJw

Peter87, thanks for your help. I wish (http://www.cplusplus.com/reference/clibrary/cstddef/offsetof/) said something similar.
Topic archived. No new replies allowed.