How do I check if a function got CTFE?

AsmMan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 2 11:33:19 PDT 2014


On Thursday, 2 October 2014 at 18:02:30 UTC, Adam D. Ruppe wrote:
> On Thursday, 2 October 2014 at 17:56:29 UTC, AsmMan wrote:
>> I'd like to check if a function got CTFE, ie, the compiler was 
>> able to replace my foo(s); by the computed value at 
>> compile-time.
>
> You have to explicitly force ctfe with context, it is never 
> done automatically, and if it fails, the build will fail and 
> you get a compile time error.

That's the point. I thought the compiler did it by checking 
things like constant arguments + function purity or so. This was 
exactly my issue. Thanks!


More information about the Digitalmars-d-learn mailing list