Boost logo

Boost :

Subject: [boost] [aligned storage] support for empty storage
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-04-20 16:41:45

Hi all,

Currently the following fails:

   typedef boost::aligned_storage< 0, 4u > storage;
   storage s;

because this will try to create an empty array.

Does anybody have anything against adding the following

template< std::size_t alignment_ >
struct aligned_storage_imp<0u,alignment_>
     /* intentionally empty */

Also, I would like to derive from aligned_storage_imp to get
the EBO:

template <
       std::size_t size_
     , std::size_t alignment_ = std::size_t(-1)
class aligned_storage : private
detail::aligned_storage::aligned_storage_imp<size_, alignment_>
{ ... }

The above changes enable the following program

   typedef boost::aligned_storage< 0, 4u > storage;

   struct simple : storage
     int i;

   #include <iostream>

   int main()
       std::cout << sizeof(storage) << " " << sizeof(simple);

to output "1 4" instead of "1 8" on gcc.

In case your are wondering, then I need this functionality in
boost::auto_buffer to get rid of the extra word when the stack-buffer
is empty (thus making auto_buffer as small as vector).



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