diff --git a/src/core/include/mp-units/bits/type_list.h b/src/core/include/mp-units/bits/type_list.h index 0f27c413..a15a673c 100644 --- a/src/core/include/mp-units/bits/type_list.h +++ b/src/core/include/mp-units/bits/type_list.h @@ -33,9 +33,7 @@ MP_UNITS_DIAGNOSTIC_PUSH MP_UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF -namespace mp_units { - -namespace detail { +namespace mp_units::detail { template inline constexpr bool is_type_list = false; @@ -43,31 +41,20 @@ inline constexpr bool is_type_list = false; template typename T, typename... Types> inline constexpr bool is_type_list> = true; -} // namespace detail - template -concept TypeList = detail::is_type_list; +concept TypeList = is_type_list; // size - -namespace detail { - template struct type_list_size_impl; template typename List, typename... Types> struct type_list_size_impl> : std::integral_constant {}; -} // namespace detail - template -inline constexpr std::size_t type_list_size = detail::type_list_size_impl::value; - +inline constexpr std::size_t type_list_size = type_list_size_impl::value; // map - -namespace detail { - template typename To> struct type_list_map_impl; @@ -76,16 +63,11 @@ struct type_list_map_impl, To> { using type = To; }; -} // namespace detail - template typename To> -using type_list_map = MP_UNITS_TYPENAME detail::type_list_map_impl::type; +using type_list_map = MP_UNITS_TYPENAME type_list_map_impl::type; // element - -namespace detail { - template struct type_list_leaf { using type = T; @@ -100,22 +82,16 @@ struct indexed_type_list_impl, Ts...> : type_list_lea template std::type_identity type_list_element_func(const type_list_leaf&); -} // namespace detail - template -struct indexed_type_list : detail::indexed_type_list_impl, Ts...> {}; +struct indexed_type_list : indexed_type_list_impl, Ts...> {}; template -using type_list_element_indexed = typename decltype(detail::type_list_element_func(std::declval()))::type; +using type_list_element_indexed = typename decltype(type_list_element_func(std::declval()))::type; template using type_list_element = type_list_element_indexed, I>; - // front - -namespace detail { - template struct type_list_front_impl; @@ -124,22 +100,14 @@ struct type_list_front_impl> { using type = T; }; -} // namespace detail - template -using type_list_front = MP_UNITS_TYPENAME detail::type_list_front_impl::type; - +using type_list_front = MP_UNITS_TYPENAME type_list_front_impl::type; // back - template using type_list_back = type_list_element - 1>; - // push_front - -namespace detail { - template struct type_list_push_front_impl; @@ -148,16 +116,10 @@ struct type_list_push_front_impl, NewTypes...> { using type = List; }; -} // namespace detail - template -using type_list_push_front = MP_UNITS_TYPENAME detail::type_list_push_front_impl::type; - +using type_list_push_front = MP_UNITS_TYPENAME type_list_push_front_impl::type; // push_back - -namespace detail { - template struct type_list_push_back_impl; @@ -166,16 +128,10 @@ struct type_list_push_back_impl, NewTypes...> { using type = List; }; -} // namespace detail - template -using type_list_push_back = MP_UNITS_TYPENAME detail::type_list_push_back_impl::type; - +using type_list_push_back = MP_UNITS_TYPENAME type_list_push_back_impl::type; // join - -namespace detail { - template struct type_list_join_impl { using type = List; @@ -186,16 +142,10 @@ struct type_list_join_impl, List, Rest...> { using type = MP_UNITS_TYPENAME type_list_join_impl, Rest...>::type; }; -} // namespace detail - template -using type_list_join = MP_UNITS_TYPENAME detail::type_list_join_impl::type; - +using type_list_join = MP_UNITS_TYPENAME type_list_join_impl::type; // split - -namespace detail { - template struct type_list_split_impl; @@ -206,28 +156,19 @@ struct type_list_split_impl, std::index_sequence, std::i using second_list = List...>; }; -} // namespace detail - template requires(N <= type_list_size) struct type_list_split : - detail::type_list_split_impl, - std::make_index_sequence - N>> {}; - + type_list_split_impl, std::make_index_sequence - N>> {}; // split_half - template struct type_list_split_half; template typename List, typename... Types> struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; - // merge_sorted - -namespace detail { - template typename Pred> struct type_list_merge_sorted_impl; @@ -261,17 +202,10 @@ struct type_list_merge_sorted_impl, List, List, Pred>::type, Rhs1>::type; }; -} // namespace detail - template typename Pred> -using type_list_merge_sorted = - MP_UNITS_TYPENAME detail::type_list_merge_sorted_impl::type; - +using type_list_merge_sorted = MP_UNITS_TYPENAME type_list_merge_sorted_impl::type; // sort - -namespace detail { - template typename Pred> struct type_list_sort_impl; @@ -294,11 +228,9 @@ struct type_list_sort_impl, Pred> { using type = MP_UNITS_TYPENAME type_list_merge_sorted_impl::type; }; -} // namespace detail - template typename Pred> -using type_list_sort = MP_UNITS_TYPENAME detail::type_list_sort_impl::type; +using type_list_sort = MP_UNITS_TYPENAME type_list_sort_impl::type; -} // namespace mp_units +} // 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 6733a231..50e83507 100644 --- a/test/static/type_list_test.cpp +++ b/test/static/type_list_test.cpp @@ -27,6 +27,7 @@ namespace { using namespace mp_units; +using namespace mp_units::detail; template struct type_list;