Boost logo

Boost :

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

On Thu, Feb 20, 2014 at 12:52 PM, Andrey Semashev
<andrey.semashev_at_[hidden]> wrote:
> On Thu, Feb 20, 2014 at 12:27 PM, Glen Fernandes
> <glen.fernandes_at_[hidden]> wrote:
>> Source:
>> Documentation:
>> Motivation: Tiny library to be used for all common alignment related
>> chores found in a few Boost libraries. (e.g. we have some in
>> Boost.Smart_Ptr).
>> Provides:
>> 1. Function boost::align, a pointer alignment function, for
>> implementations that do not yet provide std::align. (Uses std::align
>> if available)
>> 2. Functions boost::aligned_alloc and boost::aligned_free, for aligned
>> allocation and deallocation. (Use platform specific functions, such
>> _aligned_malloc or posix_memalign, or otherwise uses std::malloc with
>> the above boost::align)
>> 3. Class template boost::aligned_allocator as a replacement for
>> std::allocator that respects over-aligned types. (Up to the extent the
>> implementation supports over-alignment)
>> Many thanks to Peter Dimov for his feedback on the design and
>> implementation of this library.
>> Notes: Small enough that it might satisfy the requirements for a
>> fast-track review.
> First, nice to see this submission, I've been missing and
> reimplementing this functionality from time to time.
> Second, you may see this:
> to improve portability of aligned_alloc. As you can see,
> posix_memalign is not always available, even if advertised by POSIX
> macros. Note also that posix_memalign imposes specific requirements on
> the alignment that are not described in your docs. And
> _aligned_malloc/_aligned_free are available on compilers other than

One other note. I can see that aligned_allocator does not allow to
specify the alignment. I assume it uses the type T alignment?

Can this class be extended so that I can specify the alignment
explicitly in the template parameters? This would be very useful for
cases when the elements of type T must have stronger alignment, for
example, when element processing needs to be vectorized.

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