diff --git a/src/NCollection/NCollection_DefaultHasher.hxx b/src/NCollection/NCollection_DefaultHasher.hxx index 4007ea2739..188bb1b23f 100644 --- a/src/NCollection/NCollection_DefaultHasher.hxx +++ b/src/NCollection/NCollection_DefaultHasher.hxx @@ -29,8 +29,50 @@ * IsEqual. */ template -DEFINE_HASHER(NCollection_DefaultHasher, TheKeyType, std::hash, std::equal_to) +struct NCollection_DefaultHasher +{ + size_t operator()(const TheKeyType& theKey) const noexcept + { + return HashCode(theKey); + } + bool operator() (const TheKeyType& theK1, const TheKeyType& theK2) const noexcept + { + return IsEqual(theK1, theK2); + } +private: + // For non-enums + template + typename std::enable_if::value, size_t>::type + HashCode(const TheKeyType& theKey) const noexcept + { + return std::hash{}(theKey); + } + + // For non-enums + template + typename std::enable_if::value, bool>::type + IsEqual(const TheKeyType& theK1, const TheKeyType& theK2) const noexcept + { + return std::equal_to{}(theK1, theK2); + } + + // For enums + template + typename std::enable_if::value, size_t>::type + HashCode(const TheKeyType& theKey) const noexcept + { + return static_cast(theKey); + } + + // For enums + template + typename std::enable_if::value, bool>::type + IsEqual(const TheKeyType& theK1, const TheKeyType& theK2) const noexcept + { + return theK1 == theK2; + } +}; #define DEFINE_DEFAULT_HASHER_PURE(TheKeyType) \ template <> struct NCollection_DefaultHasher \