diff --git a/src/core/include/mp-units/bits/type_list.h b/src/core/include/mp-units/bits/type_list.h index 636c1df1..f0e6817f 100644 --- a/src/core/include/mp-units/bits/type_list.h +++ b/src/core/include/mp-units/bits/type_list.h @@ -235,6 +235,28 @@ struct type_list_sort_impl, Pred> { template typename Pred> using type_list_sort = type_list_sort_impl::type; +// sort +template +struct type_list_unique_impl; + +template typename List> +struct type_list_unique_impl> { + using type = List<>; +}; + +template typename List, typename T, typename... Rest> +struct type_list_unique_impl> { + using type = type_list_push_front>::type, T>; +}; + +template typename List, typename T, typename... Rest> +struct type_list_unique_impl> { + using type = type_list_unique_impl>::type; +}; + +template +using type_list_unique = type_list_unique_impl::type; + } // namespace mp_units::detail MP_UNITS_DIAGNOSTIC_POP diff --git a/test/static/type_list_test.cpp b/test/static/type_list_test.cpp index 35af8b60..5db9afbb 100644 --- a/test/static/type_list_test.cpp +++ b/test/static/type_list_test.cpp @@ -189,4 +189,16 @@ static_assert(is_same_v, constant_less>, type_l static_assert(is_same_v, constant_less>, type_list>); static_assert(is_same_v, constant_less>, type_list>); +// type_list_unique + +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); +static_assert(is_same_v>, type_list>); + } // namespace