1///////////////////////////////////////////////////////////////////////////////
4// Copyright : (c) Andy Arvanitis 2015
7// Maintainer : Andy Arvanitis <andy.arvanitis@gmail.com>
8// Stability : experimental
11// Provides compile-time hashes for string literals.
13///////////////////////////////////////////////////////////////////////////////
22 // Hash function which uses an xor version of the djb2 algorithm
24 constexpr auto djb2(const char s[], const uint32_t hash = 5381) -> uint32_t {
25 return !s[0] ? hash : djb2(s + 1, 33 * hash ^ s[0]);
28 // Compile-time string literal hash
31 struct _compile_time_hash_ {
32 static constexpr long value = H;
36 constexpr long _compile_time_hash_<H>::value;
38 #define HASH(s) _compile_time_hash_<djb2(s)>::value
40} // namespace PureScript
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list