1 module acd.versions;
2 
3 /** 
4 	Lets you get a given version as a boolean expression.
5 
6 	Examples:
7 
8 	```d
9 	import acd.versions : Versions;
10 	mixin Versions;
11 
12 	version = Hello;
13 	static assert(Version.Hello && !Version.Foo);
14 
15 	// Setting version conditionally.
16 	static if (Version.Hello)
17 		version = World;
18 	static assert(Version.World);
19 
20 	// Setting version if a version is not defined.
21 	static if (!Version.A)
22 		version = B;
23 	static assert(Version.B);
24 
25 	// Using as boolean expressions and assigning to a variable.
26 	version = C;
27 	enum BC = Version.B && Version.C;
28 	static assert(BC);
29 	```
30 
31 	Note: the following compiles, because `version = Bar` is evaluated before
32 	the template gets expanded. With a `version(Bar){}` it would just not compile,
33 	because versions cannot be defined after they have been used.
34 
35 	```d
36 	static assert(Version.Bar);
37 	version = Bar;
38 	```
39 
40 	Works when passing version flags when compiling as well.
41 	
42 	The other assumptions you have about the way this works will just hold true.
43 	Surprisingly, it just works!
44 */
45 mixin template Versions()
46 {
47 	struct Version
48 	{
49 		@disable this();
50 		static template opDispatch(string id)
51 		{	
52 			mixin(`
53 				version (`, id, `) 
54 					enum opDispatch = true;
55 				else 
56 					enum opDispatch = false;
57 			`);
58 		}
59 	}
60 }