Boost logo

Boost :

From: Bill Wade (bill.wade_at_[hidden])
Date: 2000-08-25 11:18:39

> From: Valentin Bonnard [mailto:Bonnard.V_at_[hidden]]

> Are the any real cases where offsetof doesn't work on non PODs (except
> with virtual bases of course) ?

It can easily be too pessimistic

struct foo
  __foo_vtable* __vptr; // Perhaps four bytes
  char c;
  T t;
  virtual void bar();

If the correct alignment for T is four bytes, offsetof(foo,t) is probably
eight. offsetof(foo,t)-offset(foo,c) gives the right answer in this case,
but if the alignment of T is eight bytes the subtraction becomes too

Boost list run by bdawes at, gregod at, cpdaniel at, john at