Fix BookSide equality operators

This commit is contained in:
John Colvin committed 2025-01-27 16:35:22 +00:00
1 parent 4e01697327
commit 3a32ed5fe6
1 file changed
+13 -2
+13 -2
View File
@@ -250,12 +250,23 @@ constexpr size_t BookSideT<SZ>::size() const noexcept {
template <std::size_t SZ>
constexpr bool BookSideT<SZ>::operator==(BookSideT const &rhs) const {
return _book == rhs._book;
std::size_t i = 0;
for (; i < size(); i++) {
const BookLevel &l = (*this)[i];
if (i == rhs.size()) {
return l.is_empty();
}
const BookLevel &r = rhs[i];
if (l != r) {
return l.is_empty() && r.is_empty();
}
}
return i == rhs.size() || rhs[i].is_empty();
}
template <std::size_t SZ>
constexpr bool BookSideT<SZ>::operator!=(BookSideT const &rhs) const {
return _book != rhs._book;
return !(*this == rhs);
}
template <std::size_t SZ>