Question about @nogc
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 20 14:30:21 PDT 2014
On Tuesday, 20 May 2014 at 21:16:26 UTC, monarch_dodra wrote:
>> enum ReturnType!fn[length] lookupTable = [elements];
>
> Depending on what the usecase is, you might want to change that
> to static immutable instead:
>
> static immutable ReturnType!fn[length] lookupTable = [elements];
>
> Remember that when using an enum, the compiler will create a
> *new* variable on every use. While the compiler can sometimes
> avoid actually allocating, it may also insert some object code
> bloat to do so.
That's the "return" line of a template. In the usage example in
main() it's static immutable.
More information about the Digitalmars-d-learn
mailing list