What is the better signature for this?
Kagamin
spam at here.lot
Tue Oct 11 12:51:13 UTC 2022
On Monday, 10 October 2022 at 12:44:18 UTC, Guillaume Piolat
wrote:
> That is solution C.
> It could work.
Static array works like this:
```
int Load4LE(in ref ubyte[4] b) pure
{
return (b[3]<<24)|(b[2]<<16)|(b[1]<<8)|b[0];
}
ubyte[] data;
int val=Load4LE(data[0..4]);
```
It's safe, bound checked, ctfeable, no casts.
> The slight problem is that function that takes __m128i* use
> that as "any packed integer taking 128-bit" space, and it's not
> immediately obvious that __m128i is int4 and __m256i is long4,
> it's rather counterintuitive. Smenatically, it could be short8
> or byte16...
There's no solution, only tradeoffs.
More information about the Digitalmars-d
mailing list