From 4b6a7ebb391fd9e190a36d98a44126e9efb50a7d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 11 Apr 2019 17:40:54 +0100 Subject: [PATCH] Down with typename --- doc/DESIGN.md | 8 ++++---- src/include/units/bits/ratio_tools.h | 2 +- src/include/units/bits/type_list.h | 20 ++++++++++---------- src/include/units/bits/upcasting.h | 6 +++--- src/include/units/dimension.h | 14 +++++++------- src/include/units/quantity.h | 14 +++++++------- src/include/units/unit.h | 12 ++++++------ 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/doc/DESIGN.md b/doc/DESIGN.md index d36beaaf..eed7a1a5 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -127,7 +127,7 @@ struct make_dimension { }; template -using make_dimension_t = typename make_dimension::type; +using make_dimension_t = make_dimension::type; ``` So for example to create a `dimension_velocity` type we have to do: @@ -172,7 +172,7 @@ struct dimension_multiply, dimension> { }; template -using dimension_multiply_t = typename dimension_multiply::type; +using dimension_multiply_t = dimension_multiply::type; ``` Example implementation of `merge_dimension` may look like: @@ -361,7 +361,7 @@ Upcasting capability is provided through dedicated `upcasting_traits`, a few hel ```cpp template -using upcast_from = typename T::base_type; +using upcast_from = T::base_type; template using upcast_to = std::type_identity; @@ -370,7 +370,7 @@ template struct upcasting_traits : upcast_to {}; template -using upcasting_traits_t = typename upcasting_traits::type; +using upcasting_traits_t = upcasting_traits::type; ``` With that the upcasting functionality is enabled by: diff --git a/src/include/units/bits/ratio_tools.h b/src/include/units/bits/ratio_tools.h index c992e35d..2e8bcb90 100644 --- a/src/include/units/bits/ratio_tools.h +++ b/src/include/units/bits/ratio_tools.h @@ -79,6 +79,6 @@ namespace units { }; template - using common_ratio_t = typename common_ratio::type; + using common_ratio_t = common_ratio::type; } // namespace units diff --git a/src/include/units/bits/type_list.h b/src/include/units/bits/type_list.h index 92088131..3b014fe9 100644 --- a/src/include/units/bits/type_list.h +++ b/src/include/units/bits/type_list.h @@ -50,7 +50,7 @@ namespace units { }; template - using type_list_push_front_t = typename type_list_push_front::type; + using type_list_push_front_t = type_list_push_front::type; // push_back @@ -63,7 +63,7 @@ namespace units { }; template - using type_list_push_back_t = typename type_list_push_back::type; + using type_list_push_back_t = type_list_push_back::type; // split @@ -81,8 +81,8 @@ namespace units { template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> struct split_impl : split_impl { using base = split_impl; - using base_first = typename base::first_list; - using base_second = typename base::second_list; + using base_first = base::first_list; + using base_second = base::second_list; using first_list = std::conditional_t, base_first>; using second_list = std::conditional_t>; }; @@ -96,8 +96,8 @@ namespace units { struct type_list_split, N> { static_assert(N <= sizeof...(Types), "Invalid index provided"); using split = detail::split_impl; - using first_list = typename split::first_list; - using second_list = typename split::second_list; + using first_list = split::first_list; + using second_list = split::second_list; }; // split_half @@ -115,7 +115,7 @@ namespace units { struct type_list_merge_sorted; template typename Pred> - using type_list_merge_sorted_t = typename type_list_merge_sorted::type; + using type_list_merge_sorted_t = type_list_merge_sorted::type; template typename List, typename... Lhs, template typename Pred> struct type_list_merge_sorted, List<>, Pred> { @@ -155,12 +155,12 @@ namespace units { struct type_list_sort, Pred> { using types = List; using split = type_list_split_half>; - using left = typename type_list_sort::type; - using right = typename type_list_sort::type; + using left = type_list_sort::type; + using right = type_list_sort::type; using type = type_list_merge_sorted_t; }; template typename Pred> - using type_list_sort_t = typename type_list_sort::type; + using type_list_sort_t = type_list_sort::type; } // namespace units \ No newline at end of file diff --git a/src/include/units/bits/upcasting.h b/src/include/units/bits/upcasting.h index e780624b..e2edeedf 100644 --- a/src/include/units/bits/upcasting.h +++ b/src/include/units/bits/upcasting.h @@ -40,15 +40,15 @@ namespace units { std::DerivedFrom>; template - using upcast_from = typename T::base_type; + using upcast_from = T::base_type; template - using upcast_to = typename std::type_identity; + using upcast_to = std::type_identity; template struct upcasting_traits : upcast_to {}; template - using upcasting_traits_t = typename upcasting_traits::type; + using upcasting_traits_t = upcasting_traits::type; } // namespace units diff --git a/src/include/units/dimension.h b/src/include/units/dimension.h index c6f74ab0..c6a8fbf8 100644 --- a/src/include/units/dimension.h +++ b/src/include/units/dimension.h @@ -82,7 +82,7 @@ namespace units { }; template - using exp_invert_t = typename exp_invert::type; + using exp_invert_t = exp_invert::type; // dimension @@ -115,7 +115,7 @@ namespace units { struct dim_invert> : std::type_identity...>>> {}; template - using dim_invert_t = typename dim_invert::type; + using dim_invert_t = dim_invert::type; // make_dimension @@ -126,7 +126,7 @@ namespace units { struct dim_consolidate; template - using dim_consolidate_t = typename dim_consolidate::type; + using dim_consolidate_t = dim_consolidate::type; template<> struct dim_consolidate> { @@ -159,7 +159,7 @@ namespace units { }; template - using make_dimension_t = typename make_dimension::type; + using make_dimension_t = make_dimension::type; template struct merge_dimension { @@ -167,7 +167,7 @@ namespace units { }; template - using merge_dimension_t = typename merge_dimension::type; + using merge_dimension_t = merge_dimension::type; // dimension_multiply @@ -178,7 +178,7 @@ namespace units { struct dimension_multiply, dimension> : std::type_identity, dimension>>> {}; template - using dimension_multiply_t = typename dimension_multiply::type; + using dimension_multiply_t = dimension_multiply::type; // dimension_divide @@ -191,6 +191,6 @@ namespace units { }; template - using dimension_divide_t = typename dimension_divide::type; + using dimension_divide_t = dimension_divide::type; } // namespace units diff --git a/src/include/units/quantity.h b/src/include/units/quantity.h index 6c6cd8d2..82029294 100644 --- a/src/include/units/quantity.h +++ b/src/include/units/quantity.h @@ -71,7 +71,7 @@ namespace units { }; template> - using common_quantity_t = typename common_quantity::type; + using common_quantity_t = common_quantity::type; // treat_as_floating_point @@ -87,8 +87,8 @@ namespace units { template static constexpr To cast(const Q& q) { - return To(static_cast(static_cast(q.count()) * static_cast(CR::num) / - static_cast(CR::den))); + return To(static_cast(static_cast(q.count()) * static_cast(CR::num) / + static_cast(CR::den))); } }; @@ -97,7 +97,7 @@ namespace units { template static constexpr To cast(const Q& q) { - return To(static_cast(q.count())); + return To(static_cast(q.count())); } }; @@ -106,7 +106,7 @@ namespace units { template static constexpr To cast(const Q& q) { - return To(static_cast(static_cast(q.count()) / static_cast(CR::den))); + return To(static_cast(static_cast(q.count()) / static_cast(CR::den))); } }; @@ -115,7 +115,7 @@ namespace units { template static constexpr To cast(const Q& q) { - return To(static_cast(static_cast(q.count()) * static_cast(CR::num))); + return To(static_cast(static_cast(q.count()) * static_cast(CR::num))); } }; @@ -183,8 +183,8 @@ namespace units { [[nodiscard]] static constexpr quantity min() noexcept { return quantity(quantity_values::min()); } [[nodiscard]] static constexpr quantity max() noexcept { return quantity(quantity_values::max()); } - [[nodiscard]] constexpr quantity operator-() const { return quantity(-count()); } [[nodiscard]] constexpr quantity operator+() const { return quantity(*this); } + [[nodiscard]] constexpr quantity operator-() const { return quantity(-count()); } constexpr quantity& operator++() { diff --git a/src/include/units/unit.h b/src/include/units/unit.h index 8ed2e954..1dfbed93 100644 --- a/src/include/units/unit.h +++ b/src/include/units/unit.h @@ -62,7 +62,7 @@ namespace units { template struct get_unit_base_dim> { static_assert(sizeof...(Rest) == 0, "Base unit expected"); - using dimension = typename E::dimension; + using dimension = E::dimension; }; template @@ -72,7 +72,7 @@ namespace units { template struct get_ratio { - using unit_base_dim = typename get_unit_base_dim::dimension; + using unit_base_dim = get_unit_base_dim::dimension; using ratio = std::conditional_t::ratio>; }; @@ -90,7 +90,7 @@ namespace units { using calc_ratio = std::conditional_t<(UnitExpValue > 0), std::ratio_multiply, std::ratio_divide>; static constexpr int value = UnitExpValue > 0 ? UnitExpValue - 1 : UnitExpValue + 1; - using ratio = typename ratio_op::ratio; + using ratio = ratio_op::ratio; }; template @@ -103,9 +103,9 @@ namespace units { template struct derived_ratio, Us...> { - using rest_ratio = typename derived_ratio, Us...>::ratio; - using e_ratio = typename get_ratio::ratio; - using ratio = typename ratio_op::ratio; + using rest_ratio = derived_ratio, Us...>::ratio; + using e_ratio = get_ratio::ratio; + using ratio = ratio_op::ratio; }; }