Date: Thu, 26 May 2022 13:32:15 +0200
On 2022-05-26 at 11:46, Andy Wang via Std-Discussion wrote:
> > there is no "array of int16_t" object at x
>
> I replied to language.lawyer earlier bit forgot to reply all so it's not
> on the list - is there no proper way at all in C++ to read/get a
> reference to the top 16 bit of a int32_t?
>
You can get the value (the bits) out by copying them to an int16_t.
Using memcpy, for example. The compiler is likely to optimize the formal
copying away, and just load a value from memory.
You cannot get a reference to the "int16_t part" of the int32_t, because
there isn't one. An int32_t just isn't composed of two int16_t's.
> > there is no "array of int16_t" object at x
>
> I replied to language.lawyer earlier bit forgot to reply all so it's not
> on the list - is there no proper way at all in C++ to read/get a
> reference to the top 16 bit of a int32_t?
>
You can get the value (the bits) out by copying them to an int16_t.
Using memcpy, for example. The compiler is likely to optimize the formal
copying away, and just load a value from memory.
You cannot get a reference to the "int16_t part" of the int32_t, because
there isn't one. An int32_t just isn't composed of two int16_t's.
Received on 2022-05-26 11:32:47