Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-01-28 15:16:39

> > That shouldn't be hard if we wanted it. After all, we have
> > 'boost::alignment_of', Fernando Cacciola's "aligned_storage.hpp"
> > in the vault, I believe), and Andrei's paper -
> > - seems to provide a
> > solution as well.
> All solutions require knowing all of the types that storage must be
> with in advance. It works quite well for, e.g., a bounded variant class
> as those written by Brian Parker and Andrei Alexandrescu), but any
> variant (such as boost::any or boost::function) won't benefit because they
> don't haven't anything to align with.

My solution is not based on knowing the types in advance. It just uses that
information to optimize the storage size. The TypesOfAllAlignments type in
the paper can be arguably quite a portable storage for any type. The code is
not 100% portable, but in practice it's hard to imagine a system that's as
perverse as to break its assumptions.

Just a quick remark, I just can't hold it - aligned_storage.hpp in the files
section defines and uses a little typelist and int2type, type2type, and
select (some with changed names). A good argument for making them
first-class citizens of the library...


Check out THE C++ Seminar: 3 Days with 5 Experts

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