@@ -274,279 +274,68 @@ namespace hud
274274 constexpr compressed_tuple_impl (compressed_tuple_impl &&) = default;
275275 };
276276
277- // /** Swap tuple1_t and tuple2_t element at the index if element is swappable. */
278- // template<usize type_index, typename tuple1_t, typename tuple2_t, bool = hud::is_swappable_v<hud::tuple_element_t<type_index, tuple1_t>, hud::tuple_element_t<type_index, tuple2_t>>>
279- // struct swap_element
280- // {
281- // template<typename>
282- // static constexpr bool EvaluateIfInstanciate = false;
283- // static_assert(EvaluateIfInstanciate<hud::false_type>, "type_t is not swappable");
284- // };
285-
286- // template<usize type_index, typename... types_t, typename... u_types_t>
287- // struct swap_element<type_index, hud::compressed_tuple<types_t...>, hud::compressed_tuple<u_types_t...>, true>
288- // {
289- // constexpr void operator()(hud::compressed_tuple<types_t...> &first, hud::compressed_tuple<u_types_t...> &second) noexcept
290- // {
291- // hud::swap(hud::get<type_index>(first), hud::get<type_index>(second));
292- // }
293- // };
294-
295- /* *
296- * Recursively swap a compressed_tuple to another.
297- * @tparam count Number of element to swap
298- // */
299- // template<usize count>
300- // struct tuple_swap
301- // {
302-
303- // /**
304- // * Swap a 2 compressed_tuple elements.
305- // * @tparam types_t... List of types_t of the compressed_tuple first
306- // * @tparam u_types_t... List of types_t of the compressed_tuple second
307- // * @param first The first compressed_tuple to swap
308- // * @param second The second tulpe to swap
309- // */
310- // template<typename... types_t, typename... u_types_t>
311- // constexpr void operator()([[maybe_unused]] hud::compressed_tuple<types_t...> &first, [[maybe_unused]] hud::compressed_tuple<u_types_t...> &second) noexcept
312- // {
313- // static_assert(hud::tuple_size_v<hud::compressed_tuple<types_t...>> == hud::tuple_size_v<hud::compressed_tuple<u_types_t...>>, "Swapping tuples of different size is not supported");
314-
315- // if constexpr (count > 0u)
316- // {
317- // constexpr const usize index_to_swap = tuple_size_v<hud::compressed_tuple<types_t...>> - count;
318- // swap_element<index_to_swap, hud::compressed_tuple<types_t...>, hud::compressed_tuple<u_types_t...>>()(first, second);
319- // tuple_swap<count - 1u>()(first, second);
320- // }
321- // }
322- // };
277+ template <typename ... tuples_t >
278+ struct compressed_tuples_cat_impl
279+ : details::tuple::tuples_cat_impl<tuples_t ...>
280+ {
281+ // using return_type = typename compressed_cat_tuples_arg<tuples_t...>::tuple_type;
282+ // using element_index_seq = typename details::tuple::cat_element_index<hud::make_index_sequence_for<>, tuples_t...>::element_index_seq;
283+ // using mask_index_seq = typename details::tuple::cat_mask_index<0, hud::make_index_sequence_for<>, tuples_t...>::mask_index_seq;
284+
285+ // /**
286+ // * Constructs a tuple that is a concatenation of all tuples in the given "tuple of tulpes" in the same order.
287+ // * @tparam tuple The tuple type of tuples to concatenate
288+ // * @tparam element_indices List element index
289+ // * @tparam mask_indices List index mask to match the element index hud::index_sequence
290+ // * @param hud::index_sequence of element_indices
291+ // * @param hud::index_sequence of mask_indices
292+ // * @param tulpe The tuple of tulpes to concatenate
293+ // * @return The concatenated tuple
294+ // */
295+ // template<typename tuple_t, usize... element_indices, usize... mask_indices>
296+ // static HD_FORCEINLINE constexpr return_type concatenate(hud::index_sequence<element_indices...>, hud::index_sequence<mask_indices...>, tuple_t &&tuple) noexcept
297+ // {
298+ // return return_type(get<element_indices>(get<mask_indices>(hud::forward<tuple>(tuple)))...);
299+ // }
300+ };
323301
324- /* *
325- * Recursively compare a compressed_tuple to another.
326- * @tparam count Number of element to compare
327- */
328- // template<usize count>
329- // struct tuple_equals
330- // {
331- // /**
332- // * Compare a 2 compressed_tuple elements.
333- // * @tparam types_t... List of types_t of the compressed_tuple first
334- // * @tparam u_types_t... List of types_t of the compressed_tuple second
335- // * @param first The first compressed_tuple to compare
336- // * @param second The second tulpe to compare
337- // */
338- // template<typename... types_t, typename... u_types_t>
339- // [[nodiscard]] constexpr bool operator()([[maybe_unused]] const hud::compressed_tuple<types_t...> &first, [[maybe_unused]] const hud::compressed_tuple<u_types_t...> &second) noexcept
340- // {
341- // static_assert(hud::tuple_size_v<hud::compressed_tuple<types_t...>> == hud::tuple_size_v<hud::compressed_tuple<u_types_t...>>, "Comparing tuples of different size is not supported");
342- // if constexpr (count > 0u)
343- // {
344- // constexpr const usize index_to_swap = tuple_size_v<hud::compressed_tuple<types_t...>> - count;
345- // return hud::get<index_to_swap>(first) == hud::get<index_to_swap>(second) && tuple_equals<count - 1u>()(first, second);
346- // }
347- // else
348- // {
349- // return true;
350- // }
351- // }
352- // };
302+ template <>
303+ struct compressed_tuples_cat_impl <>
304+ {
305+ using return_type = hud::compressed_tuple<>;
306+ using element_index_seq = hud::index_sequence<>;
307+ using mask_index_seq = hud::index_sequence<>;
353308
354- /* *
355- * Recursively compare a compressed_tuple to another with operator<.
356- * @tparam count Number of element to compare
357- */
358- // template<usize count>
359- // struct tuple_less
360- // {
361- // /**
362- // * Compare a 2 compressed_tuple elements with operator<.
363- // * @tparam types_t... List of types_t of the compressed_tuple first
364- // * @tparam u_types_t... List of types_t of the compressed_tuple second
365- // * @param first The first compressed_tuple to compare
366- // * @param second The second tulpe to compare
367- // */
368- // template<typename... types_t, typename... u_types_t>
369- // [[nodiscard]] constexpr bool operator()([[maybe_unused]] const hud::compressed_tuple<types_t...> &first, [[maybe_unused]] const hud::compressed_tuple<u_types_t...> &second) noexcept
370- // {
371- // static_assert(hud::tuple_size_v<hud::compressed_tuple<types_t...>> == hud::tuple_size_v<hud::compressed_tuple<u_types_t...>>, "Comparing tuples of different size is not supported");
372- // if constexpr (count > 0u)
373- // {
374- // constexpr const usize index_to_swap = hud::tuple_size_v<hud::compressed_tuple<types_t...>> - count;
375- // if (hud::get<index_to_swap>(first) < hud::get<index_to_swap>(second))
376- // {
377- // return true;
378- // }
379- // if (hud::get<index_to_swap>(second) < hud::get<index_to_swap>(first))
380- // {
381- // return false;
382- // }
383- // return tuple_less<count - 1u>()(first, second);
384- // }
385- // else
386- // {
387- // return false;
388- // }
389- // }
390- // };
391-
392- // template<typename... tuples_t>
393- // struct tuples_cat_impl
394- // {
395-
396- // /**
397- // * Create a new compressed_tuple equivalent to all input tuples arguments inside a single compressed_tuple.
398- // * For exemple:
399- // * If tuples_t... is compressed_tuple<u32, f32>, compressed_tuple<char, wchar, char16>, compressed_tuple<u64, f64>
400- // * tuple_type is compressed_tuple<u32, f32, char, wchar, char16, u64 f64>
401- // */
402- // template<typename tuple_t, typename... rest_t>
403- // struct cat_tuples_arg
404- // {
405- // using tuple_type = tuple_t;
406- // };
407-
408- // template<typename... args1_t, typename... args2_t, typename... rest_t>
409- // struct cat_tuples_arg<hud::compressed_tuple<args1_t...>, hud::compressed_tuple<args2_t...>, rest_t...>
410- // {
411- // using tuple_type = typename cat_tuples_arg<hud::compressed_tuple<args1_t..., args2_t...>, rest_t...>::tuple_type;
412- // };
413-
414- // using return_type = typename cat_tuples_arg<tuples_t...>::tuple_type;
415-
416- // /**
417- // * Create an hud::index_sequence of the tuples_t... list element index.
418- // * For exemple:
419- // * If tuples_t... is compressed_tuple<u32, f32>, compressed_tuple<char, wchar, char16>, compressed_tuple<u64, f64>
420- // * tuple_type is compressed_tuple<u32, f32, char, wchar, char16, u64 f64>
421- // * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
422- // */
423- // template<typename element_indices_seq, typename...>
424- // struct cat_element_index
425- // {
426- // using element_index_seq = element_indices_seq;
427- // };
428-
429- // template<usize... element_indices, typename... args_t, typename... rest_t>
430- // struct cat_element_index<hud::index_sequence<element_indices...>, hud::compressed_tuple<args_t...>, rest_t...>
431- // {
432- // using element_index_seq = typename cat_element_index<cat_integer_sequence_t<hud::index_sequence<element_indices...>, hud::make_index_sequence_for<args_t...>>, rest_t...>::element_index_seq;
433- // };
434-
435- // using element_index_seq = typename cat_element_index<hud::make_index_sequence_for<>, tuples_t...>::element_index_seq;
436-
437- // /**
438- // * Create a hud::index_sequence of the tuples_t... list index mask to match the element index hud::index_sequence.
439- // * For exemple:
440- // * If tuples_t... is compressed_tuple<u32, f32>, compressed_tuple<char, wchar, char16>, compressed_tuple<u64, f64>
441- // * tuple_type is compressed_tuple<u32, f32, char, wchar, char16, u64 f64>
442- // * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
443- // * mask_index_seq is hud::index_sequence< 0,0, 1,1,1, 2,2>
444- // */
445- // template<usize mask_index, typename type_t>
446- // static constexpr usize repeat_mask_index = mask_index;
447-
448- // template<usize tuple_index, typename mask_seq, typename... rest_t>
449- // struct cat_mask_index
450- // {
451- // using mask_index_seq = mask_seq;
452- // static_assert(sizeof...(rest_t) == 0, "Unsupported tuple_cat arguments.");
453- // };
454-
455- // template<usize tuple_index, usize... mask_indices, typename... args_t, typename... rest_t>
456- // struct cat_mask_index<tuple_index, hud::index_sequence<mask_indices...>, hud::compressed_tuple<args_t...>, rest_t...>
457- // {
458- // using mask_index_seq = typename cat_mask_index<tuple_index + 1u, cat_integer_sequence_t<hud::index_sequence<mask_indices...>, hud::index_sequence<repeat_mask_index<tuple_index, args_t>...>>, rest_t...>::mask_index_seq;
459- // };
460-
461- // using mask_index_seq = typename cat_mask_index<0, hud::make_index_sequence_for<>, tuples_t...>::mask_index_seq;
462-
463- // /**
464- // * Constructs a compressed_tuple that is a concatenation of all tuples in the given "compressed_tuple of tulpes" in the same order.
465- // * @tparam compressed_tuple The compressed_tuple type of tuples to concatenate
466- // * @tparam element_indices List element index
467- // * @tparam mask_indices List index mask to match the element index hud::index_sequence
468- // * @param hud::index_sequence of element_indices
469- // * @param hud::index_sequence of mask_indices
470- // * @param tulpe The compressed_tuple of tulpes to concatenate
471- // * @return The concatenated compressed_tuple
472- // */
473- // template<typename tuple_t, usize... element_indices, usize... mask_indices>
474- // static HD_FORCEINLINE constexpr return_type concatenate(hud::index_sequence<element_indices...>, hud::index_sequence<mask_indices...>, tuple_t &&compressed_tuple) noexcept
475- // {
476- // return return_type(hud::get<element_indices>(hud::get<mask_indices>(hud::forward<hud::compressed_tuple>(compressed_tuple)))...);
477- // }
478- // };
479-
480- // template<>
481- // struct tuples_cat_impl<>
482- // {
483- // using return_type = hud::compressed_tuple<>;
484- // using element_index_seq = hud::index_sequence<>;
485- // using mask_index_seq = hud::index_sequence<>;
486-
487- // /**
488- // * Constructs an empty compressed_tuple
489- // * @param tulpe The compressed_tuple of tulpes to concatenate
490- // * @return The concatenated compressed_tuple
491- // */
492- // template<typename EmptyTuple, usize... element_indices, usize... mask_indices>
493- // static HD_FORCEINLINE constexpr EmptyTuple concatenate(hud::index_sequence<element_indices...>, hud::index_sequence<mask_indices...>, EmptyTuple &&) noexcept
494- // {
495- // return EmptyTuple();
496- // }
497- // };
498-
499- // template<typename... tuples_t>
500- // struct tuple_cat
501- // {
502-
503- // using tuples_cat_impl_type = tuples_cat_impl<hud::decay_t<tuples_t>...>;
504- // using return_type = typename tuples_cat_impl_type::return_type;
505- // using element_index_seq = typename tuples_cat_impl_type::element_index_seq;
506- // using mask_index_seq = typename tuples_cat_impl_type::mask_index_seq;
507-
508- // /**
509- // * Constructs a compressed_tuple that is a concatenation of all tuples in the given "compressed_tuple of tulpes" in the same order.
510- // * @tparam compressed_tuple The compressed_tuple type of tuples to concatenate
511- // * @param tulpe The compressed_tuple of tulpes to concatenate
512- // * @return The concatenated compressed_tuple
513- // */
514- // template<typename tuple_t>
515- // static HD_FORCEINLINE constexpr return_type concatenate(tuple_t &&compressed_tuple) noexcept
516- // {
517- // return tuples_cat_impl_type::concatenate(element_index_seq(), mask_index_seq(), hud::forward<tuple_t>(compressed_tuple));
518- // }
519- // };
309+ /* *
310+ * Constructs an empty tuple
311+ * @param tulpe The tuple of tulpes to concatenate
312+ * @return The concatenated tuple
313+ */
314+ template <typename EmptyTuple, usize... element_indices, usize... mask_indices>
315+ static HD_FORCEINLINE constexpr EmptyTuple concatenate (hud::index_sequence<element_indices...>, hud::index_sequence<mask_indices...>, EmptyTuple &&) noexcept
316+ {
317+ return EmptyTuple ();
318+ }
319+ };
520320
521- /* *
522- * Hashes all elements of a compressed_tuple and combines them into a single hash value.
523- * This is a recursive template that processes one element per call.
524- * @tparam count Number of elements remaining to hash.
525- */
526- template <usize count>
527- struct tuple_hash
321+ template <typename ... tuples_t >
322+ struct compressed_tuple_cat
528323 {
324+ using tuples_cat_impl_type = compressed_tuples_cat_impl<hud::decay_t <tuples_t >...>;
325+ using return_type = typename tuples_cat_impl_type::return_type;
326+ using element_index_seq = typename tuples_cat_impl_type::element_index_seq;
327+ using mask_index_seq = typename tuples_cat_impl_type::mask_index_seq;
328+
529329 /* *
530- * Hashes the elements of the given compressed_tuple recursively, starting from the first unprocessed element.
531- * @tparam Hasher Type of the hasher used.
532- * @tparam types_t Types of the compressed_tuple elements.
533- * @param hasher The hasher instance used to compute the hash.
534- * @param t The compressed_tuple whose elements are to be hashed.
535- * @return The final combined hash value.
330+ * Constructs a tuple that is a concatenation of all tuples in the given "tuple of tulpes" in the same order.
331+ * @tparam tuple The tuple type of tuples to concatenate
332+ * @param tulpe The tuple of tulpes to concatenate
333+ * @return The concatenated tuple
536334 */
537- template <typename Hasher, typename ... types_t >
538- [[nodiscard]] constexpr decltype (hud::declval<Hasher>().result()) operator()(Hasher &hasher, [[maybe_unused]] const hud::compressed_tuple< types_t ...> &t ) noexcept
335+ template <typename tuple_t >
336+ static HD_FORCEINLINE constexpr return_type concatenate ( tuple_t &&tuple ) noexcept
539337 {
540- if constexpr (count > 0u )
541- {
542- constexpr const usize index_to_hash = tuple_size_v<hud::compressed_tuple<types_t ...>> - count;
543- hasher.hash (hud::get<index_to_hash>(t));
544- return tuple_hash<count - 1u >()(hasher, t);
545- }
546- else
547- {
548- return hasher.result ();
549- }
338+ return tuples_cat_impl_type::concatenate (element_index_seq (), mask_index_seq (), hud::forward<tuple_t >(tuple));
550339 }
551340 };
552341
@@ -1042,17 +831,17 @@ namespace hud
1042831 }
1043832
1044833 /* *
1045- * Constructs a compressed_tuple that is a concatenation of all tuples in args in the same order.
1046- * @tparam tuples_t All compressed_tuple types
1047- * @param args Zero or more compressed_tuple to concatenate
1048- * @return The concatenated compressed_tuple
834+ * Constructs a tuple that is a concatenation of all tuples in args in the same order.
835+ * @tparam tuples_t All tuple types
836+ * @param args Zero or more tuple to concatenate
837+ * @return The concatenated tuple
1049838 */
1050- // template<typename... tuples_t>
1051- // constexpr typename details::tuple::tuple_cat <tuples_t...>::return_type tuple_cat (tuples_t &&...args) noexcept
1052- // {
1053- // using tuple_cat_result = details::tuple::tuple_cat <tuples_t...>;
1054- // return tuple_cat_result ::concatenate(forward_as_tuple(hud::forward<tuples_t>(args)...));
1055- // }
839+ template <typename ... tuples_t >
840+ constexpr typename details::compressed_tuple::compressed_tuple_cat <tuples_t ...>::return_type compressed_tuple_cat (tuples_t &&...args) noexcept
841+ {
842+ using compressed_tuple_cat_result = details::compressed_tuple::compressed_tuple_cat <tuples_t ...>;
843+ return compressed_tuple_cat_result ::concatenate (forward_as_tuple (hud::forward<tuples_t >(args)...));
844+ }
1056845
1057846 template <typename ... types_t >
1058847 struct equal <hud::compressed_tuple<types_t ...>>
@@ -1070,7 +859,7 @@ namespace hud
1070859 [[nodiscard]] constexpr u32 operator ()(const hud::compressed_tuple<types_t ...> &t) const noexcept
1071860 {
1072861 hasher_32 hasher;
1073- return details::compressed_tuple ::tuple_hash<sizeof ...(types_t )> {}(hasher, t);
862+ return details::tuple ::tuple_hash<sizeof ...(types_t )> {}(hasher, t);
1074863 }
1075864 };
1076865
@@ -1080,7 +869,7 @@ namespace hud
1080869 [[nodiscard]] constexpr u64 operator ()(const hud::compressed_tuple<types_t ...> &t) const noexcept
1081870 {
1082871 hasher_64 hasher;
1083- return details::compressed_tuple ::tuple_hash<sizeof ...(types_t )> {}(hasher, t);
872+ return details::tuple ::tuple_hash<sizeof ...(types_t )> {}(hasher, t);
1084873 }
1085874 };
1086875
0 commit comments