Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2003-02-23 14:03:06

At 03:34 AM 2/23/2003, Thomas Witt wrote:

>I can not figure out how you make sure to satisfy the alignment constraints of
>T and counted_base_header_impl. Any hint would be appreciated.

I just used two char arrays, thinking there was a dispensation
somewhere in the standard to allow for placement new into char

   template<typename T> struct object_with_counted_header {
      char header[sizeof(counted_base_header_impl<T*,checked_deleter<T> >)];
      char object[sizeof(T)];

If I'm wrong, an alternative might be:

   template<typename T> struct object_with_counted_header {
      counted_base_header_impl<T*,checked_deleter<T> > header;
      T object;

But then you can't use offsetof, and some fancier tricks will
be in order.

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