Ways to initialize static arrays

Philippe Sigaud philippe.sigaud at gmail.com
Thu Aug 26 15:24:12 PDT 2010


On Thu, Aug 26, 2010 at 23:49, Stanislav Blinov
<stanislav.blinov at gmail.com>wrote:

> struct S(T,size_t N)
> {
>        T[N] arr;
>        int foo;        // type doesn't seem to matter here,
>                        // taking int for clarity
>
>        static immutable S C1   =   { initializeWith!(T,N)(0) 5 };
>        // Note there is no comma after first initializer    ^
> }
>
> This actually compiles and works, though I have an impression that syntax
> error is in order. Putting in second array and attempting similar
> initialization without commas leads to one. I've only tried it with Windows
> 2.048, though I think the front end would eat this on Linux too. Is this
> valid, already known or I should report this?
>

Dunno, I never use the = { ... } syntax to create structs. I always do =
S(...);
I even thought the literal syntax was being deprecated. Maybe I'm mistaken.

In any case, please report this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100827/5527f9e2/attachment.html>


More information about the Digitalmars-d-learn mailing list