AA of static array
    Derek Parnell 
    derek at psych.ward
       
    Fri Mar  7 05:39:21 PST 2008
    
    
  
DMD v2.012, Windows
I am trying to use an Associative Array whose data type is a static array
and key type is a string. The declaration and initialization of the array
compiles, but fails with an out of bounds error. If I wrap the static array
inside a struct, it works fine. Here is the code that fails...
void main()
{
   alias int[5] S;
   S[string] foo;
   
   foo["abc"]    = [1,2,3,4,5]; // out of bounds!
   foo["qwerty"] = [9,8,7,6,5];
}
And here is code that works but is kludgy...
void main()
{
   struct S
   {
       int[5] v;
   }
   S[string] x;
   
   x["abc"]   = S([1,2,3,4,5]);
   x["qwerty"]= S([9,8,7,6,5]);
}
Have I coded the first example incorrectly or is this a bug?
-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
    
    
More information about the Digitalmars-d-learn
mailing list