mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 13:14:29 +02:00
perf: get_kind_tree_root
result caching added
This commit is contained in:
@@ -1476,7 +1476,7 @@ template<typename Self, NamedQuantitySpec auto QS, auto... Args>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<QuantitySpec Q>
|
template<QuantitySpec Q>
|
||||||
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root(Q q)
|
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root_impl(Q q)
|
||||||
{
|
{
|
||||||
auto defined_as_kind = []<typename QQ>(QQ qq) {
|
auto defined_as_kind = []<typename QQ>(QQ qq) {
|
||||||
if constexpr (requires { defined_as_kind_impl(qq); })
|
if constexpr (requires { defined_as_kind_impl(qq); })
|
||||||
@@ -1501,6 +1501,15 @@ template<QuantitySpec Q>
|
|||||||
// NOLINTEND(bugprone-branch-clone)
|
// NOLINTEND(bugprone-branch-clone)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<QuantitySpec Q>
|
||||||
|
constexpr QuantitySpec auto get_kind_tree_root_result = get_kind_tree_root_impl(Q{});
|
||||||
|
|
||||||
|
template<QuantitySpec Q>
|
||||||
|
[[nodiscard]] consteval QuantitySpec auto get_kind_tree_root(Q)
|
||||||
|
{
|
||||||
|
return get_kind_tree_root_result<Q>;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
MP_UNITS_EXPORT_BEGIN
|
MP_UNITS_EXPORT_BEGIN
|
||||||
|
Reference in New Issue
Block a user