How do I check if a function got CTFE?
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Oct 2 12:50:55 PDT 2014
On Thursday, 2 October 2014 at 18:42:56 UTC, AsmMan wrote:
> I was thiking the dmd compiler did CTFE without someone ask for
> this, in the way as I've mentioned, checking for constant
> arguments + function's purity and if all this is true, it did
> the CTFE rather than generate code to compute it at run-time.
> In the case of it did happen, I just wanted to know. It was my
> misunderstsooding how it does works in dmd.
A convenient way to force ctfe is "eval":
http://dlang.org/function.html (search for "eval!")
Though you'd change "const" for "enum".
Unfortunately, it's not in Phobos, but it should be!
https://issues.dlang.org/show_bug.cgi?id=11811
More information about the Digitalmars-d-learn
mailing list