mirror of
https://github.com/MaskRay/ccls.git
synced 2025-03-18 23:11:31 +00:00
use tuple for lexicographical comparison
This commit is contained in:
parent
a4de46b9a0
commit
ca51f9eb4a
@ -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<Line,Column> {
|
||||
return std::make_tuple(line, tuple);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Range {
|
||||
|
Loading…
Reference in New Issue
Block a user