On 2015-03-15 19:16:52 +0000, anonymous said:

Answerting myself:

static if (__traits(compiles, version_minor < 67))
import std.string; // format() for versions < 2.0.67
else
import std.format; // format() for versions >= 2.0.67

That doesn't do what you want.

You need to `import std.compiler;` for version_minor. Without that import, `__traits(compiles, version_minor < 67)` is always false, because version_minor is undefined.

I have std.compiler imported.

And if you add the import, `__traits(compiles, version_minor < 67)` is always true, no matter the value of version_minor. Use `static if(version_minor < 67)` instead.

Ah, ok. Got it. so __traits(compiles,...) checks if the code can be compiled, that's it.

Finally, there's need for this (yet). `std.string.format` is fine with 2.067, too. So unless you're going for (far) future compatiblity, you can just do `import std.string;`.

I prefer to move things to the "far future compatibility" path ASAP. Reduce a lot of maintenance headaches.

Thanks for the feedback.

--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster

Reply via email to