May 23, 2020
Is it possible to have a pointer to a nogc array?

Like for regular arrays you can just do .ptr

How would you do the same for a nogc array?

The reason is I need to read different types of values from a nogc byte array.

Ex. reading an int at offset 12 of the array.

With normal arrays it can be done like this:

auto i = (*(cast(int*)(arr.ptr + 12)));

--

Perhaps there is some function that can be used instead of using pointers to do this? I can't seem to find anything in phobos but it probably exist.

It must have as little overhead as possible though. Hence why I'm using pointers for the normal arrays.