On Sunday, 16 February 2020 at 12:57:43 UTC, AlphaPurned wrote:
template AA(string[] S)
{
        auto _do() { int[string] d; foreach(s; S) d[s] = 0; return d; }
        enum AA = _do;
}


My best guess is that enum arrays(except strings) and AA's are instantiated every time you access them.
This is especially bad with loops.

Probably you want static or module level variable instead.
Module level AA's can't have compile time initializer, however you can do initialization with module constructor instead.
https://dlang.org/spec/module.html#staticorder

Reply via email to