From e2ea281de10f7f75e1a14a73e1090026d7bf9dfc Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 16 May 2022 16:43:52 +0200 Subject: [PATCH] Fixes functions for getting underlying std map from StringViewDictionary --- src/Collections/StringViewDictionary.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Collections/StringViewDictionary.hpp b/src/Collections/StringViewDictionary.hpp index 101a9b3..6942ec7 100644 --- a/src/Collections/StringViewDictionary.hpp +++ b/src/Collections/StringViewDictionary.hpp @@ -11,13 +11,11 @@ namespace ArbUt { /// @brief Wrapper around unordered_map, allowing safer access and adding several helper methods. template class StringViewDictionary { private: - - struct StringViewHash - { + struct StringViewHash { using hash_type = std::hash; using is_transparent = void; - size_t operator()(const char* str) const { return hash_type{}(str); } + size_t operator()(const char* str) const { return hash_type{}(str); } size_t operator()(StringView const& str) const { return hash_type{}(str); } size_t operator()(u32 hash) const { return hash; } }; @@ -86,7 +84,6 @@ namespace ArbUt { /// @brief Gets a value from the dictionary using the direct hash of the key. [[nodiscard]] inline const ValueT& GetFromHash(u32 hash) const { return _map.find(hash)->second; } - /// @brief Try to get an item from the dictionary using a key. Returns false if no item is found, and out will /// not be touched in that case. inline std::optional> TryGet(const StringView& key) const noexcept { @@ -97,8 +94,8 @@ namespace ArbUt { return std::ref(find->second); } - /// @brief Try to get an item from the dictionary using the hash of a key. Returns false if no item is found, and out will - /// not be touched in that case. + /// @brief Try to get an item from the dictionary using the hash of a key. Returns false if no item is found, + /// and out will not be touched in that case. inline std::optional> TryGet(u32 hash) const noexcept { const auto& find = _map.find(hash); if (find == _map.end()) { @@ -132,9 +129,11 @@ namespace ArbUt { const_iterator end() const { return _map.end(); } /// @brief returns the backing unordered_map. - const std::unordered_map& GetStdMap() const noexcept { return _map; } + const std::unordered_map>& GetStdMap() const noexcept { + return _map; + } /// @brief returns the backing unordered_map. - std::unordered_map& GetStdMap() noexcept { return _map; } + std::unordered_map>& GetStdMap() noexcept { return _map; } }; }