On Saturday, 9 September 2017 at 16:30:51 UTC, Jean-Louis Leroy wrote:
I did look at the docs, several times, couldn't find it...

you should use my unofficial docs

http://dpldocs.info/version

std.compiler looks useful
http://dpldocs.info/experimental-docs/std.compiler.version_minor.html


static foreach was introduced in 2.076 so

import std.compiler;
static if(version_minor >= 76) {
   // it is available
}


BUT, this won't do what I suspect you want... if you put a static foreach in there and compile with an old compiler... it will still cause a parse error.

The false branch of a static if still need to parse correctly, and static foreach won't in old D.

You can work around that by perhaps importing alternative modules or using string mixin that contains the new code (similar techniques for libs that are both D1 and D2 compatible)

Reply via email to