Checking if CTFE is used?
berni
someone at somemail.de
Tue Dec 18 16:20:11 UTC 2018
On Tuesday, 18 December 2018 at 14:32:29 UTC, Adam D. Ruppe wrote:
> CTFE is used if and only if it MUST be used by context. That's
> a runtime function, so no ctfe.
>
> Do something like:
>
> int[4] generate() {
> int[4] tmp;
> foreach(i; 0..4) tmp[i] = i;
> return tmp;
> }
>
>
> static immutable int[4] clue = generate();
Great, that worked. :-) My reasoning was, that CTFE is somewhat
greedy, that is, everything that can be evaluated at compile time
will be evaluated at compile time...
Many thanks for your replies. :-)
More information about the Digitalmars-d-learn
mailing list