libutil: replace Pos operator< with <=> and constexpr ==
Change-Id: I60080c416b2ee2b0efce4584cf13f37c0596d73d
This commit is contained in:
@@ -17,12 +17,6 @@ Pos::operator std::shared_ptr<Pos>() const
|
||||
return std::make_shared<Pos>(&*this);
|
||||
}
|
||||
|
||||
bool Pos::operator<(const Pos &rhs) const
|
||||
{
|
||||
return std::forward_as_tuple(line, column, origin)
|
||||
< std::forward_as_tuple(rhs.line, rhs.column, rhs.origin);
|
||||
}
|
||||
|
||||
std::optional<LinesOfCode> Pos::getCodeLines() const
|
||||
{
|
||||
if (line == 0)
|
||||
|
||||
@@ -67,9 +67,15 @@ struct Pos
|
||||
|
||||
std::optional<LinesOfCode> getCodeLines() const;
|
||||
|
||||
bool operator==(const Pos & rhs) const = default;
|
||||
bool operator!=(const Pos & rhs) const = default;
|
||||
bool operator<(const Pos & rhs) const;
|
||||
// Not defaulted because it's implicitly deleted because C++ is stupid.
|
||||
constexpr friend auto operator<=>(Pos const & lhs, Pos const & rhs)
|
||||
{
|
||||
return std::forward_as_tuple(lhs.line, lhs.column, lhs.origin)
|
||||
<=> std::forward_as_tuple(rhs.line, rhs.column, rhs.origin);
|
||||
}
|
||||
|
||||
// operator<=> doesn't generate this because it's not defaulted.
|
||||
constexpr friend bool operator==(Pos const & lhs, Pos const & rhs) = default;
|
||||
|
||||
struct LinesIterator {
|
||||
using difference_type = size_t;
|
||||
|
||||
Reference in New Issue
Block a user