diff --git a/include/etl/type_list.h b/include/etl/type_list.h index 293c9dc3..7d1cdd17 100644 --- a/include/etl/type_list.h +++ b/include/etl/type_list.h @@ -623,6 +623,29 @@ namespace etl inline constexpr bool type_list_is_unique_v = etl::type_list_is_unique::value; #endif + //*************************************************************************** + /// Check if the type_list is empty. + //*************************************************************************** + template + struct type_list_is_empty; + + template <> + struct type_list_is_empty> + : etl::true_type + { + }; + + template + struct type_list_is_empty> + : etl::false_type + { + }; + +#if ETL_USING_CPP17 + template + inline constexpr bool type_list_is_empty_v = type_list_is_empty::value; +#endif + //*************************************************************************** /// Checks that all types in a type_list satisfy a unary predicate. /// Predicate must be: template struct Pred : etl::bool_constant<...> {}; diff --git a/test/test_type_list.cpp b/test/test_type_list.cpp index 1953ef96..91d88f1a 100644 --- a/test/test_type_list.cpp +++ b/test/test_type_list.cpp @@ -714,17 +714,17 @@ namespace } //************************************************************************* - TEST(test_type_list_is_unique_for_non_empty_list) + TEST(test_type_list_is_empty) { - using list1 = etl::type_list; - using list2 = etl::type_list; + using list1 = etl::type_list<>; + using list2 = etl::type_list; - CHECK_TRUE((etl::type_list_is_unique::value)); - CHECK_FALSE((etl::type_list_is_unique::value)); + CHECK_TRUE((etl::type_list_is_empty::value)); + CHECK_FALSE((etl::type_list_is_empty::value)); #if ETL_USING_CPP17 - CHECK_TRUE((etl::type_list_is_unique_v)); - CHECK_FALSE((etl::type_list_is_unique_v)); + CHECK_TRUE((etl::type_list_is_empty_v)); + CHECK_FALSE((etl::type_list_is_empty_v)); #endif } }