Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-06-13 14:28:07


Gottlob Frege wrote:
>> I'd like type_with_alignment<> to handle sizes between 'true'
>> alignments, and/or have a way to map 'in bwetween' alignments to
>> their lower alignment.
>>
>> ie I have a struct of unknown type, but known size = 5. What is it's
>> alignment? You could 'punt' and say max_align, but I suggest that
>> its alignment is <= 5 (ie probably 4 for a typical platform). ie
>> imagine that the struct might have an int as it's first member, but
>> can't have a double (assuming sizeof(double) > 5), so the alignment
>> might need to be alignment_of<int>, but can't be
>> alignment_of<double>. Does this assumption hold true?
>>
>> So how can I map (at compile time) an integer 'n' to the closest 'x'
>> <= n where x is from the set S, and where S is the set of possible
>> alignments?

What's wrong with:

boost::alignment_of<unknown_struct>::value ?

You can feed the result into type_with_alignment<> if that's what you want
as well.

John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net