Setting a hard limit on slice size, is this possible?
Tejas
notrealemail at gmail.com
Sat Aug 7 14:34:49 UTC 2021
On Saturday, 7 August 2021 at 13:36:52 UTC, james.p.leblanc wrote:
> On Saturday, 7 August 2021 at 12:08:00 UTC, Paul Backus wrote:
>> [...]
>
> **First, thanks all for helping with this question!**
>
> The simple desire to arbitrarily align an array is certainly
> looking non-trivial.
> Below is a simple program of both the suggested "struct" and
> "align array" solutions.
> Unfortunately, neither is guaranteed to place the array with
> the desired alignnment.
>
> [...]
Umm, the ```align array``` solution is flat out wrong, please
ignore it. Most likely a bug in the compiler.
Also, why will the address of the first element of the array
```modulo``` alignment be 0? The address of the array has
absolutely nothing to do with the alignment.
You say that the ```align array``` solution has the expected
spacing, but it is default aligned, totally ignoring your 64
byte requirement.
Don't use ```x.PTR%ALIGNMENT```
Use ```(&x[1]-&[2])%ALIGNMENT```
You will get ALIGNMENT*(2 -1)(since you took difference of 2nd
and 1st elem)
More information about the Digitalmars-d-learn
mailing list