11 #include <string_view>
17 template<
typename K,
typename V>
23 consteval KVPair (K name, V val)
30 template<
size_t N,
typename V>
31 KVPair (
const char (&) [N], V) -> KVPair<std::string_view, V>;
42 res = (res << 8) + ch;
46 template<std::convertible_to<u
int64_t> K>
49 return static_cast<uint64_t
> (val);
57 template<
typename K,
typename V, auto Hasher = DefaultHash<K>>
60 const std::initializer_list<KVPair<K, V>> commandsList { commands... };
61 for (
auto i = commandsList.begin (); i != std::prev (commandsList.end ()); ++i)
62 for (
auto j = std::next (i); j != commandsList.end (); ++j)
63 if (Hasher (i->Key_) == Hasher (j->Key_))
64 throw "duplicate hashes";
66 return [=] (K key, V defValue = V {})
68 const auto keyHash = Hasher (key);
71 (void) ((Hasher (commands.Key_) == keyHash && (result = commands.Val_, foundKey = commands.Key_,
true)) || ...);
81 return MakeHash<std::string_view, V> (std::forward<decltype (commands)> (commands)...);