CTFE and assoc array

Andrey saasecondbox at yandex.ru
Sat Jan 18 20:54:20 UTC 2020


Hello,

Why this doesn't work?

> import std;
> 
> struct Qwezzz
> {
> 	shared static this()
>     {
>         qaz = qazMap;
>     }
> 
>     enum qazMap = ["rrr": "vv", "hty": "4ft6"];
>     static immutable string[string] qaz;
> }
> 
> void main()
> {
>     enum sorted = Qwezzz.qaz.keys.sort();
> }

The variable "qaz" is static immutable and doesn't work in CTFE.


More information about the Digitalmars-d-learn mailing list