newCTFE Status July 2017
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 22 11:18:39 PDT 2017
On Thursday, 13 July 2017 at 12:45:19 UTC, Stefan Koch wrote:
> [ ... ]
Hi Guys,
Due to improved ABI handling a subset of slices of complex
structs work now :)
The following code will correctly compile with newCTFE.
struct NA
{
string name;
uint age;
}
NA[] make5(string name)
{
NA[] result;
foreach(i; 1 .. 6)
{
string nameN = name ~ [cast(immutable char)('0' + (i %
10))];
result ~= [NA(nameN , i-1)];
}
return result;
}
static assert (make5("Tony") == [NA("Tony1", 0u), NA("Tony2",
1u), NA("Tony3", 2u), NA("Tony4", 3u), NA("Tony5", 4u)]);
As soon as the foreach-loop is iterated more then 1000 times you
will see a 7-10x speed improvement :)
More information about the Digitalmars-d
mailing list