refactor: sudo_cast if constexpr condition refactored

This commit is contained in:
Mateusz Pusz
2023-06-15 17:39:33 +03:00
parent fa8fc078df
commit 698b6ce338

View File

@ -59,7 +59,7 @@ template<Quantity To, typename From>
// TODO how to constrain the second part here?
[[nodiscard]] constexpr Quantity auto sudo_cast(From&& q)
{
if constexpr (q.unit == To::unit) {
if constexpr (std::remove_reference_t<From>::unit == To::unit) {
// no scaling of the number needed
return make_quantity<To::reference>(
static_cast<TYPENAME To::rep>(std::forward<From>(q).number())); // this is the only (and recommended) way to do