Semantics of mixed CT and RT statements
NaN
divide at by.zero
Sat Dec 22 10:29:08 UTC 2018
On Saturday, 22 December 2018 at 04:02:46 UTC, Timoses wrote:
> On Saturday, 22 December 2018 at 03:51:58 UTC, Rubn wrote:
>>
>> You don't need to do another is() inside of the assert, as it
>> is guaranteed to be true. Just put the logic in the static if
>> like normal.
>>
>> static if( is(T== SomeType) ) {
>> // runtime condition
>> if( true || b ) // just becomes true
>> writeln("1");
>> }
>
> This wouldn't print "1" in case T is != SomeType. Hence `static
> if || if`.
Just do
if ((is(T == SomeType)) || (b))
First bit will be evaluated at compile time but or-ed with 'b' at
runtime.
The point is if you want the whole thing evaluated in one rather
than in sequence, then the whole expression is dependant on a
runtime variable, which makes using static if on half of it wrong.
More information about the Digitalmars-d
mailing list