35 template <
typename DERIVED>
61 template <
typename TYPE>
76 static u_integer hashFuncImpl(
const T&
t)
noexcept;
114 template <
typename T,
typename...
Rest>
125 template <
typename T>
139 template <HashTraits T>
148 template<std::
integral T>
157 template <
typename T>
219 template <
typename DERIVED>
270 std::size_t operator()(
const T& t)
const noexcept;
273template<
typename TYPE>
279template<
typename TYPE>
282 if constexpr (std::is_trivially_copyable_v<T>) {
284 std::memcpy(
buffer, &
t,
sizeof(T));
285 return fnv1a(
buffer,
sizeof(T));
287 return static_cast<u_integer
>(
reinterpret_cast<uintptr_t
>(&t));
291template<
typename TYPE>
296 hash *= FNV_32_PRIME;
301template<
typename TYPE>
302template<
typename T,
typename...
Rest>
304 hashCombine(
seed, value);
308template<
typename TYPE>
311 return hashFuncImpl(
t);
314template <
typename TYPE>
315template <original::HashTraits T>
320template<
typename TYPE>
325template<
typename TYPE>
326template<std::
integral T>
331template<
typename TYPE>
334 return static_cast<u_integer
>(
reinterpret_cast<uintptr_t
>(t));
337template<
typename TYPE>
342template<
typename TYPE>
344 if (
str ==
nullptr)
return 0;
345 return fnv1a(
reinterpret_cast<const byte*
>(
str), std::strlen(
str));
348template<
typename TYPE>
350 return fnv1a(
reinterpret_cast<const byte*
>(
str.data()),
str.size());
353template<
typename TYPE>
358template <
typename DERIVED>
363template<
typename DERIVED>
368template <
typename DERIVED>
371template <original::HashTraits T>
372std::size_t std::hash<T>::operator()(
const T& t)
const noexcept {
373 return static_cast<std::size_t
>(t.toHash());
u_integer toHash() const noexcept override
Compute hash value for the pointer.
Definition autoPtr.h:735
Generic hash function object supporting multiple types.
Definition hash.h:62
static u_integer hashFunc(const T &t) noexcept
Default hash function fallback.
static void hashCombine(u_integer &seed, const T &value, const Rest &... rest) noexcept
Combines multiple hash values into one.
Definition hash.h:303
static u_integer hashFunc(const std::nullptr_t &null) noexcept
Hash function for nullptr.
Definition hash.h:321
static u_integer hashFunc(T *const &t) noexcept
Hash function for pointers.
static void hashCombine(u_integer &seed, const T &value) noexcept
Combines a hash value with another value's hash.
Definition hash.h:275
u_integer operator()(const TYPE &t) const noexcept
Hash function object call operator.
Definition hash.h:354
static u_integer hashFunc(const char &t) noexcept
Hash function for single character.
Definition hash.h:338
static u_integer hashFunc(const char *str) noexcept
Hash function for C-style strings.
Definition hash.h:343
static u_integer hashFunc(const std::string &str) noexcept
Hash function for std::string.
Definition hash.h:349
static constexpr u_integer FNV_OFFSET_BASIS
FNV-1a initial offset value (0x811C9DC5)
Definition hash.h:83
static constexpr u_integer FNV_32_PRIME
FNV-1a prime multiplier (0x01000193)
Definition hash.h:86
static u_integer fnv1a(const byte *data, u_integer size) noexcept
FNV-1a hash implementation for raw byte data.
Definition hash.h:292
Forward declaration of hashable interface template.
Definition hash.h:220
virtual bool equals(const DERIVED &other) const noexcept
Compares two objects for equality.
Definition hash.h:364
virtual ~hashable()=0
Virtual destructor.
virtual u_integer toHash() const noexcept
Computes the hash of the object.
Definition hash.h:359
A placeholder type representing the absence of a value.
Definition types.h:33
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Requires type to implement the hashable interface with toHash method.
Definition types.h:311
Platform-independent type definitions and compiler/platform detection.
Main namespace for the project Original.
Definition algorithms.h:21
Standard namespace extensions for original::alternative.
Definition allocator.h:351
Core type system foundations and concept definitions.