|
Boost : |
Subject: Re: [boost] Another implementation of properties.
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2010-03-04 02:58:12
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk