@ctfeonly
Manu
turkeyman at gmail.com
Fri Dec 8 18:59:29 UTC 2017
On 7 December 2017 at 19:49, Walter Bright via Digitalmars-d <
digitalmars-d at 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...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20171208/76117018/attachment.html>
More information about the Digitalmars-d
mailing list