Inversion of conditional compilation statements

Nick Treleaven nick at geany.org
Sat Dec 2 15:48:02 UTC 2023


On Saturday, 2 December 2023 at 15:03:25 UTC, ryuukk_ wrote:
> I wish we could use ``version`` as expression, to void the 
> repetition:
>
> ```D
> import std.stdio;
>
> enum HasTest = version (Test) ? true : false;

Tomek Sowiński wrote this template:
```d
enum bool isVersion(string ver) = !is(typeof({
           mixin("version(" ~ ver ~ ") static assert(0);");
     }));

static assert(isVersion!"assert");
static assert(!isVersion!"Broken");
```


More information about the Digitalmars-d-learn mailing list