@@ -787,8 +787,13 @@ namespace hud
787787
788788 static_assert (hud::is_hashable_64_v<key_type>, " key_type is not hashable" );
789789 static_assert (hud::is_comparable_with_equal_v<key_type, key_type>, " key_type is not comparable with equal" );
790- template <typename K>
791- using key_arg_type = typename KeyArg<hud::is_hashable_64_v<K> && hud::is_comparable_with_equal_v<key_type, K>>::template type<K, key_type>;
790+
791+ /* *
792+ * HashableAndComparableArgType is used to select the type to be used by a fonction depending of the hashable and comparable possiblity.
793+ * If the type K est not hashable or comparable, the type is `key_type`, else the type is `K`
794+ */
795+ // template<typename K>
796+ // using HashableAndComparableArgType = typename KeyArg<hud::is_hashable_64_v<key_type, K> && hud::is_comparable_with_equal_v<key_type, K>>::template type<K, key_type>;
792797
793798 template <typename u_storage_t , typename u_hasher_t , typename u_key_equal_t , typename u_allocator_t >
794799 friend class hashset_impl ; // Friend with other hashset_impl of other types
@@ -1150,6 +1155,26 @@ namespace hud
11501155 return {control_ptr_ + res.first , slot_ptr};
11511156 }
11521157
1158+ /* *
1159+ * Finds or inserts a slot corresponding to the given key.
1160+ * If the key is not found, a new slot is created by constructing it with the key followed by `args`.
1161+ * @param key The key used to find or insert the slot.
1162+ * @param args The arguments forwarded to the `slot_type` constructor after the key.
1163+ * @return An iterator to the inserted or existing value.
1164+ */
1165+ // template<typename key_tuple_t, typename value_tuple_t>
1166+ // requires(hud::is_constructible_v<slot_type, key_type, args_t...>)
1167+ // constexpr iterator add(hud::tag_piecewise_construct_t, key_tuple_t key_tuple, value_tuple_t value_tuple) noexcept
1168+ // {
1169+ // hud::pair<usize, bool> res {find_or_insert_no_construct(key)};
1170+ // slot_type *slot_ptr {slot_ptr_ + res.first};
1171+ // if (res.second)
1172+ // {
1173+ // hud::memory::construct_object_at(slot_ptr, hud::move(key), hud::forward<args_t>(args)...);
1174+ // }
1175+ // return {control_ptr_ + res.first, slot_ptr};
1176+ // }
1177+
11531178 private:
11541179 template <typename K>
11551180 [[nodiscard]]
@@ -1188,7 +1213,7 @@ namespace hud
11881213 template <typename K>
11891214 [[nodiscard]] constexpr u64 compute_hash (const K &key) noexcept
11901215 {
1191- if constexpr (hud::is_same_v <key_type, K>)
1216+ if constexpr (hud::is_hashable_64_v <key_type, K>)
11921217 {
11931218 return hasher_ (key);
11941219 }
@@ -1510,12 +1535,24 @@ namespace hud
15101535 }
15111536 }
15121537
1538+ template <typename K>
1539+ [[nodiscard]]
1540+ constexpr hud::pair<usize, bool > find_or_insert_no_construct (K &&key) noexcept
1541+ {
1542+ if constexpr (hud::is_hashable_64_v<key_type, K> && hud::is_comparable_with_equal_v<key_type, K>)
1543+ {
1544+ return find_or_insert_no_construct_impl (hud::forward<K>(key));
1545+ }
1546+ return find_or_insert_no_construct_impl (key_type (key));
1547+ }
1548+
15131549 /* *
15141550 * Find the key and add the H2 hash in the control
15151551 * If the key is found, return the iterator
15161552 * If not found insert the key but do not construct the value.
15171553 */
1518- [[nodiscard]] constexpr hud::pair<usize, bool > find_or_insert_no_construct (const key_type &key) noexcept
1554+ template <typename K>
1555+ [[nodiscard]] constexpr hud::pair<usize, bool > find_or_insert_no_construct_impl (K &&key) noexcept
15191556 {
15201557 u64 hash {compute_hash (key)};
15211558 u64 h1 (H1 (hash));
0 commit comments