struct SomePathStruct { dstring somePathText; mixin NaturalPathComparable!somePathText; } struct SomePathStructWithFunction { dstring _value; dstring path() const @safe nothrow { return _value; } mixin NaturalPathComparable!path; } assert(SomePathStruct("a/b/c") < SomePathStruct("a/b/d")); assert(SomePathStructWithFunction("a/b/c") < SomePathStructWithFunction("a/b/d"));
Automatically generates natural-path-comparing opCmp, opEquals and toHash methods for a particular property or method. Methods must be @safe, nothrow, and const.