On 13/08/2018 11:38 PM, Andrey wrote:
Hello,
I need to declare a static compile-time assoc array inside struct:
     struct Test
     {
         enum Type : ubyte
         {
             One,
             Two,
             Three
         }

        static immutable string[Type] DESCRIPTION = [Type.One: "One!", Type.Two: "It's Two...", Type.Three: "And... Three!"];
     }

I have an error: "non-constant expression". What should I do?

I want to declare it and init at compile-time (to reduce run-time overhead). After that it will be used in run-time expressions and in compile-time expressions.

Regards, Andrey.

Unsupported. AA's don't go between CT and RT. You must use a module constructor to initialize it.

Reply via email to