From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-08-07 09:58:17
----- Original Message -----
From: "Eric Friedman" <ebf_at_[hidden]>
To: "'Fernando Cacciola'" <fcacciola_at_[hidden]>; "'boost developers'"
Sent: Wednesday, August 07, 2002 1:01 AM
Subject: RE: [boost] Mini-review request: aligned_storage.hpp
> I'm not sure if the intent of your proposal is to "Keep It Simple,
> Stupid", but I have developed far more full-featured aligned-storage and
> incomplete-type facilities, which may be of interest to the Boost
> They are available in the sandbox:
> Note, however, the semantics for my boost::aligned_storage varies some
> from yours (to allow greater genericity of usage):
> boost::aligned_storage<size_t Size, size_t Alignment = -1>
> ...where an omitted Alignment (i.e. an Alignment of '-1') provides for
> maximally-aligned storage, leveraging boost::detail::max_align (which I
> think BTW should be promoted out of the detail namespace).
> [rest stripped]
I've carefully looked at your aligned_storage.hpp.
If I understood it correctly, it features these two things:
1) Provides a raw buffer which can allocate an object of type T with the
2) Provides a high-level adaptor interface based on placement new which
allows users to treat the aligned buffer as ordinary objects (through
AFAICT, (2) is built entirely upon (1), so I think that a factorization
might be more adequate.
That is, I think we should keep aligned_storage<> clean and simple, and
provide the adaptor as another, higher-level class built upon
As for the simple aligned_storage<>, I like the idea of being able to select
maximum or best alignment.
I'm not sure if the interface which takes two integers is good, though; It
does have potential for greater flexibility, but it is also significantly
more obscure for the user (IMHO).
In all the examples of this sort of utility that I've seen, 'size_' is
always 'sizeof(T)' and 'alignment_' is always
'boost::alignment_of<T>::value'; so, unless a concrete example pops up, I
prefer to parametrize aligned_storage in terms of T + Count (for arrays) + a
tag struct indicating minimum (default) or maximum alignment.
That is, instead of this interface:
template < std::size_t size_, std::size_t alignment_ = -1> class
struct use_min_alignment ;
struct use_max_alignment ;
template<class T, class align_choice = user_min_alignment, size_t count = 1>
class aligned_storage ;
P.S: I'm looking also at safe_assign()... but I'm not totally convinced.
Once I have boiled down all the details about it, I'll let you know so we
can discuss it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk