diff --git a/src/Magnum.h b/src/Magnum.h index a54c2467c..13eeb2b92 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -419,4 +419,11 @@ class Timeline; } +namespace std { + #ifndef DOXYGEN_GENERATING_OUTPUT + template struct hash; + #endif + template<> struct hash; +} + #endif diff --git a/src/Resource.h b/src/Resource.h index cf71f7998..888f2b6dd 100644 --- a/src/Resource.h +++ b/src/Resource.h @@ -277,6 +277,17 @@ template void Resource::acquire() { } +namespace std { + /** @brief `std::hash` specialization for @ref Magnum::ResourceKey */ + template<> struct hash { + #ifndef DOXYGEN_GENERATING_OUTPUT + std::size_t operator()(Magnum::ResourceKey key) const { + return *reinterpret_cast(key.byteArray()); + } + #endif + }; +} + /* Make the definition complete */ #include "ResourceManager.h" diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 0831ac727..acb3a1553 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -91,12 +91,6 @@ template class AbstractResourceLoader; namespace Implementation { -struct ResourceKeyHash { - std::size_t operator()(ResourceKey key) const { - return *reinterpret_cast(key.byteArray()); - } -}; - template class ResourceManagerData { template friend class Magnum::Resource; friend class AbstractResourceLoader; @@ -147,7 +141,7 @@ template class ResourceManagerData { void decrementReferenceCount(ResourceKey key); - std::unordered_map _data; + std::unordered_map _data; T* _fallback; AbstractResourceLoader* _loader; std::size_t _lastChange;