diff options
Diffstat (limited to 'src/mongo/db/record_id.h')
| -rw-r--r-- | src/mongo/db/record_id.h | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/mongo/db/record_id.h b/src/mongo/db/record_id.h index 91eed920098..58931fed9f9 100644 --- a/src/mongo/db/record_id.h +++ b/src/mongo/db/record_id.h @@ -30,10 +30,8 @@ #pragma once #include <boost/functional/hash.hpp> -#include <boost/operators.hpp> #include <boost/optional.hpp> #include <climits> -#include <cstddef> #include <cstdint> #include <fmt/format.h> #include <ostream> @@ -49,7 +47,7 @@ namespace mongo { /** * The key that uniquely identifies a Record in a Collection or RecordStore. */ -class RecordId : boost::totally_ordered<RecordId> { +class RecordId { public: // This set of constants define the boundaries of the 'normal' id ranges for the int64_t format. static constexpr int64_t kMinRepr = LLONG_MIN; @@ -91,7 +89,7 @@ public: * retrieved using getStr(). */ explicit RecordId(const char* str, int32_t size) { - uassert(8273007, fmt::format("key size must be greater than 0. size: {}", size), size > 0); + invariant(size > 0, "key size must be greater than 0"); if (size <= kSmallStrMaxSize) { _format = Format::kSmallStr; // Must fit into the buffer minus 1 byte for size. @@ -239,14 +237,6 @@ public: MONGO_UNREACHABLE; } - bool operator==(const RecordId& rhs) const { - return compare(rhs) == 0; - } - - bool operator<(const RecordId& rhs) const { - return compare(rhs) < 0; - } - size_t hash() const { size_t hash = 0; withFormat([](Null n) {}, @@ -434,6 +424,25 @@ private: ConstSharedBuffer _sharedBuffer; }; +inline bool operator==(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs) == 0; +} +inline bool operator!=(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs); +} +inline bool operator<(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs) < 0; +} +inline bool operator<=(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs) <= 0; +} +inline bool operator>(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs) > 0; +} +inline bool operator>=(const RecordId& lhs, const RecordId& rhs) { + return lhs.compare(rhs) >= 0; +} + inline StringBuilder& operator<<(StringBuilder& stream, const RecordId& id) { return stream << "RecordId(" << id.toString() << ')'; } |
