Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2007-05-14 15:32:40


   The code here:


   would seem to fit best in boost's type_traits, in particular, with
   those templates described here:

   Is there any interest in adding the aligned_types code there?

Brief Description:

   The aligned_types template declaration is:

     template<class Tag, typename... Types> struct aligned_types;


     Tag is the "layout tag". Currently the only such tags are:


     Types is a sequence of types (much like the current variant and boost

   and where the resulting nested type:


   is simply an instance of aligned_storage with sufficient memory to
   accommodate Types... in a layout specificed by Tag. For example,
   with Tag==variant, the aligned_storage is the same as that for
   the aligned_union<0,Types...> of:

   The other tags are for regular structs(tag=tuple) and packed

   WARNING-Needs Variadic Template Compiler:

     The code uses Gregor's variadic template compiler:

     hence, it can't be used with any other compiler. However, I'd
     think it could be converted to use the preprocessor methods used
     by much of boost::mpl and boost::fusion to approximate Gregor's
     variadic templates.


   Reuse in boost::variant:

     Around line 215 of:

     there's make_storage whose nested type, is, AFAICT, the same as
     aligned_types<variant,Types...>::type. The one difference is that
     make_storage (from looking just at lines 233-235) calculates the
     alignment of the variant and the max of the individual
     alignements. However, as explained in:

     least-common-multiple instead of max is needed to handle extended

     Thus, aligned_types<variant,Types...> could be used in place of
     the current variant's make_storage.

   Space efficient tuple without preprocessor:

     By using aligned_types<tuple,Types...>::type as a storage buffer
     for a tuple, and using the mpl::at_c specializations in to access the subparts
     of this storage buffer corresponding to an element in Types..., a
     tuple implementation as space efficient as fusion's could be
     achieved without use of the boost preprocessor library.

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