diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-01-31 16:26:41 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-01-31 16:26:41 +0000 |
| commit | da3fd6d1f9a24f881ef09a170f998b471d054742 (patch) | |
| tree | 48a27d8ed51d519388f42315ae50285cd19e01fe /RenderScript/include/EnumMappings.h | |
| parent | Updated HLSL2GLSLConverterApp (diff) | |
| download | DiligentTools-da3fd6d1f9a24f881ef09a170f998b471d054742.tar.gz DiligentTools-da3fd6d1f9a24f881ef09a170f998b471d054742.zip | |
Improved handling unordered_maps
Diffstat (limited to 'RenderScript/include/EnumMappings.h')
| -rw-r--r-- | RenderScript/include/EnumMappings.h | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/RenderScript/include/EnumMappings.h b/RenderScript/include/EnumMappings.h index 8bf71b3..7fae1c0 100644 --- a/RenderScript/include/EnumMappings.h +++ b/RenderScript/include/EnumMappings.h @@ -23,33 +23,9 @@ #pragma once +#include <unordered_map> #include "HashUtils.h" -#define DEFINE_ENUM_HASH(Type)\ -template<>struct hash<Type> \ -{ \ - size_t operator()( const Type &x ) const \ - { \ - return hash<int>()(x); \ - } \ -}; - -namespace std -{ - DEFINE_ENUM_HASH( Diligent::RESOURCE_DIMENSION ) - DEFINE_ENUM_HASH( Diligent::TEXTURE_FORMAT ) - DEFINE_ENUM_HASH( Diligent::VALUE_TYPE ) - DEFINE_ENUM_HASH( Diligent::USAGE ) - // Explicit namespace declaraion is necesseary to avoid - // name conflicts when building for windows store - DEFINE_ENUM_HASH( Diligent::BIND_FLAGS ) - DEFINE_ENUM_HASH( Diligent::CPU_ACCESS_FLAGS ) - DEFINE_ENUM_HASH( Diligent::COMPARISON_FUNCTION ) - DEFINE_ENUM_HASH( Diligent::BIND_SHADER_RESOURCES_FLAGS ) - DEFINE_ENUM_HASH( Diligent::SHADER_TYPE ) - DEFINE_ENUM_HASH( Diligent::RESOURCE_STATE_TRANSITION_MODE ) -} - namespace Diligent { template<typename EnumType> @@ -61,8 +37,8 @@ namespace Diligent m_Val2StrMap.insert( std::make_pair( Val, Str ) ); } - std::unordered_map< Diligent::HashMapStringKey, EnumType> m_Str2ValMap; - std::unordered_map<EnumType, String> m_Val2StrMap; + std::unordered_map<HashMapStringKey, EnumType, HashMapStringKey::Hasher> m_Str2ValMap; + std::unordered_map<EnumType, String, std::hash<typename std::underlying_type<EnumType>::type>> m_Val2StrMap; }; #define DEFINE_ENUM_ELEMENT_MAPPING(EnumMapping, Elem) EnumMapping.AddMapping(#Elem, Elem) |
