File indexing completed on 2026-05-27 07:24:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include <ratio>
0013
0014 namespace detray {
0015
0016
0017
0018 template <typename... ratios>
0019 struct ratio_sum_helper;
0020
0021 template <typename R>
0022 struct ratio_sum_helper<R> {
0023 using ratio = R;
0024 };
0025
0026 template <typename ratio1, typename ratio2, typename... ratios>
0027 struct ratio_sum_helper<ratio1, ratio2, ratios...> {
0028 using first_two_sum = std::ratio_add<ratio1, ratio2>;
0029
0030 using next_helper = ratio_sum_helper<first_two_sum, ratios...>;
0031
0032
0033 using ratio =
0034 typename std::conditional_t<sizeof...(ratios) == 0, first_two_sum,
0035 typename next_helper::ratio>;
0036 };
0037
0038
0039
0040 template <typename... ratios>
0041 struct ratio_sum {
0042 using helper = ratio_sum_helper<ratios...>;
0043 using ratio = typename helper::ratio;
0044 };
0045
0046
0047 template <typename R>
0048 struct is_ratio_one {
0049 static constexpr bool value = (R::num == R::den);
0050 };
0051
0052 template <class R>
0053 inline constexpr bool is_ratio_one_v = is_ratio_one<R>::value;
0054
0055 }