Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67539 - in sandbox/chrono/boost/ratio: . detail
From: vicente.botet_at_[hidden]
Date: 2011-01-01 10:56:15


Author: viboes
Date: 2011-01-01 10:56:02 EST (Sat, 01 Jan 2011)
New Revision: 67539
URL: http://svn.boost.org/trac/boost/changeset/67539

Log:
Ratio: update to use mpl::abs,mpl::sign,mpl::gcd and mpl::lcm
Text files modified:
   sandbox/chrono/boost/ratio/detail/overflow_helpers.hpp | 40 ++++++++++++++++++++++------------------
   sandbox/chrono/boost/ratio/ratio.hpp | 26 +++++++++++++++-----------
   2 files changed, 37 insertions(+), 29 deletions(-)

Modified: sandbox/chrono/boost/ratio/detail/overflow_helpers.hpp
==============================================================================
--- sandbox/chrono/boost/ratio/detail/overflow_helpers.hpp (original)
+++ sandbox/chrono/boost/ratio/detail/overflow_helpers.hpp 2011-01-01 10:56:02 EST (Sat, 01 Jan 2011)
@@ -32,10 +32,14 @@
 #ifndef BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP
 #define BOOST_RATIO_DETAIL_RATIO_OPERATIONS_HPP
 
-#include <boost/static_integer/static_abs.hpp>
-#include <boost/static_integer/static_sign.hpp>
-#include <boost/static_integer/static_lcm.hpp>
-#include <boost/static_integer/static_gcd.hpp>
+//~ #include <boost/static_integer/static_abs.hpp>
+//~ #include <boost/static_integer/static_sign.hpp>
+//~ #include <boost/static_integer/static_lcm.hpp>
+//~ #include <boost/static_integer/static_gcd.hpp>
+#include <boost/mpl/abs.hpp>
+#include <boost/mpl/sign.hpp>
+//~ #include <boost/mpl/gcd.hpp>
+//~ #include <boost/mpl/lcm.hpp>
 #include <cstdlib>
 #include <climits>
 #include <limits>
@@ -95,7 +99,7 @@
 namespace ratio_detail
 {
 
- template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = boost::integer::static_signed_sign<Y>::value>
+ template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = mpl::sign_c<boost::intmax_t, Y>::value>
   class br_add;
 
   template <boost::intmax_t X, boost::intmax_t Y>
@@ -127,7 +131,7 @@
       static const boost::intmax_t value = X + Y;
   };
 
- template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = boost::integer::static_signed_sign<Y>::value>
+ template <boost::intmax_t X, boost::intmax_t Y, boost::intmax_t = mpl::sign_c<boost::intmax_t, Y>::value>
   class br_sub;
 
   template <boost::intmax_t X, boost::intmax_t Y>
@@ -167,8 +171,8 @@
       static const boost::intmax_t min = boost::integer_traits<boost::intmax_t>::const_min;
       static const boost::intmax_t max = boost::integer_traits<boost::intmax_t>::const_max;
 
- static const boost::intmax_t a_x = boost::integer::static_signed_abs<X>::value;
- static const boost::intmax_t a_y = boost::integer::static_signed_abs<Y>::value;
+ static const boost::intmax_t a_x = mpl::abs_c<boost::intmax_t, X>::value;
+ static const boost::intmax_t a_y = mpl::abs_c<boost::intmax_t, Y>::value;
 
       BOOST_RATIO_STATIC_ASSERT(X != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ());
       BOOST_RATIO_STATIC_ASSERT(Y != nan, BOOST_RATIO_OVERFLOW_IN_MUL, ());
@@ -226,8 +230,8 @@
       //R2::den + R2::num * R1::den and T2 has the value R1::den * R2::den.
       // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
   private:
- static const boost::intmax_t gcd_n1_n2 = boost::integer::static_signed_gcd<R1::num, R2::num>::value;
- static const boost::intmax_t gcd_d1_d2 = boost::integer::static_signed_gcd<R1::den, R2::den>::value;
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
   public:
       // No need to normalize as ratio_multiply is already normalized
       typedef typename ratio_multiply
@@ -252,8 +256,8 @@
       // R1::num *R2::den - R2::num * R1::den and T2 has the value R1::den * R2::den.
       // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
   private:
- static const boost::intmax_t gcd_n1_n2 = boost::integer::static_signed_gcd<R1::num, R2::num>::value;
- static const boost::intmax_t gcd_d1_d2 = boost::integer::static_signed_gcd<R1::den, R2::den>::value;
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
   public:
       // No need to normalize as ratio_multiply is already normalized
       typedef typename ratio_multiply
@@ -277,8 +281,8 @@
       // The nested typedef type shall be a synonym for ratio<R1::num * R2::den - R2::num * R1::den, R1::den * R2::den>::type.
       // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
   private:
- static const boost::intmax_t gcd_n1_d2 = boost::integer::static_signed_gcd<R1::num, R2::den>::value;
- static const boost::intmax_t gcd_d1_n2 = boost::integer::static_signed_gcd<R1::den, R2::num>::value;
+ static const boost::intmax_t gcd_n1_d2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::den>::value;
+ static const boost::intmax_t gcd_d1_n2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::num>::value;
   public:
       typedef typename ratio
          <
@@ -293,8 +297,8 @@
       // The nested typedef type shall be a synonym for ratio<R1::num * R2::den, R2::num * R1::den>::type.
       // As the preceding doesn't works because of overflow on boost::intmax_t we need something more elaborated.
   private:
- static const boost::intmax_t gcd_n1_n2 = boost::integer::static_signed_gcd<R1::num, R2::num>::value;
- static const boost::intmax_t gcd_d1_d2 = boost::integer::static_signed_gcd<R1::den, R2::den>::value;
+ static const boost::intmax_t gcd_n1_n2 = mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value;
+ static const boost::intmax_t gcd_d1_d2 = mpl::gcd_c<boost::intmax_t, R1::den, R2::den>::value;
   public:
       typedef typename ratio
          <
@@ -346,8 +350,8 @@
   template <
       class R1,
       class R2,
- boost::intmax_t S1 = boost::integer::static_signed_sign<R1::num>::value,
- boost::intmax_t S2 = boost::integer::static_signed_sign<R2::num>::value
+ boost::intmax_t S1 = mpl::sign_c<boost::intmax_t, R1::num>::value,
+ boost::intmax_t S2 = mpl::sign_c<boost::intmax_t, R2::num>::value
>
   struct ratio_less
   {

Modified: sandbox/chrono/boost/ratio/ratio.hpp
==============================================================================
--- sandbox/chrono/boost/ratio/ratio.hpp (original)
+++ sandbox/chrono/boost/ratio/ratio.hpp 2011-01-01 10:56:02 EST (Sat, 01 Jan 2011)
@@ -33,9 +33,13 @@
 #define BOOST_RATIO_RATIO_HPP
 
 #include <boost/config.hpp>
-#include <boost/static_integer/static_abs.hpp>
-#include <boost/static_integer/static_sign.hpp>
-#include <boost/static_integer/static_gcd.hpp>
+//~ #include <boost/static_integer/static_abs.hpp>
+//~ #include <boost/static_integer/static_sign.hpp>
+//~ #include <boost/static_integer/static_gcd.hpp>
+#include <boost/mpl/abs.hpp>
+#include <boost/mpl/sign.hpp>
+#include <boost/mpl/gcd.hpp>
+#include <boost/mpl/lcm.hpp>
 #include <cstdlib>
 #include <climits>
 #include <limits>
@@ -71,14 +75,14 @@
 template <boost::intmax_t N, boost::intmax_t D>
 class ratio
 {
- static const boost::intmax_t ABS_N = boost::integer::static_signed_abs<N>::value;
- static const boost::intmax_t ABS_D = boost::integer::static_signed_abs<D>::value;
+ static const boost::intmax_t ABS_N = mpl::abs_c<boost::intmax_t, N>::value;
+ static const boost::intmax_t ABS_D = mpl::abs_c<boost::intmax_t, D>::value;
     BOOST_RATIO_STATIC_ASSERT(ABS_N >= 0, BOOST_RATIO_NUMERATOR_IS_OUT_OF_RANGE, ());
     BOOST_RATIO_STATIC_ASSERT(ABS_D > 0, BOOST_RATIO_DENOMINATOR_IS_OUT_OF_RANGE, ());
     BOOST_RATIO_STATIC_ASSERT(D != 0, BOOST_RATIO_DIVIDE_BY_0 , ());
- static const boost::intmax_t SIGN_N = boost::integer::static_signed_sign<N>::value
- * boost::integer::static_signed_sign<D>::value;
- static const boost::intmax_t GCD = boost::integer::static_signed_gcd<ABS_N, ABS_D>::value;
+ static const boost::intmax_t SIGN_N = mpl::sign_c<boost::intmax_t,N>::value
+ * mpl::sign_c<boost::intmax_t,D>::value;
+ static const boost::intmax_t GCD = mpl::gcd_c<boost::intmax_t, ABS_N, ABS_D>::value;
 public:
     BOOST_STATIC_CONSTEXPR boost::intmax_t num = SIGN_N * ABS_N / GCD;
     BOOST_STATIC_CONSTEXPR boost::intmax_t den = ABS_D / GCD;
@@ -181,11 +185,11 @@
 template <class R1, class R2>
 struct ratio_gcd
 {
- typedef ratio<boost::integer::static_signed_gcd<R1::num, R2::num>::value,
- boost::integer::static_signed_lcm<R1::den, R2::den>::value> type;
+ typedef ratio<mpl::gcd_c<boost::intmax_t, R1::num, R2::num>::value,
+ mpl::lcm_c<boost::intmax_t, R1::den, R2::den>::value> type;
 };
     
 } // namespace boost
 
 
-#endif // BOOST_RATIO_HPP
+#endif // BOOST_RATIO_RATIO_HPP


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk