From 27352e706ce3eb2babfc213b70518d920f7e850b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 3 May 2015 20:04:23 +0200 Subject: [PATCH] Ability to create ResourceKey directly from the hash. --- src/Magnum/Resource.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Resource.h b/src/Magnum/Resource.h index 01654d629..cd78b01ab 100644 --- a/src/Magnum/Resource.h +++ b/src/Magnum/Resource.h @@ -88,7 +88,10 @@ class ResourceKey: public Utility::MurmurHash2::Digest { * Creates zero key. Note that it is not the same as calling other * constructors with empty string. */ - constexpr ResourceKey() {} + constexpr /*implicit*/ ResourceKey() {} + + /** @brief Construct resource key directly from hashed value */ + explicit ResourceKey(std::size_t key): Utility::MurmurHash2::Digest{Utility::MurmurHash2::Digest::fromByteArray(reinterpret_cast(&key))} {} /** @brief Constructor */ ResourceKey(const std::string& key): Utility::MurmurHash2::Digest(Utility::MurmurHash2()(key)) {}