Why this code can't take advantage from CTFE?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 3 09:39:39 PST 2016


On 2/3/16 12:16 PM, Andrea Fontana wrote:
> On Wednesday, 3 February 2016 at 16:24:19 UTC, Adam D. Ruppe wrote:
>> On Wednesday, 3 February 2016 at 16:07:59 UTC, Messenger wrote:
>>> What is a good way to try to force it? Using enum? Then optionally
>>> copying the value once to avoid the "manifest constant" copy/paste
>>> behaviour, where applicable?
>>
>> Yes, or static local variables are ctfe initialized too.
>
> But if I want a normal var, not static or enum?
> There's no way to force it?

Hm... trick you could do is:

auto myvar = AliasSeq!(someCTFEFunc())[0];

-Steve


More information about the Digitalmars-d-learn mailing list