On Friday, 13 January 2023 at 19:16:17 UTC, H. S. Teoh wrote:
On Fri, Jan 13, 2023 at 08:31:17AM -0800, Ali Çehreli via
Digitalmars-d-learn wrote:
On 1/13/23 07:07, Gavin Ray wrote:
> This is "valid" D I hope?
Yes because static arrays are just elements side-by-side in
memory. You can cast any piece of memory to a static array
provided the length and alignment are correct.
[...]
Or to be more precise, cast the memory to a *pointer* to a
static array of the right size. Static arrays are by-value
types; passing around the raw array will cause the array to be
copied every time, which is probably not what is intended.
T
Thanks Teoh and Ali, I wound up passing a pointer to a static
array.
If anyone is curious, here's the full WIP implementation -- it's
for a toy database (Postgres-like) I'm writing for a hobby and
learning project:
https://ldc.godbolt.org/z/Kvh7dv96c