static arrays at runtime with templates ?

Paul Backus snarwin at gmail.com
Sun Feb 3 16:36:30 UTC 2019


On Sunday, 3 February 2019 at 16:33:48 UTC, Emil wrote:
> I tried this on a whim and it appears to work:
>
> auto static_array(T, size_t data_size)()
> {
>     T[data_size] data;
>     return data;
> }

This is actually already in the standard library:

https://dlang.org/phobos/std_array.html#staticArray


More information about the Digitalmars-d-learn mailing list