From da3fd6d1f9a24f881ef09a170f998b471d054742 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 31 Jan 2019 08:26:41 -0800 Subject: Improved handling unordered_maps --- RenderScript/include/EnumMappings.h | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'RenderScript/include/EnumMappings.h') 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 #include "HashUtils.h" -#define DEFINE_ENUM_HASH(Type)\ -template<>struct hash \ -{ \ - size_t operator()( const Type &x ) const \ - { \ - return hash()(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 @@ -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 m_Val2StrMap; + std::unordered_map m_Str2ValMap; + std::unordered_map::type>> m_Val2StrMap; }; #define DEFINE_ENUM_ELEMENT_MAPPING(EnumMapping, Elem) EnumMapping.AddMapping(#Elem, Elem) -- cgit v1.2.3