How to make a global immutable associative array?

Rikki Cattermole alphaglosined at gmail.com
Tue Mar 18 23:05:23 PDT 2014


On Wednesday, 19 March 2014 at 04:10:21 UTC, Meta wrote:
> On Wednesday, 19 March 2014 at 01:56:35 UTC, Rikki Cattermole 
> wrote:
>> Is an enum not appropriate? Because it can be used to push 
>> constants and available at ctfe.
>>
>> enum int[int] aa = [1: 2, 3: 4];
>> pragma(msg, aa);
>
> This will create a new associative array at runtime wherever aa 
> is used, rather than creating only one instance at compile time 
> and referring to it wherever aa is used. This is also the case 
> with normal arrays, and possibly objects... I can't remember.

Okay, well I learnt something.


More information about the Digitalmars-d mailing list