On 7 December 2017 at 19:49, Walter Bright via Digitalmars-d <
digitalmars-d@puremagic.com> wrote:

> 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.
>

Sorry, in my mind, it was meant to be a template function...

Reply via email to