Serious problem with opCmp

kov_serg kov_serg at freemail.ru
Sun Mar 2 14:01:22 PST 2008


Bill Baxter Wrote:

In C++ code solution may looks like:

template<class T>int compare(const T& lv,const T& rv) {
	return lv<rv?-1: rv<lv?+1: 0;
}

and using it like this
struct S {
	int a,b;
	static int cmp(const S& lv,const S& rv) {
		int t=compare(lv.a,rv.a); if (t) return t;
		return compare(lv.b,rv.b);
	}
};
any case it will requires from me only operator<



More information about the Digitalmars-d mailing list