Skip to content

Commit 08d3250

Browse files
committed
CBD-6348: [BP] [C++20] Add SerialisedDocKey::operator== ...
C++ wants an operator for A == B and B == A. Our SerialisedDocKey had just an operator for DocKeyView which would cause B to be converted to DocKeyView (as we have an operator for that) and now we can't necessarily know if one could flip the order. This is a cherryy-pick from trinity Change-Id: I2c3cd6594c34f3a67e299d47a6978f8d8eeb17ae Reviewed-on: https://review.couchbase.org/c/kv_engine/+/234992 Well-Formed: Restriction Checker Tested-by: Trond Norbye <[email protected]> Reviewed-by: Faizan Alam <[email protected]>
1 parent 064a0fb commit 08d3250

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

engines/ep/src/storeddockey.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ bool SerialisedDocKey::operator==(const DocKey& rhs) const {
126126
std::equal(rhs.begin(), rhs.end(), data() + 1);
127127
}
128128

129+
bool SerialisedDocKey::operator==(const SerialisedDocKey& rhs) const {
130+
return rhs.size() == size() && std::memcmp(data(), rhs.data(), size()) == 0;
131+
}
132+
129133
SerialisedDocKey::SerialisedDocKey(cb::const_byte_buffer key,
130134
CollectionID cid) {
131135
cb::mcbp::unsigned_leb128<CollectionIDType> leb128(uint32_t{cid});

engines/ep/src/storeddockey.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class SerialisedDocKey : public DocKeyInterface<SerialisedDocKey> {
239239
}
240240

241241
bool operator==(const DocKey& rhs) const;
242+
bool operator==(const SerialisedDocKey& rhs) const;
242243

243244
/**
244245
* Return how many bytes are (or need to be) allocated to this object

0 commit comments

Comments
 (0)