diff --git a/src/core/include/mp_units/bits/dimension_concepts.h b/src/core/include/mp_units/bits/dimension_concepts.h index 0a1469fd..a3726370 100644 --- a/src/core/include/mp_units/bits/dimension_concepts.h +++ b/src/core/include/mp_units/bits/dimension_concepts.h @@ -56,11 +56,12 @@ concept BaseDimension = namespace detail { template -inline constexpr bool is_dimension_one = false; +struct is_dimension_one : std::false_type {}; template inline constexpr bool is_power_of_dim = requires { - requires is_specialization_of_power && (BaseDimension || is_dimension_one); + requires is_specialization_of_power && + (BaseDimension || is_dimension_one::value); }; template @@ -68,13 +69,13 @@ inline constexpr bool is_per_of_dims = false; template inline constexpr bool is_per_of_dims> = - (... && (BaseDimension || is_dimension_one || is_power_of_dim)); + (... && (BaseDimension || is_dimension_one::value || is_power_of_dim)); } // namespace detail template concept DerivedDimensionExpr = - BaseDimension || detail::is_dimension_one || detail::is_power_of_dim || detail::is_per_of_dims; + BaseDimension || detail::is_dimension_one::value || detail::is_power_of_dim || detail::is_per_of_dims; template struct derived_dimension; diff --git a/src/core/include/mp_units/bits/expression_template.h b/src/core/include/mp_units/bits/expression_template.h index b4f74ee9..76bebb2a 100644 --- a/src/core/include/mp_units/bits/expression_template.h +++ b/src/core/include/mp_units/bits/expression_template.h @@ -291,7 +291,7 @@ struct expr_fractions_result { using _den_ = Den; // exposition only }; -template +template typename OneType, typename List> [[nodiscard]] consteval auto expr_fractions_impl() { constexpr std::size_t size = type_list_size; @@ -304,7 +304,7 @@ template using last_element = type_list_back; if constexpr (is_specialization_of_per) { - if constexpr (size == 2 && std::derived_from, OneTypeBase>) + if constexpr (size == 2 && OneType>::value) return expr_fractions_result, type_list_map>{}; else { using split = type_list_split; @@ -319,8 +319,8 @@ template /** * @brief Divides expression template spec to numerator and denominator parts */ -template -struct expr_fractions : decltype(expr_fractions_impl>()) {}; +template typename OneType, typename... Ts> +struct expr_fractions : decltype(expr_fractions_impl>()) {}; // expr_make_spec template typename To> diff --git a/src/core/include/mp_units/bits/quantity_spec_concepts.h b/src/core/include/mp_units/bits/quantity_spec_concepts.h index eb158585..00e16e89 100644 --- a/src/core/include/mp_units/bits/quantity_spec_concepts.h +++ b/src/core/include/mp_units/bits/quantity_spec_concepts.h @@ -88,12 +88,12 @@ concept BaseQuantitySpec = namespace detail { template -inline constexpr bool is_dimensionless = false; +struct is_dimensionless : std::false_type {}; template inline constexpr bool is_power_of_quantity_spec = requires { requires is_specialization_of_power && - (NamedQuantitySpec || is_dimensionless); + (NamedQuantitySpec || is_dimensionless::value); }; template @@ -101,16 +101,17 @@ inline constexpr bool is_per_of_quantity_specs = false; template inline constexpr bool is_per_of_quantity_specs> = - (... && (NamedQuantitySpec || is_dimensionless || is_power_of_quantity_spec)); + (... && (NamedQuantitySpec || is_dimensionless::value || is_power_of_quantity_spec)); } // namespace detail template -concept DerivedQuantitySpecExpr = detail::NamedQuantitySpec || detail::is_dimensionless || - detail::is_power_of_quantity_spec || detail::is_per_of_quantity_specs; +concept IntermediateDerivedQuantitySpecExpr = + detail::NamedQuantitySpec || detail::is_dimensionless::value || detail::is_power_of_quantity_spec || + detail::is_per_of_quantity_specs; -template +template struct derived_quantity_spec; namespace detail { diff --git a/src/core/include/mp_units/dimension.h b/src/core/include/mp_units/dimension.h index 231c995b..9afe1f2e 100644 --- a/src/core/include/mp_units/dimension.h +++ b/src/core/include/mp_units/dimension.h @@ -115,7 +115,7 @@ using type_list_of_base_dimension_less = expr_less; * instantiate this type automatically based on the dimensional arithmetic equation provided by the user. */ template -struct derived_dimension : detail::expr_fractions, Expr...> {}; +struct derived_dimension : detail::expr_fractions {}; /** * @brief Dimension one @@ -130,7 +130,7 @@ inline constexpr struct dimension_one : derived_dimension<> { namespace detail { template<> -inline constexpr bool is_dimension_one = true; +struct is_dimension_one : std::true_type {}; } // namespace detail diff --git a/src/core/include/mp_units/unit.h b/src/core/include/mp_units/unit.h index d1552de9..9d3c353a 100644 --- a/src/core/include/mp_units/unit.h +++ b/src/core/include/mp_units/unit.h @@ -219,6 +219,13 @@ struct prefixed_unit : std::remove_const_t { static constexpr auto symbol = Symbol + U.symbol; }; +namespace detail { + +template +struct is_one : std::false_type {}; + +} // namespace detail + /** * @brief Measurement unit for a derived quantity * @@ -265,7 +272,7 @@ struct prefixed_unit : std::remove_const_t { * instantiate this type automatically based on the unit arithmetic equation provided by the user. */ template -struct derived_unit : detail::expr_fractions, Expr...> {}; +struct derived_unit : detail::expr_fractions {}; /** * @brief Unit one @@ -278,6 +285,9 @@ inline constexpr struct one : derived_unit<> {} one; namespace detail { +template<> +struct is_one : std::true_type {}; + /** * @brief A canonical representation of a unit *