Versions

Lets you get a given version as a boolean expression.

mixin template Versions () {}

Members

Structs

Version
struct Version
Undocumented in source.

Examples

import acd.versions : Versions;
mixin Versions;

version = Hello;
static assert(Version.Hello && !Version.Foo);

// Setting version conditionally.
static if (Version.Hello)
	version = World;
static assert(Version.World);

// Setting version if a version is not defined.
static if (!Version.A)
	version = B;
static assert(Version.B);

// Using as boolean expressions and assigning to a variable.
version = C;
enum BC = Version.B && Version.C;
static assert(BC);

Note: the following compiles, because version = Bar is evaluated before the template gets expanded. With a version(Bar){} it would just not compile, because versions cannot be defined after they have been used.

static assert(Version.Bar);
version = Bar;

Works when passing version flags when compiling as well.

The other assumptions you have about the way this works will just hold true. Surprisingly, it just works!

Meta