add switch case as string key
This commit is contained in:
@@ -68,4 +68,14 @@ namespace hack::utils
|
||||
{
|
||||
inline static T id = value;
|
||||
};
|
||||
|
||||
// this function can will use
|
||||
// as switch wiht string
|
||||
// switch(case_int("key"))
|
||||
// case case_int("test"): hack::log()("wow!");
|
||||
// case case_int("no_test"): hack::log()("wow!");
|
||||
inline constexpr std::uint32_t case_int(const char* str, std::uint32_t hash = 2166136261UL)
|
||||
{
|
||||
return *str ? case_int(str + 1, (hash ^ *str) * 16777619ULL) : hash;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user