From 39df94a7ea93456e06d97f0efbca1c5d210b0f0d Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 31 Jan 2019 08:21:39 -0800 Subject: Updated HashMapStringKey to define Hasher in the struct rather than in std --- Common/interface/HashUtils.h | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'Common/interface') diff --git a/Common/interface/HashUtils.h b/Common/interface/HashUtils.h index 5107f3b9..d84af8cd 100644 --- a/Common/interface/HashUtils.h +++ b/Common/interface/HashUtils.h @@ -113,17 +113,17 @@ namespace Diligent } explicit // Make this constructor explicit to avoid unintentional string copies - HashMapStringKey(const String &Str) : + HashMapStringKey(const String& Str) : StrPtr( nullptr ), Hash(0) { MakeCopy( Str.c_str() ); } - HashMapStringKey(HashMapStringKey &&Key)noexcept : - StringBuff( std::move(Key.StringBuff) ), - StrPtr( std::move(Key.StrPtr) ), - Hash(0) + HashMapStringKey(HashMapStringKey&& Key)noexcept : + StringBuff(std::move(Key.StringBuff)), + StrPtr (std::move(Key.StrPtr)), + Hash (0) { Key.StrPtr = nullptr; Key.Hash = 0; @@ -165,6 +165,14 @@ namespace Diligent return Hash; } + struct Hasher + { + size_t operator()( const HashMapStringKey &Key ) const + { + return Key.GetHash(); + } + }; + const Char* GetStr()const{ return StrPtr; } private: @@ -185,15 +193,3 @@ namespace Diligent mutable size_t Hash; }; } - -namespace std -{ - template<> - struct hash - { - size_t operator()( const Diligent::HashMapStringKey &Key ) const - { - return Key.GetHash(); - } - }; -} -- cgit v1.2.3