refactor: get_complexity refactored to returned maximum complexity of an element (instead of the sum of elements)

This commit is contained in:
Mateusz Pusz committed 2024-11-04 19:13:48 +01:00
1 parent 467d9a5558
commit cc25f9b0de
2 files changed
+14 -5

No files matched your search

@@ -610,7 +610,10 @@ template<QuantitySpec Q>
template<typename... Ts>
[[nodiscard]] consteval int get_complexity(type_list<Ts...>)
{
return (0 + ... + get_complexity(Ts{}));
if constexpr (sizeof...(Ts) == 0)
return 0;
else
return max({get_complexity(Ts{})...});
}
template<QuantitySpec Q, int... Ints>
@@ -629,7 +632,7 @@ template<QuantitySpec Q>
[[nodiscard]] consteval int get_complexity(Q)
{
if constexpr (DerivedQuantitySpec<Q>)
return get_complexity(typename Q::_num_{}) + get_complexity(typename Q::_den_{});
return max(get_complexity(typename Q::_num_{}), get_complexity(typename Q::_den_{}));
else if constexpr (requires { Q::_equation_; })
return 1 + get_complexity(Q::_equation_);
else