Topic: offsetof


Author: Bill Seymour <wseymour@email.usps.gov>
Date: 1996/05/06
Raw View
Is it planned that the offsetof macro will exist in C++,
or do pointers to members replace it somehow?

Thanks,

--Bill
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: clamage@Eng.sun.com (Steve Clamage)
Date: 1996/05/06
Raw View
In article 6rr@blue.usps.gov, Bill Seymour <wseymour@email.usps.gov> writes:
>Is it planned that the offsetof macro will exist in C++,
>or do pointers to members replace it somehow?

The offsetof macro in C++ has defined behavior only if the struct argument
is a "POD" (a C-like struct). In other words, C code using offsetof will
continue to work, but don't use it on C++ classes. Pointer-to-member
is probably what you should be using instead of offsetof.

---
Steve Clamage, stephen.clamage@eng.sun.com




[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 1996/05/07
Raw View
Hi,
Bill Seymour (wseymour@email.usps.gov) wrote:
: Is it planned that the offsetof macro will exist in C++,
: or do pointers to members replace it somehow?

Although it becomes a little bit more trouble, pointers to members
replace it:  The more trouble is due to the fact that you need another
pointer to member type for each type you want to support. However, I
think on PODs the 'offsetof' macro can still be applied. This is e.g
essential when writing Widgets for the X Toolkit in C++.
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl/
I am a realistic optimist - that's why I appear to be slightly pessimistic
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]