Construct an used-defined hash table container type from an AA-literal expression

Jacob Carlborg doob at
Mon Jul 6 12:04:11 UTC 2020

On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote:
> Is there a way to construct a custom written hash-table 
> container (struct) from an AA-literal expression?

I think your best bet is a tuple of pairs, because then you're 
not limited to compile time values, but it won't look pretty:

import std;

struct Pair
     string key;
     int value;

void main() @nogc
     auto a = tuple(Pair("foo", 1), Pair("bar", 2));

/Jacob Carlborg

More information about the Digitalmars-d-learn mailing list