Differences From Artifact [c96de2738d81e418]:
- File
tricks/tricks.d
- 2010-11-13 02:48:58 - part of checkin [1c01f44f52] on branch trunk - simplepatternmatch (user: kinaba) [annotate]
To Artifact [d1500d1519df592c]:
- File
tricks/tricks.d
- 2010-11-13 05:38:21 - part of checkin [078444a806] on branch trunk - additional primitives for doing typechecking (user: kinaba) [annotate]
126 126 }
127 127
128 128 override int opCmp(Object rhs_) const /// member-by-member compare
129 129 {
130 130 if( auto rhs = cast(typeof(this))rhs_ )
131 131 {
132 132 foreach(i,_; this.tupleof)
133 - if(auto c = typeid(_).compare(&this.tupleof[i],&rhs.tupleof[i]))
134 - return c;
133 + if( this.tupleof[i] != rhs.tupleof[i] ) {
134 + auto a = this.tupleof[i];
135 + auto b = rhs.tupleof[i];
136 + return cast(SC_Unqual!(typeof(a)))a < b ? -1 : +1;
137 + }
138 +// if(auto c = typeid(_).compare(&this.tupleof[i],&rhs.tupleof[i]))
139 +// return c;
135 140 return 0;
136 141 }
137 142 assert(false, sprintf!"Cannot compare %s with %s"(typeid(this), typeid(rhs_)));
138 143 }
139 144 }
145 +
146 +alias std.traits.Unqual SC_Unqual;
140 147
141 148 unittest
142 149 {
143 150 class Temp
144 151 {
145 152 int x;
146 153 string y;