diff options
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/oid.cpp | 6 | ||||
-rw-r--r-- | src/mongo/bson/oid.h | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/bson/oid.cpp b/src/mongo/bson/oid.cpp index 92664fd753c..b073c8efa49 100644 --- a/src/mongo/bson/oid.cpp +++ b/src/mongo/bson/oid.cpp @@ -50,6 +50,12 @@ namespace mongo { boost::hash_combine(seed, z); } + size_t OID::Hasher::operator() (const OID& oid) const { + size_t seed = 0; + oid.hash_combine(seed); + return seed; + } + // machine # before folding in the process id OID::MachineAndPid OID::ourMachine; diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h index b98e070eeac..d5063dc5f1b 100644 --- a/src/mongo/bson/oid.h +++ b/src/mongo/bson/oid.h @@ -53,6 +53,16 @@ namespace mongo { */ class OID { public: + + /** + * Functor compatible with std::hash for std::unordered_{map,set} + * Warning: The hash function is subject to change. Do not use in cases where hashes need + * to be consistent across versions. + */ + struct Hasher { + size_t operator() (const OID& oid) const; + }; + OID() : a(0), b(0) { } enum { |