Detect runtime vs ctfe?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Sun Nov 29 06:17:39 PST 2009


Nick Sabalausky wrote:
> Is there an idiom, preferably D1, to detect whether or not the code is 
> currently executing as a ctfe?
> 
> Ie:
> 
> void foo()
> {
>     (static?) if( ???? )
>     {
>         // Run-time code here
>         // that does stuff the CTFE engine chokes on
>     }
>     else
>     {
>         // CTFE code here
>         // that might not be ideal, but at least works as CTFE
>     }
> }

Don posted one to the NG once, but I'm not sure if it works with D1:

http://www.digitalmars.com/d/archives/digitalmars/D/Going_from_CTFE-land_to_Template-land_101395.html#N101414

-Lars


More information about the Digitalmars-d-learn mailing list