Chris@16
|
1 // ratio_fwd.hpp ---------------------------------------------------------------//
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright 2008 Howard Hinnant
|
Chris@16
|
4 // Copyright 2008 Beman Dawes
|
Chris@16
|
5 // Copyright 2009 Vicente J. Botet Escriba
|
Chris@16
|
6
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
8 // See http://www.boost.org/LICENSE_1_0.txt
|
Chris@16
|
9
|
Chris@16
|
10 /*
|
Chris@16
|
11
|
Chris@16
|
12 This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
|
Chris@16
|
13 Many thanks to Howard for making his code available under the Boost license.
|
Chris@16
|
14 The original code was modified to conform to Boost conventions and to section
|
Chris@16
|
15 20.4 Compile-time rational arithmetic [ratio], of the C++ committee working
|
Chris@16
|
16 paper N2798.
|
Chris@16
|
17 See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
|
Chris@16
|
18
|
Chris@16
|
19 time2_demo contained this comment:
|
Chris@16
|
20
|
Chris@16
|
21 Much thanks to Andrei Alexandrescu,
|
Chris@16
|
22 Walter Brown,
|
Chris@16
|
23 Peter Dimov,
|
Chris@16
|
24 Jeff Garland,
|
Chris@16
|
25 Terry Golubiewski,
|
Chris@16
|
26 Daniel Krugler,
|
Chris@16
|
27 Anthony Williams.
|
Chris@16
|
28 */
|
Chris@16
|
29
|
Chris@16
|
30 // The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio
|
Chris@16
|
31
|
Chris@16
|
32 #ifndef BOOST_RATIO_RATIO_FWD_HPP
|
Chris@16
|
33 #define BOOST_RATIO_RATIO_FWD_HPP
|
Chris@16
|
34
|
Chris@16
|
35 #include <boost/ratio/config.hpp>
|
Chris@16
|
36
|
Chris@101
|
37 #if defined(__GNUC__) && (__GNUC__ >= 4)
|
Chris@101
|
38 #pragma GCC system_header
|
Chris@101
|
39 #endif
|
Chris@101
|
40
|
Chris@16
|
41 namespace boost
|
Chris@16
|
42 {
|
Chris@16
|
43
|
Chris@16
|
44 //----------------------------------------------------------------------------//
|
Chris@16
|
45 // //
|
Chris@16
|
46 // 20.6 Compile-time rational arithmetic [ratio] //
|
Chris@16
|
47 // //
|
Chris@16
|
48 //----------------------------------------------------------------------------//
|
Chris@16
|
49
|
Chris@16
|
50 // ratio
|
Chris@16
|
51 template <boost::intmax_t N, boost::intmax_t D = 1> class ratio;
|
Chris@16
|
52
|
Chris@16
|
53 // ratio arithmetic
|
Chris@16
|
54 template <class R1, class R2> struct ratio_add;
|
Chris@16
|
55 template <class R1, class R2> struct ratio_subtract;
|
Chris@16
|
56 template <class R1, class R2> struct ratio_multiply;
|
Chris@16
|
57 template <class R1, class R2> struct ratio_divide;
|
Chris@101
|
58 #ifdef BOOST_RATIO_EXTENSIONS
|
Chris@101
|
59 template <class R1, class R2> struct ratio_gcd;
|
Chris@101
|
60 template <class R1, class R2> struct ratio_lcm;
|
Chris@101
|
61 template <class R> struct ratio_negate;
|
Chris@101
|
62 template <class R> struct ratio_abs;
|
Chris@101
|
63 template <class R> struct ratio_sign;
|
Chris@101
|
64 template <class R, int P> struct ratio_power;
|
Chris@101
|
65 #endif
|
Chris@16
|
66
|
Chris@16
|
67 // ratio comparison
|
Chris@16
|
68 template <class R1, class R2> struct ratio_equal;
|
Chris@16
|
69 template <class R1, class R2> struct ratio_not_equal;
|
Chris@16
|
70 template <class R1, class R2> struct ratio_less;
|
Chris@16
|
71 template <class R1, class R2> struct ratio_less_equal;
|
Chris@16
|
72 template <class R1, class R2> struct ratio_greater;
|
Chris@16
|
73 template <class R1, class R2> struct ratio_greater_equal;
|
Chris@16
|
74
|
Chris@16
|
75 // convenience SI typedefs
|
Chris@16
|
76 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto;
|
Chris@16
|
77 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto;
|
Chris@16
|
78 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico;
|
Chris@16
|
79 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000)> nano;
|
Chris@16
|
80 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000)> micro;
|
Chris@16
|
81 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000)> milli;
|
Chris@16
|
82 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(100)> centi;
|
Chris@16
|
83 typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10)> deci;
|
Chris@16
|
84 typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca;
|
Chris@16
|
85 typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto;
|
Chris@16
|
86 typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo;
|
Chris@16
|
87 typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega;
|
Chris@16
|
88 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga;
|
Chris@16
|
89 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera;
|
Chris@16
|
90 typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta;
|
Chris@16
|
91 typedef ratio<BOOST_RATIO_INTMAX_C(1000000000000000000), BOOST_RATIO_INTMAX_C(1)> exa;
|
Chris@16
|
92
|
Chris@101
|
93 #ifdef BOOST_RATIO_EXTENSIONS
|
Chris@101
|
94
|
Chris@101
|
95 #define BOOST_RATIO_1024 BOOST_RATIO_INTMAX_C(1024)
|
Chris@101
|
96
|
Chris@101
|
97 // convenience IEC typedefs
|
Chris@101
|
98 typedef ratio< BOOST_RATIO_1024> kibi;
|
Chris@101
|
99 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024> mebi;
|
Chris@101
|
100 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> gibi;
|
Chris@101
|
101 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> tebi;
|
Chris@101
|
102 typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> pebi;
|
Chris@101
|
103 typedef ratio<BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> exbi;
|
Chris@101
|
104
|
Chris@101
|
105 #endif
|
Chris@16
|
106 } // namespace boost
|
Chris@16
|
107
|
Chris@16
|
108
|
Chris@16
|
109 #endif // BOOST_RATIO_HPP
|