Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:05

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 // System include(s)
0012 #include <ratio>
0013 
0014 namespace detray {
0015 
0016 /// Helper struct to sum over variadic std::ratio
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   // recursive summation of first two std::ratio
0033   using ratio =
0034       typename std::conditional_t<sizeof...(ratios) == 0, first_two_sum,
0035                                   typename next_helper::ratio>;
0036 };
0037 /// @}
0038 
0039 /// Struct to sum over variadic std::ratio
0040 template <typename... ratios>
0041 struct ratio_sum {
0042   using helper = ratio_sum_helper<ratios...>;
0043   using ratio = typename helper::ratio;
0044 };
0045 
0046 /// Helper trait to check if the ratio is one
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 }  // namespace detray