diff options
Diffstat (limited to 'source/core/smart-pointer.h')
| -rw-r--r-- | source/core/smart-pointer.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/source/core/smart-pointer.h b/source/core/smart-pointer.h index e19ed6a4d..0b03deb8f 100644 --- a/source/core/smart-pointer.h +++ b/source/core/smart-pointer.h @@ -2,6 +2,7 @@ #define FUNDAMENTAL_LIB_SMART_POINTER_H #include "common.h" +#include "hash.h" #include "type-traits.h" #include <assert.h> @@ -157,10 +158,14 @@ namespace Slang releaseReference(old); } - int GetHashCode() - { - return (int)(long long)(void*)pointer; - } + int GetHashCode() + { + // Note: We need a `RefPtr<T>` to hash the same as a `T*`, + // so that a `T*` can be used as a key in a dictionary with + // `RefPtr<T>` keys, and vice versa. + // + return Slang::GetHashCode(pointer); + } bool operator==(const T * ptr) const { |
