Allocating byte aligned array
Igor
stojkovic.igor at gmail.com
Fri Sep 29 20:04:16 UTC 2017
On Wednesday, 27 September 2017 at 21:48:35 UTC, timvol wrote:
> On Wednesday, 27 September 2017 at 21:44:48 UTC, Ali Çehreli
> wrote:
>> On 09/27/2017 02:39 PM, timvol wrote:
>>> [...]
>>
>> void main() {
>> auto mem = new ubyte[1024+15];
>> auto ptr = cast(ubyte*)(cast(ulong)(mem.ptr + 15) &
>> ~0x0FUL);
>> auto arr = ptr[0..1024];
>> }
>>
>> Ali
>
> Works perfect. Thank you!
I know you can also use this with static arrays:
align(16) ubyte[1024] mem;
But I guess align directive doesn't work with dynamic arrays...
More information about the Digitalmars-d-learn
mailing list