diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index e421b841..8e598629 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -115,6 +115,11 @@ template template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const common_unit&); +template +struct get_canonical_unit_result { + inline static constexpr auto value = get_canonical_unit_impl(U{}, U{}); +}; + template struct unit_less : std::bool_constant() < type_name()> {}; @@ -131,7 +136,10 @@ concept PotentiallyConvertibleTo = Unit && Unit && // TODO this should really be in the `details` namespace but is used in `chrono.h` (a part of mp_units.systems) // Even though it is not exported, it is visible to the other module via ADL -[[nodiscard]] consteval auto get_canonical_unit(Unit auto u) { return detail::get_canonical_unit_impl(u, u); } +[[nodiscard]] consteval auto get_canonical_unit(Unit auto u) +{ + return detail::get_canonical_unit_result::value; +} // convertible template @@ -530,14 +538,14 @@ namespace detail { template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const scaled_unit_impl&) { - auto base = get_canonical_unit_impl(U{}, U{}); + auto base = get_canonical_unit(U{}); return canonical_unit{M * base.mag, base.reference_unit}; } template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const common_unit& u) { - return get_canonical_unit_impl(u._common_unit_, u._common_unit_); + return get_canonical_unit(u._common_unit_); } template @@ -549,7 +557,7 @@ template template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const named_unit&) { - return get_canonical_unit_impl(U, U); + return get_canonical_unit(U); } template @@ -563,7 +571,7 @@ template template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const power&) { - auto base = get_canonical_unit_impl(F{}, F{}); + auto base = get_canonical_unit(F{}); if constexpr (requires { typename decltype(base.reference_unit)::_num_; }) { auto num = get_canonical_unit_impl(power{}, typename decltype(base.reference_unit)::_num_{}); auto den = get_canonical_unit_impl(power{}, typename decltype(base.reference_unit)::_den_{});