Static Initialization of AAs - when?

arandomonlooker shdkahdkhhhhhii at gmail.com
Sun May 29 20:58:42 UTC 2022


On Sunday, 29 May 2022 at 15:34:09 UTC, Steven Schveighoffer 
wrote:
> On 5/28/22 8:36 PM, arandomonlooker wrote:
>> [...]
>
> You can do this with my [newaa 
> project](https://code.dlang.org/packages/newaa):
>
> ```d
> import schlib.newaa;
>
> auto myAA = Hash!(string, int)(["hello" : 1, "world" : 2]);
>
> void main()
> {
>    int[string] aa = myAA.asAA;
>    writeln(aa);
> }
> ```
>
> Not much niceties there yet, notably, it doesn't print out 
> well, or have a good factory function. You also cannot 
> reinterpret as a builtin AA at compile time, because the 
> reinterpret cast isn't possible.
>
> But you can just use it as a drop-in replacement for builtin 
> AAs. It actually is binary compatible, so you can have both a 
> normal builtin AA reference to it, and a `Hash` reference, and 
> both will work.
>
> -Steve

Thank you. This is going to be useful to me anyways.


More information about the Digitalmars-d mailing list