On Wednesday, 20 March 2019 at 08:11:27 UTC, boolangery wrote:
Got it ! Thank you, so I need to write:

enum string[string] CtfeFoo = ["foo" : "bar"];
static immutable string[string] Foo;

static this()
{
    Foo = CtfeFoo;
}

string ctfeableFunction()
{
    if (__ctfe)
        return CtfeFoo["foo"];
    else
        return Foo["foo"];
}

void main()
{
    enum a = ctfeableFunction();
    auto b = ctfeableFunction();
}

Yes, that looks correct to me.

Reply via email to