Boost logo

Boost :

Subject: Re: [boost] interest in structure of arrays container?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2016-10-26 11:41:57


On 10/26/2016 10:17 AM, degski wrote:
> On 26 October 2016 at 18:00, Michael Marcin <mike.marcin_at_[hidden]> wrote:
>
>> But I don't know how to query the alignment of an object rather than a
>> type.
>>
>
> Shouldn't ( & object [ 0 ] ) % 16 == 0 do the trick?
>
Or use:
   boost::alignment::detail::is_aligned(&object[0], 16).
However, that code uses:

   boost::alignment::is_aligned
     ( std::size_t value
     , std::size_t alignment
     )
     {
        return (value & (alignment - 1)) == 0;
     }

which is more obscure than:

     return (value % alignment) == 0;

But I guess there's some reason for using the more obscure code.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk