Semantics of mixed CT and RT statements

Timoses timosesu at gmail.com
Sat Dec 22 04:02:46 UTC 2018


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

Note that the idea of `static if || if` does not exist (afaik):

>> static if (A) || if (B): Only ever check B at run-time when A 
>> is false at compile-time

> else static if( is (T == SomeOtherType ) ) {
>     if( b ) {
>         writeln("2");
>     }
> }





More information about the Digitalmars-d mailing list