Templates and SIMD - examining types

Dennis dkorpel at gmail.com
Wed Jul 22 22:21:47 UTC 2020


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


More information about the Digitalmars-d-learn mailing list