C++17 cannot beat D surely

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 3 21:39:21 PDT 2017


On Sunday, 4 June 2017 at 04:34:44 UTC, Mike Parker wrote:
> I would not have expected enum b = sort(a) to trigger an 
> allocation. auto b, yes, of course (and the disassembly from 
> that is not much different). So I'd love to see a blog post 
> explaining it.

I don't think I can do a full-on blog post, but I can answer it 
in a couple sentences: `enum` is treated by the compiler just 
like literals. Array literals allocate at each usage point, 
therefore enum arrays allocate at each usage point. (*each* usage 
point)


More information about the Digitalmars-d mailing list