Templates and SIMD - examining types
Cecil Ward
cecil at cecilward.com
Tue Jul 28 03:21:09 UTC 2020
On Wednesday, 22 July 2020 at 22:21:47 UTC, Dennis wrote:
> On Wednesday, 22 July 2020 at 21:58:16 UTC, Cecil Ward wrote:
>> I need to then work out what is the size of the internal units
>> within the 128-bit value, size in bytes,1 or 2, at compile
>> time.
>
> You can use the .sizeof property on the type.
>
> ```
> import core.simd;
> void main() {
> ubyte16 a;
> ushort8 b;
> pragma(msg, a.sizeof);
> pragma(msg, b.sizeof);
> pragma(msg, a[0].sizeof);
> pragma(msg, b[0].sizeof);
> pragma(msg, typeof(a[0]));
> pragma(msg, typeof(b[0]));
> }
> ```
>
> 16LU
> 16LU
> 1LU
> 2LU
> ubyte
> ushort
Brilliant. I am sooo stupid, I forgot you can access SIMD
variables like normal arrays. Thank you for waking me up again :-)
More information about the Digitalmars-d-learn
mailing list