Boost logo

Boost :

Subject: Re: [boost] interest in structure of arrays container?
From: degski (degski_at_[hidden])
Date: 2016-10-27 01:51:01


On 26 October 2016 at 21:33, Chris Glover <c.d.glover_at_[hidden]> wrote:

> In this case, FWIW, on MSVC2015, the bit-twiddling
> version generates faster code than the mod version -- about 25% faster. I
> didn't test gcc or clang.
>

How often are you going to check this? I would do this only in debug.

On 27 October 2016 at 06:58, Michael Marcin <mike.marcin_at_[hidden]> wrote:

> There's quite a large difference between "this object happens to land on a
> 16 byte alignment" and "what is the alignment of this object?" or even "is
> this object alignas(16)".

Yes, resorting to some bit-fiddling then:

size_t whatIsTheAlignmentOfThisPointer ( const void* p_ ) {

    return ( size_t ) ( ( uintptr_t ) p_ & ( uintptr_t ) -( ( intptr_t ) p_
) );
}

Yes, it assumes twos-complement, and yes it will therefore possibly fail
[running it] on your average IoT-water-cooker.

degski


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