Differences From Artifact [783554bf667412ed]:
- File
src/util.d
- 2012-07-14 11:24:30 - part of checkin [bee0596f0f] on branch trunk - Refactoring. (user: kinaba) [annotate]
To Artifact [0665970b47ba63ed]:
- File
src/util.d
- 2012-07-15 01:58:08 - part of checkin [9d983af88c] on branch trunk - Hige parsing and rendering. (user: kinaba) [annotate]
19 this.tupleof = params; 19 this.tupleof = params;
20 } 20 }
21 } 21 }
22 22
23 template DeriveCompare() 23 template DeriveCompare()
24 { 24 {
25 override: 25 override:
26 bool opEquals(Object rhs) | 26 bool opEquals(Object rhs) const
27 { 27 {
28 return tuple(this.tupleof) == tuple((cast(typeof(this))rhs).tupl 28 return tuple(this.tupleof) == tuple((cast(typeof(this))rhs).tupl
29 } 29 }
30 30
31 int opCmp(Object rhs) | 31 int opCmp(Object rhs) const
32 { 32 {
33 return tuple(this.tupleof).opCmp(tuple((cast(typeof(this))rhs).t 33 return tuple(this.tupleof).opCmp(tuple((cast(typeof(this))rhs).t
34 } 34 }
35 35
36 hash_t toHash() | 36 hash_t toHash() const
37 { 37 {
38 hash_t v = 0; 38 hash_t v = 0;
39 foreach(mem; this.tupleof) { 39 foreach(mem; this.tupleof) {
40 v *= 11; 40 v *= 11;
41 static if(__traits(compiles, v^=mem)) 41 static if(__traits(compiles, v^=mem))
42 v ^= mem; 42 v ^= mem;
43 else 43 else
................................................................................................................................................................................
46 return v; 46 return v;
47 } 47 }
48 } 48 }
49 49
50 template DeriveShow() 50 template DeriveShow()
51 { 51 {
52 override: 52 override:
53 string toString() | 53 string toString() const
54 { 54 {
55 string str = text(typeof(this).stringof, "("); 55 string str = text(typeof(this).stringof, "(");
56 foreach(i,mem; this.tupleof) { 56 foreach(i,mem; this.tupleof) {
57 if(i) str ~= ", "; 57 if(i) str ~= ", ";
58 str = text(str, this.tupleof[i].stringof[5..$], ":", me 58 str = text(str, this.tupleof[i].stringof[5..$], ":", me
59 } 59 }
60 return str ~ ")"; 60 return str ~ ")";
61 } 61 }
62 } 62 }