@@ -976,7 +976,10 @@ namespace hud
976976 {
977977 return find_impl (hud::forward<K>(key));
978978 }
979- return find_impl (key_type (key));
979+ else
980+ {
981+ return find_impl (key_type (hud::forward<K>(key)));
982+ }
980983 }
981984
982985 constexpr void rehash (i32 count) noexcept
@@ -1158,6 +1161,8 @@ namespace hud
11581161 /* *
11591162 * Finds or inserts a slot corresponding to the given key.
11601163 * If the key is not found, a new slot is created by constructing it with the key followed by `args`.
1164+ * If the `key_type` is not hashable with the `key_tuple_t` a temporary key is created to find it in the hashmap
1165+ * To make the `key_type` hashable with the `key_tuple_t` you must specialize the `hud::equal<key_type>` functor by adding the function
11611166 * @param key The key used to find or insert the slot.
11621167 * @param args The arguments forwarded to the `slot_type` constructor after the key.
11631168 * @return An iterator to the inserted or existing value.
@@ -1189,53 +1194,7 @@ namespace hud
11891194 return {control_ptr_ + res.first , slot_ptr};
11901195 }
11911196
1192- // template<typename key_tuple_t, typename value_tuple_t>
1193- // requires(hud::is_hashable_64_v<key_type, key_tuple_t> && hud::is_comparable_with_equal_v<key_type, key_tuple_t>)
1194- // constexpr iterator add(hud::tag_piecewise_construct_t, key_tuple_t &&key_tuple, value_tuple_t &&value_tuple) noexcept
1195- // {
1196- // hud::pair<usize, bool> res = find_or_insert_no_construct(hud::forward<key_tuple_t>(key_tuple));
1197- // slot_type *slot_ptr {slot_ptr_ + res.first};
1198- // if (res.second)
1199- // {
1200- // hud::memory::construct_object_at(slot_ptr, hud::tag_piecewise_construct, hud::forward<key_tuple_t>(key_tuple), hud::forward<value_tuple_t>(value_tuple));
1201- // }
1202- // return {control_ptr_ + res.first, slot_ptr};
1203- // }
1204-
1205- // template<typename key_tuple_t, typename value_tuple_t>
1206- // constexpr iterator add(hud::tag_piecewise_construct_t, key_tuple_t &&key_tuple, value_tuple_t &&value_tuple) noexcept
1207- // {
1208- // return add(hud::tag_piecewise_construct, hud::forward<key_tuple_t>(key_tuple), hud::forward<value_tuple_t>(value_tuple), hud::make_index_sequence<hud::tuple_size_v<key_tuple_t>> {});
1209- // }
1210-
12111197 private:
1212- // template<typename key_tuple_t, usize... indices_key, typename value_tuple_t>
1213- // constexpr iterator add(hud::tag_piecewise_construct_t, key_tuple_t &&key_tuple, value_tuple_t &&value_tuple, hud::index_sequence<indices_key...>) noexcept
1214- // {
1215- // key_type key(hud::get<indices_key>(key_tuple)...);
1216- // hud::pair<usize, bool> res = find_or_insert_no_construct(key);
1217- // slot_type *slot_ptr {slot_ptr_ + res.first};
1218- // if (res.second)
1219- // {
1220- // hud::memory::construct_object_at(slot_ptr, hud::tag_piecewise_construct, hud::forward<key_tuple_t>(key_tuple), hud::forward<value_tuple_t>(value_tuple));
1221- // }
1222- // return {control_ptr_ + res.first, slot_ptr};
1223- // }
1224-
1225- // template<typename key_tuple_t, usize... indices_key>
1226- // [[nodiscard]]
1227- // constexpr decltype(auto) forward_key(key_tuple_t &&key_tuple, hud::index_sequence<indices_key...>) noexcept
1228- // {
1229- // if constexpr (is_hashable_and_comparable<key_tuple_t>)
1230- // {
1231- // return hud::forward<key_tuple_t>(key_tuple);
1232- // }
1233- // else
1234- // {
1235- // return key_type(hud::get<indices_key>(key_tuple)...);
1236- // }
1237- // }
1238-
12391198 template <typename K>
12401199 [[nodiscard]]
12411200 constexpr iterator find_impl (K &&key) noexcept
@@ -1271,15 +1230,15 @@ namespace hud
12711230 }
12721231
12731232 template <typename K>
1274- [[nodiscard]] constexpr u64 compute_hash (const K &key) noexcept
1233+ [[nodiscard]] constexpr u64 compute_hash (K & &key) noexcept
12751234 {
12761235 if constexpr (hud::is_hashable_64_v<key_type, K>)
12771236 {
1278- return hasher_ (key);
1237+ return hasher_ (hud::forward<K>( key) );
12791238 }
12801239 else
12811240 {
1282- return hasher_ (key_type (key));
1241+ return hasher_ (key_type (hud::forward<K>( key) ));
12831242 }
12841243 }
12851244
@@ -1608,7 +1567,7 @@ namespace hud
16081567 }
16091568 else
16101569 {
1611- return find_or_insert_no_construct_impl (key_type (key));
1570+ return find_or_insert_no_construct_impl (key_type (hud::forward<K>( key) ));
16121571 }
16131572 }
16141573
@@ -1656,7 +1615,6 @@ namespace hud
16561615 [[nodiscard]] constexpr usize insert_no_construct (u64 h1, u8 h2) noexcept
16571616 {
16581617 // If we reach the load factor grow the table and retrieves the new slot, else use the given slot
1659- // TODO : check rehash_and_grow_if_necessary and implement the Squash DELETED branch
16601618 if (free_slot_before_grow () == 0 )
16611619 {
16621620 resize (next_capacity ());
0 commit comments