|
Boost : |
From: brianjparker_at_[hidden]
Date: 2001-10-20 19:17:03
--- In boost_at_y..., John Maddock <John_Maddock_at_c...> wrote:
>
> >alignment_traits class which is used to align stack-based or
static
> >memory
>
> See alignment_of in the type traits lib
>
>
> - John Maddock
> http://ourworld.compuserve.com/homepages/john_maddock/
Hi,
Yes, I am aware of alignment_of.
The problem is that just knowing the required alignment is not useful
without also having some form of standardised #pragma pack to
actually effect the alignment requirements.
By contrast, alignment_traits<T>::align_t, being a POD, is directly
useable in a union to effect the alignment.
For example, in the valunion class I use the following construct to
align the embedded buffer
union {
typename alignment_traits<A>::align_t al1;
typename alignment_traits<B>::align_t al2;
typename alignment_traits<C>::align_t al3;
char buffer[size_max];
};
I don't see how this buffer could be aligned with
alignment_of<T>::value alone.
I do think though that a good place to add the functionality of
aligment_traits<T>::align_t to Boost is in boost::alignment_of i.e.
boost::alignment_of could have an additional member align_t and
alignment_traits would then be hidden in a detail namespace.
,Brian Parker
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk