Associative array on the heap

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 18 17:03:59 PDT 2015


On Mon, 18 May 2015 23:55:38 +0000, 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", "-v", "-o-",
> "test.d", "-I."]

AAs are always allocated on heap, you don't need to do anything special.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150519/1ff6f680/attachment.sig>


More information about the Digitalmars-d-learn mailing list