On Tuesday, 10 October 2017 at 14:15:07 UTC, Simon Bürger wrote:
On Tuesday, 10 October 2017 at 13:48:16 UTC, Andrea Fontana wrote:
Maybe:

double[n] bar = 0.repeat(n).array;

This works fine, thanks a lot. I would have expected `.array` to return a dynamic array. But apparently the compiler is smart enough to know the length. Even the multi-dimensional case works fine:

double[n][n] bar = 0.repeat(n).array.repeat(n).array;

I hope this is not performance-critical code. The assembly is terrible for such code, at least for LDC, doing a GC allocation, unrolled reset to zero, then memcpying the dynamic array back to the stack: https://godbolt.org/g/uXBN75

`double[n] bar = void; bar[] = 0;` (2 lines, granted) results in a memset.

Reply via email to