Add comparison operator for bitextent am: 44c83ceeac
Original change: https://android-review.googlesource.com/c/platform/external/puffin/+/1835273
Change-Id: I716b7e3653d76947cc234f36bbaf86fcaeb62778
diff --git a/src/include/puffin/common.h b/src/include/puffin/common.h
index 954b7d9..07b8589 100644
--- a/src/include/puffin/common.h
+++ b/src/include/puffin/common.h
@@ -43,12 +43,18 @@
};
struct BitExtent {
- BitExtent(uint64_t offset, uint64_t length)
+ constexpr BitExtent(uint64_t offset, uint64_t length)
: offset(offset), length(length) {}
- bool operator==(const BitExtent& other) const {
+ constexpr bool operator==(const BitExtent& other) const {
return this->length == other.length && this->offset == other.offset;
}
+ constexpr bool operator<(const BitExtent& other) const {
+ if (offset != other.offset) {
+ return offset < other.offset;
+ }
+ return length < other.length;
+ }
uint64_t offset;
uint64_t length;