| 1 | // ratio.hpp ---------------------------------------------------------------// |
| 2 | |
| 3 | // Copyright 2008 Howard Hinnant |
| 4 | // Copyright 2008 Beman Dawes |
| 5 | // Copyright 2009 Vicente J. Botet Escriba |
| 6 | |
| 7 | // Distributed under the Boost Software License, Version 1.0. |
| 8 | // See http://www.boost.org/LICENSE_1_0.txt |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype. |
| 13 | Many thanks to Howard for making his code available under the Boost license. |
| 14 | The original code was modified to conform to Boost conventions and to section |
| 15 | 20.4 Compile-time rational arithmetic [ratio], of the C++ committee working |
| 16 | paper N2798. |
| 17 | See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf. |
| 18 | |
| 19 | time2_demo contained this comment: |
| 20 | |
| 21 | Much thanks to Andrei Alexandrescu, |
| 22 | Walter Brown, |
| 23 | Peter Dimov, |
| 24 | Jeff Garland, |
| 25 | Terry Golubiewski, |
| 26 | Daniel Krugler, |
| 27 | Anthony Williams. |
| 28 | */ |
| 29 | |
| 30 | // The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio |
| 31 | |
| 32 | #ifndef BOOST_RATIO_RATIO_HPP |
| 33 | #define BOOST_RATIO_RATIO_HPP |
| 34 | |
| 35 | #include <boost/ratio/ratio_fwd.hpp> |
| 36 | #include <boost/ratio/detail/gcd_lcm.hpp> |
| 37 | |
| 38 | namespace boost |
| 39 | { |
| 40 | |
| 41 | // extension used by Chrono |
| 42 | |
| 43 | template <class R1, class R2> using ratio_gcd = typename ratio< |
| 44 | ratio_detail::gcd<R1::num, R2::num>::value, |
| 45 | ratio_detail::lcm<R1::den, R2::den>::value>::type; |
| 46 | |
| 47 | } // namespace boost |
| 48 | |
| 49 | #endif // BOOST_RATIO_RATIO_HPP |
| 50 | |