Re: Associative array on the heap

2020-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/7/20 3:08 AM, mw wrote: On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote: On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can

Re: Associative array on the heap

2020-07-07 Thread mw via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 12:21:48 UTC, Steven Schveighoffer wrote: On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic

Re: Associative array on the heap

2015-05-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 7:55 PM, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic arrays or class objects, not int[string]'s Failed: ["dmd&q

Re: Associative array on the heap

2015-05-18 Thread Xinok via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 00:31:50 UTC, Freddy wrote: Sorry mis-phrased my question, Who do you allocate a pointer to an associative array(int[string]*). Ignoring the why for a moment, one trick is to place it in an array literal so it's heap allocated. This requires writing an associative

Re: Associative array on the heap

2015-05-18 Thread Freddy via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 00:00:30 UTC, Meta wrote: On Monday, 18 May 2015 at 23:55:40 UTC, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs

Re: Associative array on the heap

2015-05-18 Thread Meta via Digitalmars-d-learn
On Monday, 18 May 2015 at 23:55:40 UTC, Freddy wrote: How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic arrays or class objects, not int[string]&#

Re: Associative array on the heap

2015-05-18 Thread ketmar via Digitalmars-d-learn
On Mon, 18 May 2015 23:55:38 +, Freddy wrote: > How do you allocate an associative array on the heap? > > void main(){ > alias A=int[string]; > auto b=new A; > } > > $ rdmd test test.d(4): Error: new can only create structs, dynamic > array

Re: Associative array on the heap

2015-05-18 Thread Meta via Digitalmars-d-learn
On Tuesday, 19 May 2015 at 00:00:30 UTC, Meta wrote: A b = []; //No allocation yet, b is null Whoops, you actually can't assign the empty array literal to an AA. This line should be: A b; Which has the exact same effects.

Associative array on the heap

2015-05-18 Thread Freddy via Digitalmars-d-learn
How do you allocate an associative array on the heap? void main(){ alias A=int[string]; auto b=new A; } $ rdmd test test.d(4): Error: new can only create structs, dynamic arrays or class objects, not int[string]'s Failed: ["dmd", "-v", "-o-", "test.d", "-I."]