Boost logo

Boost :

From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-08-08 15:00:23


Hi,

Eric Friedman's aligned_storage<int size,int align>, which I'm packaging up
with test and docs so it can be finally added, allows you to choose a
'maximum alignment' by passing 'align == -1'.

OTOH,

make_aligned_storage<T,Count,AlignStrategy>::type

is a type generator which instantiates the specific aligned_storage<>
required for aligned allocation of T[Count].

The last parameter AlignStrategy is either 'use_min_align' or
'use_max_align'.

If it is "use_min_align", aligned_storage<sizeof(T), alignment_of<T> > is
instantiated, which in turn uses the compile-time computation
'type_with_alignment< alignment_of<T> >'

If it is "use_max_align", aligned_storage<sizeof(T), -1> is instantiated,
which in turn uses 'detail::max_align' directly (from
type_traits/alignment_traits.hpp); without trying to find the best type with
same alignment.

The question is:

Is the last parameter really useful for 'make_aligned_storage<>'?
Why would I ever want to use 'maximum alignment' for a single, fixed type
'T'?

I seem to recall that Andrei's articles on the subject mentioned that
finding the correct alignment 'alias' for a given alignment is not *always*
possible, so, one may want to resort to a more wasteful, yet conservative,
maximum-alignment approach.
Is that so?

TIA,

Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk