NaturalComparable

Automatically generates natural-comparing opCmp, opEquals and toHash methods for a particular property or method. Methods must be @safe, nothrow, and const.

mixin template NaturalComparable () {}

Members

Mixins

__anonymous
mixin NaturalComparableCommon!(compareNatural, T)
Undocumented in source.

Examples

struct SomeStruct {
	dstring someText;
	mixin NaturalComparable!someText;
}
struct SomeStructWithFunction {
	dstring _value;
	dstring something() const nothrow @safe {
		return _value;
	}
	mixin NaturalComparable!something;
}
assert(SomeStruct("100") > SomeStruct("2"));
assert(SomeStruct("100") == SomeStruct("100"));
assert(SomeStructWithFunction("100") > SomeStructWithFunction("2"));
assert(SomeStructWithFunction("100") == SomeStructWithFunction("100"));

Meta