48#ifndef DOXYGEN_SHOULD_SKIP_THIS
51#define _NODISCARD [[nodiscard]]
54#if defined(_WIN64) || defined(__x86_64__) || defined(__aarch64__)
55 inline constexpr size_t _FNV_offset_basis = 14695981039346656037ULL;
56 inline constexpr size_t _FNV_prime = 1099511628211ULL;
58 inline constexpr size_t _FNV_offset_basis = 2166136261U;
59 inline constexpr size_t _FNV_prime = 16777619U;
62 _NODISCARD
inline size_t _Fnv1a_append_bytes(
63 size_t _Val,
const unsigned char*
const _First,
64 const size_t _Count)
noexcept
67 for (
size_t _Idx = 0; _Idx < _Count; ++_Idx) {
68 _Val ^=
static_cast<size_t>(_First[_Idx]);
76 _NODISCARD
size_t _Fnv1a_append_value(
const size_t _Val,
77 const _Kty& _Keyval)
noexcept
79 static_assert(std::is_trivial_v<_Kty>,
80 "Only trivial types can be directly hashed.");
81 return _Fnv1a_append_bytes(
82 _Val, &
reinterpret_cast<const unsigned char&
>(_Keyval),
88 _NODISCARD
size_t _Hash_representation(
const _Kty& _Keyval)
noexcept
90 return _Fnv1a_append_value(_FNV_offset_basis, _Keyval);
94 template <
class _Kty>
struct Hash;
96 template <
class _Kty,
bool _Enabled>
struct _Conditionally_enabled_hash
98 using argument_type = _Kty;
99 using result_type = size_t;
103 operator()(
const _Kty& _Keyval)
const
104 noexcept(
noexcept(Hash<_Kty>::_Do_hash(_Keyval)))
106 return Hash<_Kty>::_Do_hash(_Keyval);
111 template <
class _Kty>
113 : _Conditionally_enabled_hash<
114 _Kty, !std::is_const_v<_Kty> && !std::is_volatile_v<_Kty> &&
115 (std::is_enum_v<_Kty> || std::is_integral_v<_Kty> ||
116 std::is_pointer_v<_Kty>)>
120 static size_t _Do_hash(
const _Kty& _Keyval)
noexcept
122 return _Hash_representation(_Keyval);
126 template <>
struct Hash<float>
128 using argument_type = float;
129 using result_type = size_t;
132 operator()(
const float _Keyval)
const noexcept
134 return _Hash_representation(
135 _Keyval == 0.0F ? 0.0F : _Keyval);
139 template <>
struct Hash<double>
141 using argument_type = double;
142 using result_type = size_t;
145 operator()(
const double _Keyval)
const noexcept
147 return _Hash_representation(
148 _Keyval == 0.0 ? 0.0 : _Keyval);
152 template <>
struct Hash<std::nullptr_t>
154 using argument_type = std::nullptr_t;
155 using result_type = size_t;
158 operator()(std::nullptr_t)
const noexcept
161 return _Hash_representation(_Null);
Definition: array2DWrapper.h:44