Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-26 20:04:10

1. Got tests and docs?

2. Brian Parker invented the basic approach; he should get credit (I
refined it a bit)

3. Brian and I agree that this algorithm is suboptimal. He writes:


I suppose there is a tradeof here between having an over-aligned
result type vs an excessively large result type.

For example, on an architecture (or compiler packing option) in which
all types have an alignment of 1, the above algorithm will cause the
union to include all types and so will give an excessively large

I think that, in theory, a more efficient algorithm would be-

take the union of all types whose alignment is <= that of the target
AND whose alignment <= target alignment,
     if the alignment is not a multiple of the target alignment,
         take the union of all the types and cross fingers
 assert success.

----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, March 26, 2002 7:36 PM
Subject: [boost] [Type Traits] Patch for type_with_alignment

> The attached patch adds a new type trait that extracts a built-in or
POD type
> with a given alignment (and size). It's a copy-and-paste port of
> boost/python/converter/from_python_data.hpp into alignment_traits.hpp,
> the interface:
> template<int Align, int Size = Align>
> struct type_with_alignment {
> typedef /* some POD or built-in */ type;
> };
> Okay on GCC 2.95.3 and GCC 3.0.3; Comeau crashes because of
> incomplete member function pointer (workaround suggestions? - maybe
just a
> type with a few virtual base classes and a virtual function?).
> Doug

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