Boost logo

Boost :

Subject: Re: [boost] Review request for Boost.Align
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-02-20 10:24:29

On Thu, Feb 20, 2014 at 7:07 PM, Peter Dimov <lists_at_[hidden]> wrote:
> Andrey Semashev wrote:
>> this will likely not work because std::list won't use
>> my_alignment_of<__m128 > but instead some my_alignment_of< list_node< __m128
>> > >. To make this work you'd have to write some fake metafunction that just
>> always returns 64, and this is equivalent to just specifying 64 in
>> aligned_allocator template parameters, only more complicated.
> Specifying 64 is not going to work for list<> containers. That was my point.
> template< class T > struct __list_node { void* next_; T t_; }
> If you align the __list_node at 64, the t_ member is not going to be aligned
> at 64.
> aligned_allocator<T, 64> is going to work for vector<> though, and this is
> often precisely what's needed. So I think that your suggestion of specifying
> a minimal alignment, with the actual alignment being determined as LCM(
> min_align, alignof(T) ) is useful, as long as people realize that it's
> tailored to vector<> and is not generally suitable.

You're right, I forgot about the node layout. I guess, the only way to
make sure it works in all cases is to use both the element type with
the required alignment and aligned_allocator.

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