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

2020-07-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 July 2020 at 21:38:12 UTC, Per Nordlöw wrote: On Sunday, 5 July 2020 at 21:22:13 UTC, ikod wrote: struct AA(K,V) { void opAssign(V[K] aa) { } } void main() { AA!(string, int) custom_aa; custom_aa = ["one":1, "two":2]; } Forget to mention that I want the

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

2020-07-05 Thread user1234 via Digitalmars-d-learn
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? How about iterating the literal, e.g --- foreach (k,v; ["one":1, "two":2]) { myCustomAA[k] = v; } ---

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

2020-07-05 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 5 July 2020 at 21:22:13 UTC, ikod wrote: struct AA(K,V) { void opAssign(V[K] aa) { } } void main() { AA!(string, int) custom_aa; custom_aa = ["one":1, "two":2]; } Forget to mention that I want the assign call (to `opAssign`) in `main` to be non-(GC)heap

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

2020-07-05 Thread ikod via Digitalmars-d-learn
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? can opAssign help? struct AA(K,V) { void opAssign(V[K] aa) { } } void main() { AA!(string, int) custom_aa;

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

2020-07-05 Thread Per Nordlöw via Digitalmars-d-learn
Is there a way to construct a custom written hash-table container (struct) from an AA-literal expression?