#ifndef CORE_HPPASH_CODE_HPP #define CORE_HPPASH_CODE_HPP #include #include "core/utils/Types.hpp" namespace Core { template inline u64 hashCode(const H& key) { return key.hashCode(); } template inline u64 hashNumber(T t) { static_assert(sizeof(t) <= 8); return static_cast(t); } inline u64 hashCode(char key) { return hashNumber(key); } inline u64 hashCode(signed char key) { return hashNumber(key); } inline u64 hashCode(signed short key) { return hashNumber(key); } inline u64 hashCode(signed int key) { return hashNumber(key); } inline u64 hashCode(signed long key) { return hashNumber(key); } inline u64 hashCode(signed long long key) { return hashNumber(key); } inline u64 hashCode(unsigned char key) { return hashNumber(key); } inline u64 hashCode(unsigned short key) { return hashNumber(key); } inline u64 hashCode(unsigned int key) { return hashNumber(key); } inline u64 hashCode(unsigned long key) { return hashNumber(key); } inline u64 hashCode(unsigned long long key) { return hashNumber(key); } template inline consteval T emptyValue() { if constexpr(Core::IsSame) { return CHAR_MAX; } else if constexpr(Core::IsSame) { return SCHAR_MAX; } else if constexpr(Core::IsSame) { return SHRT_MAX; } else if constexpr(Core::IsSame) { return INT_MAX; } else if constexpr(Core::IsSame) { return LONG_MAX; } else if constexpr(Core::IsSame) { return LLONG_MAX; } else if constexpr(Core::IsSame) { return UCHAR_MAX; } else if constexpr(Core::IsSame) { return USHRT_MAX; } else if constexpr(Core::IsSame) { return UINT_MAX; } else if constexpr(Core::IsSame) { return ULONG_MAX; } else if constexpr(Core::IsSame) { return ULLONG_MAX; } else { return T::emptyValue(); } } } #endif