6293256fec 2012-07-14 kinaba: public import std.algorithm; 6293256fec 2012-07-14 kinaba: public import std.array; 6293256fec 2012-07-14 kinaba: public import std.conv; 6293256fec 2012-07-14 kinaba: public import std.range; 6293256fec 2012-07-14 kinaba: public import std.stdio; 6293256fec 2012-07-14 kinaba: public import std.string; 6293256fec 2012-07-14 kinaba: public import std.typecons; 6293256fec 2012-07-14 kinaba: 6293256fec 2012-07-14 kinaba: template DeriveCreate() 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: this(TS...)(TS params) 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: this.tupleof = params; 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: 6293256fec 2012-07-14 kinaba: template DeriveCompare() 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: override: 6293256fec 2012-07-14 kinaba: bool opEquals(Object rhs) 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: return tuple(this.tupleof) == tuple((cast(typeof(this))rhs).tupleof); 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: 6293256fec 2012-07-14 kinaba: int opCmp(Object rhs) 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: return tuple(this.tupleof).opCmp(tuple((cast(typeof(this))rhs).tupleof)); 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: 6293256fec 2012-07-14 kinaba: hash_t toHash() 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: hash_t v = 0; 6293256fec 2012-07-14 kinaba: foreach(mem; this.tupleof) { 6293256fec 2012-07-14 kinaba: v *= 11; 6293256fec 2012-07-14 kinaba: static if(__traits(compiles, v^=mem)) 6293256fec 2012-07-14 kinaba: v ^= mem; 6293256fec 2012-07-14 kinaba: else 6293256fec 2012-07-14 kinaba: v ^= typeid(mem).getHash(&mem); 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: return v; 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: 6293256fec 2012-07-14 kinaba: template DeriveShow() 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: override: 6293256fec 2012-07-14 kinaba: string toString() 6293256fec 2012-07-14 kinaba: { 6293256fec 2012-07-14 kinaba: string str = text(typeof(this).stringof, "("); 6293256fec 2012-07-14 kinaba: foreach(i,mem; this.tupleof) { 6293256fec 2012-07-14 kinaba: if(i) str ~= ", "; 6293256fec 2012-07-14 kinaba: str = text(str, this.tupleof[i].stringof[5..$], ":", mem); 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: return str ~ ")"; 6293256fec 2012-07-14 kinaba: } 6293256fec 2012-07-14 kinaba: }