On Saturday, 9 September 2017 at 16:53:19 UTC, jmh530 wrote:

version(DLANGSEMVER >= 2.076.0)
{
   //include static foreach code.
}

but we can't do conditionals in version blocks, so you'd need a static if. Alternately, we'd also need a trait or something to get the semver of the compiler.

Actually:

static if(__VERSION__ >= 2076)

Better to use this than the compiler version, as it specifies the version of the front end, so when LDC and GDC catch up it will work for those as well.

But Adam's point about the false branch still holds, so:

static if(__VERSION__ >= 2076)
    mixin(`static foreach(i; 0..3) writeln(i);`);
else
    writeln("Version too low");

The same is true for version statements.

Reply via email to