mirror of
https://github.com/MaskRay/ccls.git
synced 2025-03-21 16:26:16 +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
|
// Compare two Positions and check if they are equal. Ignores the value of
|
||||||
// |interesting|.
|
// |interesting|.
|
||||||
bool operator==(const Pos &o) const {
|
bool operator==(const Pos &o) const {
|
||||||
return line == o.line && column == o.column;
|
return asTuple() == o.asTuple();
|
||||||
}
|
}
|
||||||
bool operator<(const Pos &o) const {
|
bool operator<(const Pos &o) const {
|
||||||
if (line != o.line)
|
return asTuple() < o.asTuple();
|
||||||
return line < o.line;
|
|
||||||
return column < o.column;
|
|
||||||
}
|
}
|
||||||
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 {
|
struct Range {
|
||||||
|
Loading…
Reference in New Issue
Block a user