fixes
This commit is contained in:
35
include/util/string_lookup.hpp
Normal file
35
include/util/string_lookup.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace ztu
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct string_hash
|
||||
{
|
||||
using is_transparent = void;
|
||||
using hash_type = std::hash<std::string_view>;
|
||||
|
||||
[[nodiscard]] std::size_t operator()(const char *txt) const
|
||||
{
|
||||
return hash_type{}(txt);
|
||||
}
|
||||
[[nodiscard]] std::size_t operator()(std::string_view txt) const
|
||||
{
|
||||
return hash_type{}(txt);
|
||||
}
|
||||
[[nodiscard]] std::size_t operator()(const std::string &txt) const
|
||||
{
|
||||
return hash_type{}(txt);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
using string_lookup = std::unordered_map<std::string, T, detail::string_hash, std::equal_to<>>;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user