File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/core/include/mp-units/framework Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,23 @@ template<detail::MagArg auto V>
7272 requires detail::is_nonzero_mag_arg<V>
7373constexpr UnitMagnitude auto mag = detail::make_magnitude<V>();
7474
75+ #if MP_UNITS_COMP_MSVC
76+ // Workaround for MSVC ICE with ratio as NTTP in make_magnitude
77+ template <std::intmax_t N, std::intmax_t D>
78+ requires (N != 0 )
79+ constexpr UnitMagnitude auto mag_ratio = []() consteval {
80+ constexpr auto abs_n = N < 0 ? -N : N;
81+ constexpr auto abs_mag = detail::prime_factorization_v<abs_n> / detail::prime_factorization_v<D>;
82+ if constexpr (N < 0 )
83+ return detail::unit_magnitude<detail::negative_tag{}>{} * abs_mag;
84+ else
85+ return abs_mag;
86+ }();
87+ #else
7588template <std::intmax_t N, std::intmax_t D>
7689 requires (N != 0 )
7790constexpr UnitMagnitude auto mag_ratio = detail::make_magnitude<detail::ratio{N, D}>();
91+ #endif
7892
7993/* *
8094 * @brief Create a Magnitude which is some rational number raised to a rational power.
You can’t perform that action at this time.
0 commit comments