@@ -362,13 +362,6 @@ namespace hud
362362 }
363363 };
364364
365- // template<usize count, typename... types_t, typename... u_types_t>
366- // struct tuple_assign<count, hud::tuple<types_t...>, hud::tuple<u_types_t...>>
367- // {
368- // using tuple_to_type = hud::tuple<types_t...>;
369- // using tuple_from_type = hud::tuple<u_types_t...>;
370- // };
371-
372365 /* * Swap tuple1_t and tuple2_t element at the index if element is swappable. */
373366 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 >>>
374367 struct swap_element
@@ -378,12 +371,12 @@ namespace hud
378371 static_assert (EvaluateIfInstanciate<hud::false_type>, " type_t is not swappable" );
379372 };
380373
381- template <usize type_index, typename ... types_t , typename ... u_types_t >
382- struct swap_element <type_index, hud::tuple< types_t ...>, hud::tuple< u_types_t ...> , true >
374+ template <usize type_index, typename tuple1_t , typename tuple2_t >
375+ struct swap_element <type_index, tuple1_t , tuple2_t , true >
383376 {
384- constexpr void operator ()(hud::tuple< types_t ...> &first, hud::tuple< u_types_t ...> &second) noexcept
377+ constexpr void operator ()(tuple1_t &first, tuple2_t &second) noexcept
385378 {
386- hud::swap (hud:: get<type_index>(first), hud:: get<type_index>(second));
379+ hud::swap (get<type_index>(first), get<type_index>(second));
387380 }
388381 };
389382
@@ -401,15 +394,15 @@ namespace hud
401394 * @param first The first tuple to swap
402395 * @param second The second tulpe to swap
403396 */
404- template <typename ... types_t , typename ... u_types_t >
405- constexpr void operator ()([[maybe_unused]] hud::tuple< types_t ...> &first, [[maybe_unused]] hud::tuple< u_types_t ...> &second) noexcept
397+ template <typename tuple1_t , typename tuple2_t >
398+ constexpr void operator ()([[maybe_unused]] tuple1_t &first, [[maybe_unused]] tuple2_t &second) noexcept
406399 {
407- static_assert (hud::tuple_size_v<hud::tuple< types_t ...>> == hud::tuple_size_v<hud::tuple< u_types_t ...> >, " Swapping tuples of different size is not supported" );
400+ static_assert (hud::tuple_size_v<tuple1_t > == hud::tuple_size_v<tuple2_t >, " Swapping tuples of different size is not supported" );
408401
409402 if constexpr (count > 0u )
410403 {
411- constexpr const usize index_to_swap = tuple_size_v<hud::tuple< types_t ...> > - count;
412- swap_element<index_to_swap, hud::tuple< types_t ...>, hud::tuple< u_types_t ...> >()(first, second);
404+ constexpr const usize index_to_swap = tuple_size_v<tuple1_t > - count;
405+ swap_element<index_to_swap, tuple1_t , tuple2_t >()(first, second);
413406 tuple_swap<count - 1u >()(first, second);
414407 }
415408 }
@@ -429,14 +422,14 @@ namespace hud
429422 * @param first The first tuple to compare
430423 * @param second The second tulpe to compare
431424 */
432- template <typename ... types_t , typename ... u_types_t >
433- [[nodiscard]] constexpr bool operator ()([[maybe_unused]] const hud::tuple< types_t ...> &first, [[maybe_unused]] const hud::tuple< u_types_t ...> &second) noexcept
425+ template <typename tuple1_t , typename tuple2_t >
426+ [[nodiscard]] constexpr bool operator ()([[maybe_unused]] const tuple1_t &first, [[maybe_unused]] const tuple2_t &second) noexcept
434427 {
435- static_assert (hud::tuple_size_v<hud::tuple< types_t ...>> == hud::tuple_size_v<hud::tuple< u_types_t ...> >, " Comparing tuples of different size is not supported" );
428+ static_assert (hud::tuple_size_v<tuple1_t > == hud::tuple_size_v<tuple2_t >, " Comparing tuples of different size is not supported" );
436429 if constexpr (count > 0u )
437430 {
438- constexpr const usize index_to_swap = tuple_size_v<hud::tuple< types_t ...> > - count;
439- return hud:: get<index_to_swap>(first) == hud:: get<index_to_swap>(second) && tuple_equals<count - 1u >()(first, second);
431+ constexpr const usize index_to_swap = tuple_size_v<tuple1_t > - count;
432+ return get<index_to_swap>(first) == get<index_to_swap>(second) && tuple_equals<count - 1u >()(first, second);
440433 }
441434 else
442435 {
@@ -459,18 +452,18 @@ namespace hud
459452 * @param first The first tuple to compare
460453 * @param second The second tulpe to compare
461454 */
462- template <typename ... types_t , typename ... u_types_t >
463- [[nodiscard]] constexpr bool operator ()([[maybe_unused]] const hud::tuple< types_t ...> &first, [[maybe_unused]] const hud::tuple< u_types_t ...> &second) noexcept
455+ template <typename tuple1_t , typename tuple2_t >
456+ [[nodiscard]] constexpr bool operator ()([[maybe_unused]] const tuple1_t &first, [[maybe_unused]] const tuple2_t &second) noexcept
464457 {
465- static_assert (hud::tuple_size_v<hud::tuple< types_t ...>> == hud::tuple_size_v<hud::tuple< u_types_t ...> >, " Comparing tuples of different size is not supported" );
458+ static_assert (hud::tuple_size_v<tuple1_t > == hud::tuple_size_v<tuple2_t >, " Comparing tuples of different size is not supported" );
466459 if constexpr (count > 0u )
467460 {
468- constexpr const usize index_to_swap = hud::tuple_size_v<hud::tuple< types_t ...> > - count;
469- if (hud:: get<index_to_swap>(first) < hud:: get<index_to_swap>(second))
461+ constexpr const usize index_to_swap = hud::tuple_size_v<tuple1_t > - count;
462+ if (get<index_to_swap>(first) < get<index_to_swap>(second))
470463 {
471464 return true ;
472465 }
473- if (hud:: get<index_to_swap>(second) < hud:: get<index_to_swap>(first))
466+ if (get<index_to_swap>(second) < get<index_to_swap>(first))
474467 {
475468 return false ;
476469 }
@@ -483,75 +476,72 @@ namespace hud
483476 }
484477 };
485478
486- template <typename ... tuples_t >
487- struct tuples_cat_impl
479+ /* *
480+ * Create a new tuple equivalent to all input tuples arguments inside a single tuple.
481+ * For exemple:
482+ * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
483+ * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
484+ */
485+ template <typename tuple_t , typename ... rest_t >
486+ struct cat_tuples_arg
488487 {
488+ using tuple_type = tuple_t ;
489+ };
489490
490- /* *
491- * Create a new tuple equivalent to all input tuples arguments inside a single tuple.
492- * For exemple:
493- * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
494- * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
495- */
496- template <typename tuple_t , typename ... rest_t >
497- struct cat_tuples_arg
498- {
499- using tuple_type = tuple_t ;
500- };
501-
502- template <typename ... args1_t , typename ... args2_t , typename ... rest_t >
503- struct cat_tuples_arg <hud::tuple<args1_t ...>, hud::tuple<args2_t ...>, rest_t ...>
504- {
505- using tuple_type = typename cat_tuples_arg<hud::tuple<args1_t ..., args2_t ...>, rest_t ...>::tuple_type;
506- };
507-
508- using return_type = typename cat_tuples_arg<tuples_t ...>::tuple_type;
509-
510- /* *
511- * Create an hud::index_sequence of the tuples_t... list element index.
512- * For exemple:
513- * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
514- * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
515- * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
516- */
517- template <typename element_indices_seq, typename ...>
518- struct cat_element_index
519- {
520- using element_index_seq = element_indices_seq;
521- };
491+ template <typename ... args1_t , typename ... args2_t , typename ... rest_t >
492+ struct cat_tuples_arg <hud::tuple<args1_t ...>, hud::tuple<args2_t ...>, rest_t ...>
493+ {
494+ using tuple_type = typename cat_tuples_arg<hud::tuple<args1_t ..., args2_t ...>, rest_t ...>::tuple_type;
495+ };
522496
523- template <usize... element_indices, typename ... args_t , typename ... rest_t >
524- struct cat_element_index <hud::index_sequence<element_indices...>, hud::tuple<args_t ...>, rest_t ...>
525- {
526- 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;
527- };
497+ /* *
498+ * Create an hud::index_sequence of the tuples_t... list element index.
499+ * For exemple:
500+ * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
501+ * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
502+ * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
503+ */
504+ template <typename element_indices_seq, typename ...>
505+ struct cat_element_index
506+ {
507+ using element_index_seq = element_indices_seq;
508+ };
528509
529- using element_index_seq = typename cat_element_index<hud::make_index_sequence_for<>, tuples_t ...>::element_index_seq;
510+ template <usize... element_indices, typename ... args_t , typename ... rest_t >
511+ struct cat_element_index <hud::index_sequence<element_indices...>, hud::tuple<args_t ...>, rest_t ...>
512+ {
513+ 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;
514+ };
530515
531- /* *
532- * Create a hud::index_sequence of the tuples_t... list index mask to match the element index hud::index_sequence.
533- * For exemple:
534- * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
535- * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
536- * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
537- * mask_index_seq is hud::index_sequence< 0,0, 1,1,1, 2,2>
538- */
539- template <usize mask_index, typename type_t >
540- static constexpr usize repeat_mask_index = mask_index;
516+ /* *
517+ * Create a hud::index_sequence of the tuples_t... list index mask to match the element index hud::index_sequence.
518+ * For exemple:
519+ * If tuples_t... is tuple<u32, f32>, tuple<char, wchar, char16>, tuple<u64, f64>
520+ * tuple_type is tuple<u32, f32, char, wchar, char16, u64 f64>
521+ * element_index_seq is hud::index_sequence< 0,1, 0,1,2, 0,1>
522+ * mask_index_seq is hud::index_sequence< 0,0, 1,1,1, 2,2>
523+ */
524+ template <usize mask_index, typename type_t >
525+ static constexpr usize repeat_mask_index = mask_index;
541526
542- template <usize tuple_index, typename mask_seq, typename ... rest_t >
543- struct cat_mask_index
544- {
545- using mask_index_seq = mask_seq;
546- static_assert (sizeof ...(rest_t ) == 0 , " Unsupported tuple_cat arguments." );
547- };
527+ template <usize tuple_index, typename mask_seq, typename ... rest_t >
528+ struct cat_mask_index
529+ {
530+ using mask_index_seq = mask_seq;
531+ static_assert (sizeof ...(rest_t ) == 0 , " Unsupported tuple_cat arguments." );
532+ };
548533
549- template <usize tuple_index, usize... mask_indices, typename ... args_t , typename ... rest_t >
550- struct cat_mask_index <tuple_index, hud::index_sequence<mask_indices...>, hud::tuple<args_t ...>, rest_t ...>
551- {
552- 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;
553- };
534+ template <usize tuple_index, usize... mask_indices, typename ... args_t , typename ... rest_t >
535+ struct cat_mask_index <tuple_index, hud::index_sequence<mask_indices...>, hud::tuple<args_t ...>, rest_t ...>
536+ {
537+ 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;
538+ };
554539
540+ template <typename ... tuples_t >
541+ struct tuples_cat_impl
542+ {
543+ using return_type = typename cat_tuples_arg<tuples_t ...>::tuple_type;
544+ using element_index_seq = typename cat_element_index<hud::make_index_sequence_for<>, tuples_t ...>::element_index_seq;
555545 using mask_index_seq = typename cat_mask_index<0 , hud::make_index_sequence_for<>, tuples_t ...>::mask_index_seq;
556546
557547 /* *
@@ -567,7 +557,7 @@ namespace hud
567557 template <typename tuple_t , usize... element_indices, usize... mask_indices>
568558 static HD_FORCEINLINE constexpr return_type concatenate (hud::index_sequence<element_indices...>, hud::index_sequence<mask_indices...>, tuple_t &&tuple) noexcept
569559 {
570- return return_type (hud:: get<element_indices>(hud:: get<mask_indices>(hud::forward<tuple>(tuple)))...);
560+ return return_type (get<element_indices>(get<mask_indices>(hud::forward<tuple>(tuple)))...);
571561 }
572562 };
573563
@@ -593,7 +583,6 @@ namespace hud
593583 template <typename ... tuples_t >
594584 struct tuple_cat
595585 {
596-
597586 using tuples_cat_impl_type = tuples_cat_impl<hud::decay_t <tuples_t >...>;
598587 using return_type = typename tuples_cat_impl_type::return_type;
599588 using element_index_seq = typename tuples_cat_impl_type::element_index_seq;
@@ -628,12 +617,12 @@ namespace hud
628617 * @param t The tuple whose elements are to be hashed.
629618 * @return The final combined hash value.
630619 */
631- template <typename Hasher, typename ... types_t >
632- [[nodiscard]] constexpr decltype (hud::declval<Hasher>().result()) operator()(Hasher &hasher, [[maybe_unused]] const hud::tuple< types_t ...> &t) noexcept
620+ template <typename Hasher, typename tuple_t >
621+ [[nodiscard]] constexpr decltype (hud::declval<Hasher>().result()) operator()(Hasher &hasher, [[maybe_unused]] const tuple_t &t) noexcept
633622 {
634623 if constexpr (count > 0u )
635624 {
636- constexpr const usize index_to_hash = tuple_size_v<hud::tuple< types_t ...> > - count;
625+ constexpr const usize index_to_hash = tuple_size_v<tuple_t > - count;
637626 hasher.hash (hud::get<index_to_hash>(t));
638627 return tuple_hash<count - 1u >()(hasher, t);
639628 }
0 commit comments