One case of array assignments

monarch_dodra monarchdodra at gmail.com
Tue Mar 19 05:07:06 PDT 2013


On Tuesday, 19 March 2013 at 08:19:38 UTC, Timon Gehr wrote:
> On 03/19/2013 08:18 AM, monarch_dodra wrote:

>> That said, I investigated array, and just got it to work :) 
>> And it was
>> trivial, so I'll push it.
>
> Great.

Done:

https://github.com/D-Programming-Language/phobos/pull/1213

Now, this is legal code:

//--------
unittest
{
     //CTFE
     struct S
     {
         ubyte[5] a = repeat(cast(ubyte)1)[0 .. 5].array();
         ubyte[5] b = iota(cast(ubyte)0, cast(ubyte)5).array();
     }
     static assert(S.init.a[] == [1, 1, 1, 1, 1]);
     static assert(S.init.b[] == [0, 1, 2, 3, 4]);
}
//--------

Gnarly!


More information about the Digitalmars-d mailing list