forked from mpusz/mp-units
common_ratio refactored
This commit is contained in:
@@ -69,16 +69,19 @@ namespace units {
|
||||
concept bool Ratio = detail::is_ratio<T>;
|
||||
|
||||
// common_ratio
|
||||
namespace detail {
|
||||
|
||||
// todo: simplified
|
||||
template<Ratio R1, Ratio R2>
|
||||
struct common_ratio {
|
||||
using gcd_num = static_gcd<R1::num, R2::num>;
|
||||
using gcd_den = static_gcd<R1::den, R2::den>;
|
||||
using type = std::ratio<gcd_num::value, (R1::den / gcd_den::value) * R2::den>;
|
||||
};
|
||||
// todo: simplified
|
||||
template<typename R1, typename R2>
|
||||
struct common_ratio_impl {
|
||||
using gcd_num = static_gcd<R1::num, R2::num>;
|
||||
using gcd_den = static_gcd<R1::den, R2::den>;
|
||||
using type = std::ratio<gcd_num::value, (R1::den / gcd_den::value) * R2::den>;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<Ratio R1, Ratio R2>
|
||||
using common_ratio_t = common_ratio<R1, R2>::type;
|
||||
using common_ratio = detail::common_ratio_impl<R1, R2>::type;
|
||||
|
||||
} // namespace units
|
||||
|
||||
Reference in New Issue
Block a user