inferred size for static array initialization

Erik Smith via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 2 06:00:27 PDT 2016


Is there a way to initialize a static array and have it's size 
inferred (and that works for arrays of structs using braced 
literals)?  This would make it easier to maintain longer static 
array definitions.  The code below doesn't work when removing the 
array size even though the array is declared as static immutable.

     import std.traits;
     static immutable int[] a  = [1,2,3];
     static assert(isStaticArray!(typeof(a)));  // fails



More information about the Digitalmars-d-learn mailing list