On 12/7/2017 5:30 PM, Manu wrote:
I tried this, and was surprised it didn't work:
int ctfeOnly(int x)
{
static assert(__ctfe);
return x + 1;
}
The error is:
test2.d(3): Error: variable __ctfe cannot be read at compile time
test2.d(3): while evaluating: static assert(__ctfe)
because static asserts are evaluated when the function is semantically analyzed, not when it is executed.