CTFE determination?
Russell Lewis
webmaster at villagersonline.com
Fri Sep 12 10:41:26 PDT 2008
bmeck wrote:
> Hi i was messing around in D2 and noticed that the following always is saying that it is only at runtime even when the input is a constant... was wondering if there was a right way to do this.
CTFE only kicks in when the function is called in a context which
requires a compile-time constant, such as passing the return value from
the function as the parameter to a template.
If you don't use the function in that context, then CTFE is *not*
active. Thus, your test() function is *not* compile-time evaluated.
The basic reason for this is that if you write a long-running scientific
program with fixed inputs you don't want CTFE to kick in just because
the inputs are hard-coded.
More information about the Digitalmars-d
mailing list