On Tuesday, 23 February 2016 at 07:26:01 UTC, Ali Çehreli wrote:
On 02/22/2016 09:52 PM, Nicholas Wilson wrote:
How is this not a constant expression ?
auto ctodtypes =
[
     "void"      : "void",
     "uint32_t"  : "uint",
     "uint64_t"  : "ulong",
     "int32_t"   : "int",
     "int64_t"   : "long",
     "char"      : "char",
     "uint8_t"   : "ubyte",
     "size_t"    : "size_t",
     "float"     : "float"
];
dmd complains
source/emit/registryemitter.d(7): Error: non-constant expression ["void":"void", "uint32_t":"uint", "uint64_t":"ulong", "int32_t":"int", "int64_t":"long", "char":"char", "uint8_t":"ubyte", "size_t":"size_t",
"float":"float"]

Because it's mutable: :)

    ctodtypes["hello"] = "world";

What context are you using it in?

Ali

I've tried with both mutable and immutable a module scope. Scope I want is global (don't care about mutability)

Reply via email to