Skip to content

Commit 2185a13

Browse files
authored
Fix destination unit creation in inverse
1 parent 507b2db commit 2185a13

File tree

1 file changed

+6
-3
lines changed
  • src/core/include/mp-units

1 file changed

+6
-3
lines changed

src/core/include/mp-units/math.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,16 @@ template<Unit auto To, auto R, typename Rep>
413413
}
414414
{
415415
#if MP_UNITS_API_NATURAL_UNITS
416-
if constexpr (!MP_UNITS_ASSOCIATED_UNIT<MP_UNITS_REMOVE_CONST(decltype(To))>)
417-
return (representation_values<Rep>::one() * one).force_in(To * get_unit(R)) / q;
416+
if constexpr (!MP_UNITS_ASSOCIATED_UNIT<MP_UNITS_REMOVE_CONST(decltype(To))>) {
417+
constexpr Unit auto unit = To * quantity<R, Rep>::unit;
418+
return (representation_values<Rep>::one() * one).force_in(unit) / q;
419+
}
418420
else
419421
#endif
420422
{
421423
constexpr QuantitySpec auto qs = get_quantity_spec(To) * quantity<R, Rep>::quantity_spec;
422-
return qs(representation_values<Rep>::one() * one).force_in(To * get_unit(R)) / q;
424+
constexpr Unit auto unit = To * quantity<R, Rep>::unit;
425+
return qs(representation_values<Rep>::one() * one).force_in(unit) / q;
423426
}
424427
}
425428

0 commit comments

Comments
 (0)