https://issues.dlang.org/show_bug.cgi?id=13663
Simen Kjaeraas <simen.kja...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |simen.kja...@gmail.com Resolution|WONTFIX |--- --- Comment #3 from Simen Kjaeraas <simen.kja...@gmail.com> --- Peter's claims in comment 1 are plain false - opCmp can return float, and float.nan for incomparable cases. Here's an implementation of opCmp that does that: float opCmp(R)(R rhs) if (areCompatibleTuples!(typeof(this), R, "<")) { static foreach (i; 0 .. Types.length) { if (field[i] != field[i] || rhs.field[i] != rhs.field[i]) { return float.nan; } if (field[i] != rhs.field[i]) { return field[i] < rhs.field[i] ? -1 : 1; } } return 0; } /// ditto float opCmp(R)(R rhs) const if (areCompatibleTuples!(typeof(this), R, "<")) { static foreach (i; 0 .. Types.length) { if (field[i] != field[i] || rhs.field[i] != rhs.field[i]) { return float.nan; } if (field[i] != rhs.field[i]) { return field[i] < rhs.field[i] ? -1 : 1; } } return 0; } These are taken directly from std.typecons, and the only change made is they return float, and check if any of the fields are incomparable. --