Last active
August 29, 2015 14:21
-
-
Save elbeno/001da6c83c8876e1a9b7 to your computer and use it in GitHub Desktop.
constexpr __FILE__ hashing
This file contains hidden or 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 <iostream> | |
using namespace std; | |
constexpr unsigned long long fnv_hash64_r(unsigned long long result, const char* string) | |
{ | |
return (*string == 0) ? result : fnv_hash64_r(1099511628211ULL * result ^ *string, string + 1); | |
} | |
constexpr unsigned long long fnv_hash64(const char* string) | |
{ | |
return fnv_hash64_r(14695981039346656037ULL, string); | |
} | |
constexpr auto this_file = fnv_hash64(__FILE__); | |
int main(int argc, char** argv) | |
{ | |
cout << hex << this_file << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment