Subject: Re: [boost] Interest in a "Heterogenous Container" system?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-08-04 12:30:39


Frank Mori Hess wrote:

> I wasn't following the thread too closely, but I assumed the benefit of using
> size+alignment instead of type would be that you could reuse the same
> allocator with different types (as long as they had the same size and
> alignment). But since a type's size+alignment varies across platforms, you
> wouldn't be able to portably reuse such an allocator with different types
> (hence no portable benefit).

The size + alignment wouldn't be part of the type of the allocator, it
would be part of the arguments it receives to perform a given
allocation. (i.e., like posix_memalign).
But strictly speaking, the language doesn't even require to take into
account arbitrary alignments, you can just align to anything big enough,
like malloc and operator new do.