Fixes functions for getting underlying std map from StringViewDictionary
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
e0c16b772c
commit
e2ea281de1
|
@ -11,9 +11,7 @@ namespace ArbUt {
|
|||
/// @brief Wrapper around unordered_map, allowing safer access and adding several helper methods.
|
||||
template <class ValueT> class StringViewDictionary {
|
||||
private:
|
||||
|
||||
struct StringViewHash
|
||||
{
|
||||
struct StringViewHash {
|
||||
using hash_type = std::hash<StringView>;
|
||||
using is_transparent = void;
|
||||
|
||||
|
@ -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<std::reference_wrapper<const ValueT>> 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<std::reference_wrapper<const ValueT>> 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<StringView, ValueT>& GetStdMap() const noexcept { return _map; }
|
||||
const std::unordered_map<StringView, ValueT, StringViewHash, std::equal_to<>>& GetStdMap() const noexcept {
|
||||
return _map;
|
||||
}
|
||||
/// @brief returns the backing unordered_map.
|
||||
std::unordered_map<StringView, ValueT>& GetStdMap() noexcept { return _map; }
|
||||
std::unordered_map<StringView, ValueT, StringViewHash, std::equal_to<>>& GetStdMap() noexcept { return _map; }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue