Is enum static?

Jonathan M Davis jmdavisProg at gmx.com
Tue Aug 20 10:01:52 PDT 2013


On Tuesday, August 20, 2013 12:54:29 John Colvin wrote:
> is there an allocation in this?
> 
> enum vals=[1, 2, 3, 0];
> 
> int[4] a;
> a[] = vals[];

Since, you're asking it to copy the elements of a dynamic array to a static 
one, I would fully expect it to result in an allocation, though a smart 
compiler might optimize it out. I wouldn't expect dmd to do that though.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list