More operators inside `is(...)` expressions

Simen Kjærås simen.kjaras at
Tue Sep 1 11:01:52 UTC 2020

On Tuesday, 1 September 2020 at 09:05:27 UTC, Jacob Carlborg 
> On Tuesday, 1 September 2020 at 07:11:45 UTC, Ogi wrote:
>> Why use `version` then?
> Because that's set automatically by the compiler. Here's a list 
> of the predefined version identifiers set by the compiler [1].
> [1]

Also, more versions can be set via the -version compiler flag:

Perhaps an even more useful version of the above trick:

struct Version {
     template opDispatch(string name) {
         mixin("version ("~name~") enum opDispatch = true; else 
enum opDispatch = false;");

static if (Version.Windows) pragma(msg, "Windows machine");
static if (Version.linux) pragma(msg, "Linux machine");


More information about the Digitalmars-d mailing list