36 lines
637 B
C++
36 lines
637 B
C++
#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<>>;
|
|
|
|
}
|