Created
September 7, 2018 05:38
-
-
Save SammyJames/57e656d6c6c1d6d66cdf188935b96473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdint> | |
#include <cstdio> | |
constexpr uint32_t val_32_const = 0x811c9dc5; | |
constexpr uint32_t prime_32_const = 0x1000193; | |
inline constexpr uint32_t FNV1a(const char* const str, const uint32_t value = val_32_const) | |
{ | |
return (str[0] == '\0') ? value : FNV1a(&str[1], (value ^ uint32_t(str[0])) * prime_32_const); | |
} | |
template <uint32_t Hash> | |
constexpr uint32_t TForceEval = Hash; | |
#define HASH(text) TForceEval<FNV1a(text)> | |
void SetTexture(uint32_t test, void* param) | |
{ | |
printf("%u\n", test); | |
} | |
int main() | |
{ | |
SetTexture(HASH("Butts"), nullptr); | |
SetTexture(HASH("Rule"), nullptr); | |
SetTexture(HASH("The"), nullptr); | |
SetTexture(HASH("World"), nullptr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
asm = https://godbolt.org/z/Pf92MZ