1 // ratio_fwd.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_FWD_HPP 33 #define BOOST_RATIO_RATIO_FWD_HPP 34 35 #include <boost/cstdint.hpp> 36 #ifdef INTMAX_C 37 #define BOOST_RATIO_INTMAX_C(a) INTMAX_C(a) 38 #else 39 #define BOOST_RATIO_INTMAX_C(a) a##LL 40 #endif 41 42 namespace boost 43 { 44 45 //----------------------------------------------------------------------------// 46 // // 47 // 20.6 Compile-time rational arithmetic [ratio] // 48 // // 49 //----------------------------------------------------------------------------// 50 51 // ratio 52 template <boost::intmax_t N, boost::intmax_t D = 1> class ratio; 53 54 // ratio arithmetic 55 template <class R1, class R2> struct ratio_add; 56 template <class R1, class R2> struct ratio_subtract; 57 template <class R1, class R2> struct ratio_multiply; 58 template <class R1, class R2> struct ratio_divide; 59 60 // ratio comparison 61 template <class R1, class R2> struct ratio_equal; 62 template <class R1, class R2> struct ratio_not_equal; 63 template <class R1, class R2> struct ratio_less; 64 template <class R1, class R2> struct ratio_less_equal; 65 template <class R1, class R2> struct ratio_greater; 66 template <class R1, class R2> struct ratio_greater_equal; 67 68 // convenience SI typedefs 69 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto; 70 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto; 71 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico; 72 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000)> nano; 73 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000)> micro; 74 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000)> milli; 75 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(100)> centi; 76 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10)> deci; 77 typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca; 78 typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto; 79 typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo; 80 typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega; 81 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga; 82 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera; 83 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta; 84 typedef ratio<BOOST_RATIO_INTMAX_C(1000000000000000000), BOOST_RATIO_INTMAX_C(1)> exa; 85 86 } // namespace boost 87 88 89 #endif // BOOST_RATIO_HPP 90