diff --git a/src/core/include/mp-units/bits/get_associated_quantity.h b/src/core/include/mp-units/bits/get_associated_quantity.h index 6ec16010..2282ffb2 100644 --- a/src/core/include/mp-units/bits/get_associated_quantity.h +++ b/src/core/include/mp-units/bits/get_associated_quantity.h @@ -61,37 +61,55 @@ template } template -[[nodiscard]] consteval auto get_associated_quantity_impl(U u); +[[nodiscard]] consteval auto determine_associated_quantity(U u); template -using to_quantity_spec = decltype(get_associated_quantity_impl(U{})); +using to_quantity_spec = decltype(determine_associated_quantity(U{})); template -[[nodiscard]] consteval auto get_associated_quantity_impl(common_unit) +[[nodiscard]] consteval auto determine_associated_quantity_impl(common_unit) { - return get_common_quantity_spec(get_associated_quantity_impl(Us{})...); + return get_common_quantity_spec(determine_associated_quantity(Us{})...); } template -[[nodiscard]] consteval auto get_associated_quantity_impl(U u) +[[nodiscard]] consteval auto determine_associated_quantity_impl(U u) { if constexpr (requires { U::_quantity_spec_; }) return remove_kind(U::_quantity_spec_); else if constexpr (requires { U::_reference_unit_; }) - return get_associated_quantity_impl(U::_reference_unit_); + return determine_associated_quantity(U::_reference_unit_); else if constexpr (requires { typename U::_num_; }) { return expr_map(u); } } template -[[nodiscard]] consteval auto get_associated_quantity(U u) +constexpr auto determine_associated_quantity_result = determine_associated_quantity_impl(U{}); + +template +[[nodiscard]] consteval auto determine_associated_quantity(U) +{ + return determine_associated_quantity_result; +} + +template +[[nodiscard]] consteval auto get_associated_quantity_impl(U u) { constexpr bool all_kinds = all_are_kinds(U{}); if constexpr (all_kinds) - return kind_of; + return kind_of; else - return get_associated_quantity_impl(u); + return determine_associated_quantity(u); +} + +template +constexpr auto get_associated_quantity_result = get_associated_quantity_impl(U{}); + +template +[[nodiscard]] consteval auto get_associated_quantity(U) +{ + return get_associated_quantity_result; } } // namespace detail