|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
constexpr-safe, compile-time hash algorithms for meta utilities. More...
Go to the source code of this file.
Namespaces | |
| namespace | jh::meta |
| Aggregated entry point for compile-time metaprogramming utilities. | |
Enumerations | |
| enum class | jh::meta::c_hash : std::uint8_t { jh::meta::fnv1a64 = 0 , jh::meta::fnv1_64 = 1 , jh::meta::djb2 = 2 , jh::meta::sdbm = 3 , jh::meta::murmur64 = 4 , jh::meta::xxhash64 = 5 } |
| Compile-time selectable hash algorithm tag (FNV, DJB2, SDBM, etc.). More... | |
Functions | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::fnv1a64 (const Char *data, const std::uint64_t size) noexcept |
| FNV-1a 64-bit hash implementation (default choice). | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::fnv1_64 (const Char *data, const std::uint64_t size) noexcept |
| FNV-1 64-bit hash (multiply before xor). | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::djb2 (const Char *str, const std::uint64_t size) noexcept |
| DJB2 hash (hash * 33 + c). | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::sdbm (const Char *str, const std::uint64_t size) noexcept |
| SDBM hash (used in several DB engines). | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::murmur64 (const Char *data, const std::uint64_t size) noexcept |
| constexpr MurmurHash-like 64-bit variant (seedless) | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::xxhash64 (const Char *data, std::uint64_t len) noexcept |
| constexpr xxHash-like 64-bit variant (seedless) | |
| template<any_char Char> | |
| constexpr std::uint64_t | jh::meta::hash (const c_hash algo, const Char *data, const std::uint64_t size) noexcept |
| Dispatch to selected hash algorithm based on c_hash. | |
constexpr-safe, compile-time hash algorithms for meta utilities.
Provides a minimal set of constexpr 64-bit hash functions usable in compile-time contexts, such as type reflection, lookup maps, or consteval identifiers. All implementations avoid heap and STL dependencies.
All hash functions accept any character type satisfying any_char, namely char, signed char, and unsigned char. These can be passed directly as const Char* without casting.
Other types, such as bool or std::byte, are not character types and must be explicitly converted via reinterpret_cast<const char*> if used for hashing. This restriction ensures semantic clarity and prevents accidental misuse of non-textual memory as string data in compile-time contexts.
For safe reinterpretation of POD objects or contiguous buffers, see jh::pod::bytes_view.