mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Add type_list functionality to etl::tuple using etl::tuple_from_type_list
This commit is contained in:
parent
a669d1f46e
commit
a4e4527669
@ -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<TTypes...> into etl::tuple<TTypes...>
|
||||
template <typename TList>
|
||||
struct tuple_from_type_list;
|
||||
|
||||
template <typename... TTypes>
|
||||
struct tuple_from_type_list<etl::type_list<TTypes...>>
|
||||
{
|
||||
using type = etl::tuple<TTypes...>;
|
||||
};
|
||||
|
||||
template <typename TTypeList>
|
||||
using tuple_from_type_list_t = typename tuple_from_type_list<TTypeList>::type;
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
@ -104,6 +104,17 @@ namespace
|
||||
CHECK_TRUE((std::is_same<Data, etl::tuple_element_t<3, Tuple>>::value));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_tuple_from_type_list)
|
||||
{
|
||||
using TypeList = etl::type_list<int, double, int, Data>;
|
||||
using TupleFromTypeList = etl::tuple_from_type_list_t<TypeList>;
|
||||
using Tuple = etl::tuple<int, double, int, Data>;
|
||||
|
||||
CHECK_TRUE((std::is_same<Tuple, TupleFromTypeList>::value));
|
||||
CHECK_TRUE((std::is_same<TypeList, TupleFromTypeList::type_list>::value));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_tuple_type_list)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user