static arrays at runtime with templates ?

H. S. Teoh hsteoh at
Mon Feb 4 19:22:00 UTC 2019

On Mon, Feb 04, 2019 at 07:14:38PM +0000, Emil via Digitalmars-d-learn wrote:
> Can std.array.staticArray build static arrays with size known only at
> run time ? Now that I am not overcome with enthousiasm it looks like
> it too needs to know the size.

That's not possible, because the size of a static array is part of its
type, meaning it must be known at compile-time.

Perhaps what you're looking for is alloca (and possibly a slice over


In a world without fences, who needs Windows and Gates? -- Christian Surchi

More information about the Digitalmars-d-learn mailing list