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; 8acc8e6c78 2012-07-15 kinaba: public import std.math; bee0596f0f 2012-07-14 kinaba: import std.c.stdlib; bee0596f0f 2012-07-14 kinaba: 86489420ef 2012-07-15 kinaba: // To avoide the following ICE: 86489420ef 2012-07-15 kinaba: // src\phobos\std\algorithm.d(4552): 86489420ef 2012-07-15 kinaba: // Error: function std.algorithm.count!("a == b",string,char).count 86489420ef 2012-07-15 kinaba: // compiler error, parameter 'value', bugzilla 2962? 86489420ef 2012-07-15 kinaba: // Assertion failure: '0' on line 717 in file 'glue.c' 86489420ef 2012-07-15 kinaba: int count(T,V)(T[] a, V v) 86489420ef 2012-07-15 kinaba: { 86489420ef 2012-07-15 kinaba: int cnt = 0; 86489420ef 2012-07-15 kinaba: foreach(e; a) 86489420ef 2012-07-15 kinaba: if(e == v) 86489420ef 2012-07-15 kinaba: ++cnt; 86489420ef 2012-07-15 kinaba: return cnt; 86489420ef 2012-07-15 kinaba: } 86489420ef 2012-07-15 kinaba: d95246eada 2013-03-16 kinaba: void application_exit() nothrow bee0596f0f 2012-07-14 kinaba: { bee0596f0f 2012-07-14 kinaba: std.c.stdlib.exit(0); bee0596f0f 2012-07-14 kinaba: } 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: 9d983af88c 2012-07-15 kinaba: bool opEquals(Object rhs) const 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: 9d983af88c 2012-07-15 kinaba: int opCmp(Object rhs) const 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: 9d983af88c 2012-07-15 kinaba: hash_t toHash() const 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: 9d983af88c 2012-07-15 kinaba: string toString() const 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: }