1 // ratio_fwd.hpp ---------------------------------------------------------------//
3 // Copyright 2008 Howard Hinnant
4 // Copyright 2008 Beman Dawes
5 // Copyright 2009 Vicente J. Botet Escriba
7 // Distributed under the Boost Software License, Version 1.0.
8 // See http://www.boost.org/LICENSE_1_0.txt
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
17 See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
19 time2_demo contained this comment:
21 Much thanks to Andrei Alexandrescu,
30 // The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
32 #ifndef BOOST_RATIO_RATIO_FWD_HPP
33 #define BOOST_RATIO_RATIO_FWD_HPP
35 #include <boost/ratio/config.hpp>
37 #if defined(__GNUC__) && (__GNUC__ >= 4)
38 #pragma GCC system_header
44 //----------------------------------------------------------------------------//
46 // 20.6 Compile-time rational arithmetic [ratio] //
48 //----------------------------------------------------------------------------//
51 template <boost::intmax_t N, boost::intmax_t D = 1> class ratio;
54 template <class R1, class R2> struct ratio_add;
55 template <class R1, class R2> struct ratio_subtract;
56 template <class R1, class R2> struct ratio_multiply;
57 template <class R1, class R2> struct ratio_divide;
58 #ifdef BOOST_RATIO_EXTENSIONS
59 template <class R1, class R2> struct ratio_gcd;
60 template <class R1, class R2> struct ratio_lcm;
61 template <class R> struct ratio_negate;
62 template <class R> struct ratio_abs;
63 template <class R> struct ratio_sign;
64 template <class R, int P> struct ratio_power;
68 template <class R1, class R2> struct ratio_equal;
69 template <class R1, class R2> struct ratio_not_equal;
70 template <class R1, class R2> struct ratio_less;
71 template <class R1, class R2> struct ratio_less_equal;
72 template <class R1, class R2> struct ratio_greater;
73 template <class R1, class R2> struct ratio_greater_equal;
75 // convenience SI typedefs
76 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto;
77 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto;
78 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico;
79 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000)> nano;
80 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000)> micro;
81 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000)> milli;
82 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(100)> centi;
83 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10)> deci;
84 typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca;
85 typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto;
86 typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo;
87 typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega;
88 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga;
89 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera;
90 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta;
91 typedef ratio<BOOST_RATIO_INTMAX_C(1000000000000000000), BOOST_RATIO_INTMAX_C(1)> exa;
93 #ifdef BOOST_RATIO_EXTENSIONS
95 #define BOOST_RATIO_1024 BOOST_RATIO_INTMAX_C(1024)
97 // convenience IEC typedefs
98 typedef ratio< BOOST_RATIO_1024> kibi;
99 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024> mebi;
100 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> gibi;
101 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> tebi;
102 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> pebi;
103 typedef ratio<BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> exbi;
109 #endif // BOOST_RATIO_HPP