Chris@16: // ratio_fwd.hpp ---------------------------------------------------------------// Chris@16: Chris@16: // Copyright 2008 Howard Hinnant Chris@16: // Copyright 2008 Beman Dawes Chris@16: // Copyright 2009 Vicente J. Botet Escriba Chris@16: Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // See http://www.boost.org/LICENSE_1_0.txt Chris@16: Chris@16: /* Chris@16: Chris@16: This code was derived by Beman Dawes from Howard Hinnant's time2_demo prototype. Chris@16: Many thanks to Howard for making his code available under the Boost license. Chris@16: The original code was modified to conform to Boost conventions and to section Chris@16: 20.4 Compile-time rational arithmetic [ratio], of the C++ committee working Chris@16: paper N2798. Chris@16: See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2798.pdf. Chris@16: Chris@16: time2_demo contained this comment: Chris@16: Chris@16: Much thanks to Andrei Alexandrescu, Chris@16: Walter Brown, Chris@16: Peter Dimov, Chris@16: Jeff Garland, Chris@16: Terry Golubiewski, Chris@16: Daniel Krugler, Chris@16: Anthony Williams. Chris@16: */ Chris@16: Chris@16: // The way overflow is managed for ratio_less is taken from llvm/libcxx/include/ratio Chris@16: Chris@16: #ifndef BOOST_RATIO_RATIO_FWD_HPP Chris@16: #define BOOST_RATIO_RATIO_FWD_HPP Chris@16: Chris@16: #include Chris@16: Chris@101: #if defined(__GNUC__) && (__GNUC__ >= 4) Chris@101: #pragma GCC system_header Chris@101: #endif Chris@101: Chris@16: namespace boost Chris@16: { Chris@16: Chris@16: //----------------------------------------------------------------------------// Chris@16: // // Chris@16: // 20.6 Compile-time rational arithmetic [ratio] // Chris@16: // // Chris@16: //----------------------------------------------------------------------------// Chris@16: Chris@16: // ratio Chris@16: template class ratio; Chris@16: Chris@16: // ratio arithmetic Chris@16: template struct ratio_add; Chris@16: template struct ratio_subtract; Chris@16: template struct ratio_multiply; Chris@16: template struct ratio_divide; Chris@101: #ifdef BOOST_RATIO_EXTENSIONS Chris@101: template struct ratio_gcd; Chris@101: template struct ratio_lcm; Chris@101: template struct ratio_negate; Chris@101: template struct ratio_abs; Chris@101: template struct ratio_sign; Chris@101: template struct ratio_power; Chris@101: #endif Chris@16: Chris@16: // ratio comparison Chris@16: template struct ratio_equal; Chris@16: template struct ratio_not_equal; Chris@16: template struct ratio_less; Chris@16: template struct ratio_less_equal; Chris@16: template struct ratio_greater; Chris@16: template struct ratio_greater_equal; Chris@16: Chris@16: // convenience SI typedefs Chris@16: typedef ratio atto; Chris@16: typedef ratio femto; Chris@16: typedef ratio pico; Chris@16: typedef ratio nano; Chris@16: typedef ratio micro; Chris@16: typedef ratio milli; Chris@16: typedef ratio centi; Chris@16: typedef ratio deci; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(10), BOOST_RATIO_INTMAX_C(1)> deca; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(100), BOOST_RATIO_INTMAX_C(1)> hecto; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(1000), BOOST_RATIO_INTMAX_C(1)> kilo; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(1000000), BOOST_RATIO_INTMAX_C(1)> mega; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(1000000000), BOOST_RATIO_INTMAX_C(1)> giga; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000), BOOST_RATIO_INTMAX_C(1)> tera; Chris@16: typedef ratio< BOOST_RATIO_INTMAX_C(1000000000000000), BOOST_RATIO_INTMAX_C(1)> peta; Chris@16: typedef ratio exa; Chris@16: Chris@101: #ifdef BOOST_RATIO_EXTENSIONS Chris@101: Chris@101: #define BOOST_RATIO_1024 BOOST_RATIO_INTMAX_C(1024) Chris@101: Chris@101: // convenience IEC typedefs Chris@101: typedef ratio< BOOST_RATIO_1024> kibi; Chris@101: typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024> mebi; Chris@101: typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> gibi; Chris@101: typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> tebi; Chris@101: typedef ratio< BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024*BOOST_RATIO_1024> pebi; Chris@101: typedef ratio exbi; Chris@101: Chris@101: #endif Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_RATIO_HPP