From a4e4527669ed1bae445802f197ecc9cd5bfcb7b5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 28 Jan 2026 17:26:57 +0000 Subject: [PATCH] Add type_list functionality to etl::tuple using etl::tuple_from_type_list --- include/etl/tuple.h | 16 +++++++++++++++- test/test_tuple.cpp | 11 +++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/etl/tuple.h b/include/etl/tuple.h index 2dd4971e..dbdbdaa2 100644 --- a/include/etl/tuple.h +++ b/include/etl/tuple.h @@ -132,7 +132,7 @@ namespace etl using value_type = void; ///< The type contained by this tuple. using this_type = tuple<>; ///< The type of this tuple. using base_type = void; ///< The type of the base tuple. - using type_list = etl::type_list<>; ///< The type list for this tuple. + using type_list = etl::type_list<>; ///< The type list for this tuple. using index_sequence_type = etl::make_index_sequence<0>; ///< The index_sequence type for this tuple. //********************************* @@ -1276,6 +1276,20 @@ namespace etl { lhs.swap(rhs); } + + //*************************************************************************** + /// Helper to turn etl::type_list into etl::tuple + template + struct tuple_from_type_list; + + template + struct tuple_from_type_list> + { + using type = etl::tuple; + }; + + template + using tuple_from_type_list_t = typename tuple_from_type_list::type; } namespace std diff --git a/test/test_tuple.cpp b/test/test_tuple.cpp index ec02bdaf..d84940d9 100644 --- a/test/test_tuple.cpp +++ b/test/test_tuple.cpp @@ -104,6 +104,17 @@ namespace CHECK_TRUE((std::is_same>::value)); } + //************************************************************************* + TEST(test_tuple_from_type_list) + { + using TypeList = etl::type_list; + using TupleFromTypeList = etl::tuple_from_type_list_t; + using Tuple = etl::tuple; + + CHECK_TRUE((std::is_same::value)); + CHECK_TRUE((std::is_same::value)); + } + //************************************************************************* TEST(test_tuple_type_list) {