Artifact 8d98b81c5616ea88b288a157097423341092abb8
1 public import std.algorithm;
2 public import std.array;
3 public import std.conv;
4 public import std.range;
5 public import std.stdio;
6 public import std.string;
7 public import std.typecons;
8
9 template DeriveCreate()
10 {
11 this(TS...)(TS params)
12 {
13 this.tupleof = params;
14 }
15 }
16
17 template DeriveCompare()
18 {
19 override:
20 bool opEquals(Object rhs)
21 {
22 return tuple(this.tupleof) == tuple((cast(typeof(this))rhs).tupleof);
23 }
24
25 int opCmp(Object rhs)
26 {
27 return tuple(this.tupleof).opCmp(tuple((cast(typeof(this))rhs).tupleof));
28 }
29
30 hash_t toHash()
31 {
32 hash_t v = 0;
33 foreach(mem; this.tupleof) {
34 v *= 11;
35 static if(__traits(compiles, v^=mem))
36 v ^= mem;
37 else
38 v ^= typeid(mem).getHash(&mem);
39 }
40 return v;
41 }
42 }
43
44 template DeriveShow()
45 {
46 override:
47 string toString()
48 {
49 string str = text(typeof(this).stringof, "(");
50 foreach(i,mem; this.tupleof) {
51 if(i) str ~= ", ";
52 str = text(str, this.tupleof[i].stringof[5..$], ":", mem);
53 }
54 return str ~ ")";
55 }
56 }