
4 Mar
2010
4 Mar
'10
7:58 a.m.
El 03/03/2010 06:15 p.m., vicente.botet escribió:
Why offsetof is a C++ standard macro that should work in any case.
if f is a field of a type T reinterpret_cast<T*>(reinterpret_cast<char*>(this)-offsetof(T,f)))
should point to the T instance, isn't it? Someone tolds that this works only for POD. Could you clarify?
[18.2.4] "The macro offsetof(type, member-designator) accepts a restricted set of type arguments in this International Standard. If type is not a standard-layout class (Clause 9), the results are undefined. (...)" Agustín K-ballo Bergé.- http://talesofcpp.blogspot.com