db/view: use operator<=> to define comparison operators

also, there is no need to define operator!=() if
operator==() is defined, so drop it.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2023-02-28 17:13:15 +08:00
parent 4f3bc915a6
commit ab5d772d63

View File

@@ -8,6 +8,7 @@
#pragma once
#include <compare>
#include <cstddef>
#include <limits>
@@ -28,28 +29,11 @@ struct update_backlog {
return float(current) / float(max);
}
friend bool operator==(const update_backlog& lhs, const update_backlog& rhs) {
return lhs.relative_size() == rhs.relative_size();
std::partial_ordering operator<=>(const update_backlog &rhs) const {
return relative_size() <=> rhs.relative_size();
}
friend bool operator<(const update_backlog& lhs, const update_backlog& rhs) {
return lhs.relative_size() < rhs.relative_size();
}
friend bool operator!=(const update_backlog& lhs, const update_backlog& rhs) {
return !(lhs == rhs);
}
friend bool operator<=(const update_backlog& lhs, const update_backlog& rhs) {
return !(rhs < lhs);
}
friend bool operator>(const update_backlog& lhs, const update_backlog& rhs) {
return rhs < lhs;
}
friend bool operator>=(const update_backlog& lhs, const update_backlog& rhs) {
return !(lhs < rhs);
bool operator==(const update_backlog& rhs) const {
return relative_size() == rhs.relative_size();
}
static update_backlog no_backlog() {