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
12This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype.
13Many thanks to Howard for making his code available under the Boost license.
14The original code was modified to conform to Boost conventions and to section
1520.4 Compile-time rational arithmetic [ratio], of the C++ committee working
16paper N2798.
17See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf.
18
19time2_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
41namespace boost
42{
43
44//----------------------------------------------------------------------------//
45// //
46// 20.6 Compile-time rational arithmetic [ratio] //
47// //
48//----------------------------------------------------------------------------//
49
50// ratio
51template <boost::intmax_t N, boost::intmax_t D = 1> class ratio;
52
53// ratio arithmetic
54template <class R1, class R2> struct ratio_add;
55template <class R1, class R2> struct ratio_subtract;
56template <class R1, class R2> struct ratio_multiply;
57template <class R1, class R2> struct ratio_divide;
58#ifdef BOOST_RATIO_EXTENSIONS
59template <class R1, class R2> struct ratio_gcd;
60template <class R1, class R2> struct ratio_lcm;
61template <class R> struct ratio_negate;
62template <class R> struct ratio_abs;
63template <class R> struct ratio_sign;
64template <class R, int P> struct ratio_power;
65#endif
66
67// ratio comparison
68template <class R1, class R2> struct ratio_equal;
69template <class R1, class R2> struct ratio_not_equal;
70template <class R1, class R2> struct ratio_less;
71template <class R1, class R2> struct ratio_less_equal;
72template <class R1, class R2> struct ratio_greater;
73template <class R1, class R2> struct ratio_greater_equal;
74
75// convenience SI typedefs
76typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000000)> atto;
77typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000000)> femto;
78typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000000)> pico;
79typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000000)> nano;
80typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000000)> micro;
81typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(1000)> milli;
82typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(100)> centi;
83typedef ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10)> deci;
84typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca;
85typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto;
86typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo;
87typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega;
88typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga;
89typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera;
90typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta;
91typedef 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
98typedef ratio< BOOST_RATIO_1024> kibi;
99typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024> mebi;
100typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> gibi;
101typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> tebi;
102typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> pebi;
103typedef 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