diff --git a/src/position.hh b/src/position.hh index fd953cb2..250cdead 100644 --- a/src/position.hh +++ b/src/position.hh @@ -23,14 +23,23 @@ struct Pos { // Compare two Positions and check if they are equal. Ignores the value of // |interesting|. bool operator==(const Pos &o) const { - return line == o.line && column == o.column; + return asTuple() == o.asTuple(); } bool operator<(const Pos &o) const { - if (line != o.line) - return line < o.line; - return column < o.column; + return asTuple() < o.asTuple(); } - bool operator<=(const Pos &o) const { return !(o < *this); } + bool operator<=(const Pos &o) const { + return asTuple() <= o.asTuple(); + } +protected: + /*! + * (line, pos) + * use for lexicographic comparison + */ + auto asTuple() const -> std::tuple { + return std::make_tuple(line, tuple); + } + }; struct Range {