1 static assert(isOrderingComparable!int); 2 static assert(isOrderingComparable!string); 3 static assert(!isOrderingComparable!creal); 4 5 static struct Foo {} 6 static assert(!isOrderingComparable!Foo); 7 8 static struct Bar 9 { 10 int a; 11 auto opCmp(Bar b1) const { return a - b1.a; } 12 } 13 14 Bar b1 = Bar(5); 15 Bar b2 = Bar(7); 16 assert(isOrderingComparable!Bar && b2 > b1);
Detects whether T is a comparable type. Basic types and structs and classes that implement opCmp are ordering comparable.