templated static array
Simen Kjaeraas
simen.kjaras at gmail.com
Mon Oct 15 10:05:13 PDT 2012
On 2012-35-15 17:10, Namespace <rswhite4 at googlemail.com> wrote:
> But bar([1, 2, 3]); not. The compiler does not realize that [1, 2, 3]
> means a static array in this context.
> You have to write bar(cast(int[3]) [1, 2, 3]); but I think the compiler
> have to recognize this on it's own.
This is true. The problem is, as you say, that the compiler treats array
literals as dynamic rather than static arrays. I would argue this is the
correct default, but it's obviously not the default you want here.
bearophile has posted about this on numerous occasions, and it's among
his top thousand wanted features. :p
--
Simen
More information about the Digitalmars-d-learn
mailing list