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/ratio/config.hpp> |
36 | |
37 | #if defined(__GNUC__) && (__GNUC__ >= 4) |
38 | #pragma GCC system_header |
39 | #endif |
40 | |
41 | namespace boost |
42 | { |
43 | |
44 | //----------------------------------------------------------------------------// |
45 | // // |
46 | // 20.6 Compile-time rational arithmetic [ratio] // |
47 | // // |
48 | //----------------------------------------------------------------------------// |
49 | |
50 | // ratio |
51 | template <boost::intmax_t N, boost::intmax_t D = 1> class ratio; |
52 | |
53 | // ratio arithmetic |
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; |
65 | #endif |
66 | |
67 | // ratio comparison |
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; |
74 | |
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; |
92 | |
93 | #ifdef BOOST_RATIO_EXTENSIONS |
94 | |
95 | #define BOOST_RATIO_1024 BOOST_RATIO_INTMAX_C(1024) |
96 | |
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; |
104 | |
105 | #endif |
106 | } // namespace boost |
107 | |
108 | |
109 | #endif // BOOST_RATIO_HPP |
110 | |