$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r78060 - sandbox/fixed_point/boost/fixed_point
From: vicente.botet_at_[hidden]
Date: 2012-04-18 01:52:14
Author: viboes
Date: 2012-04-18 01:52:13 EDT (Wed, 18 Apr 2012)
New Revision: 78060
URL: http://svn.boost.org/trac/boost/changeset/78060
Log:
FixedPoint: Added add_result and replace it whenever is can be used.
Text files modified: 
   sandbox/fixed_point/boost/fixed_point/number.hpp |    96 +++++++++++++++++---------------------- 
   1 files changed, 41 insertions(+), 55 deletions(-)
Modified: sandbox/fixed_point/boost/fixed_point/number.hpp
==============================================================================
--- sandbox/fixed_point/boost/fixed_point/number.hpp	(original)
+++ sandbox/fixed_point/boost/fixed_point/number.hpp	2012-04-18 01:52:13 EDT (Wed, 18 Apr 2012)
@@ -2598,15 +2598,15 @@
     // mixed fixed point arithmetic
 
 
-
     /**
      * Add type metafunction.
      *
      * The result type depends on whether the types are open/closed.
      * The specializations must define a nested typedef type.
      */
-    template <typename T1, typename T2=T1, bool B1=is_open<T1>::value,  bool B2=is_open<T2>::value >
-    struct add_result{
+    template <typename T1, typename T2=T1, bool B1=is_open<T1>::value, bool B2=is_open<T2>::value >
+    struct add_result
+    {
     };
 #if ! defined(BOOST_FIXED_POINT_DOXYGEN_INVOKED)
     /**
@@ -2620,87 +2620,59 @@
 
     /**
      * When one of them is open, the result is open
+     * real_t<MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)>
      */
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2, bool B1, bool B2>
     struct add_result<real_t<R1,P1,RP1,OP1,F1>, real_t<R2,P2,RP2,OP2,F2>, B1, B2 >
     {
       typedef
-          real_t<
-      #if defined(BOOST_FIXED_POINT_DOXYGEN_INVOKED)
-          MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)
-      #else
-          mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
-          mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
-          typename default_type<RP1,RP2>::type,
-          typename default_type<OP1,OP2>::type,
-          typename default_type<F1,F2>::type
-      #endif
-          >
-          type;
+      real_t<
+      mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
+      mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
+      typename default_type<RP1,RP2>::type,
+      typename default_type<OP1,OP2>::type,
+      typename default_type<F1,F2>::type
+      >
+      type;
     };
     /**
      * When one of them is open, the result is open
+     * real_t<MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)>
      */
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2, bool B1, bool B2>
     struct add_result<ureal_t<R1,P1,RP1,OP1,F1>, real_t<R2,P2,RP2,OP2,F2>, B1, B2 >
+    : add_result<real_t<R1,P1,RP1,OP1,F1>, real_t<R2,P2,RP2,OP2,F2> >
     {
-      typedef
-          real_t<
-      #if defined(BOOST_FIXED_POINT_DOXYGEN_INVOKED)
-          MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)
-      #else
-          mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
-          mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
-          typename default_type<RP1,RP2>::type,
-          typename default_type<OP1,OP2>::type,
-          typename default_type<F1,F2>::type
-      #endif
-          >
-          type;
     };
     /**
      * When one of them is open, the result is open
+     * real_t<MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)>
      */
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2, bool B1, bool B2>
     struct add_result<real_t<R1,P1,RP1,OP1,F1>, ureal_t<R2,P2,RP2,OP2,F2>, B1, B2 >
+    : add_result<real_t<R1,P1,RP1,OP1,F1>, real_t<R2,P2,RP2,OP2,F2> >
     {
-      typedef
-          real_t<
-      #if defined(BOOST_FIXED_POINT_DOXYGEN_INVOKED)
-          MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)
-      #else
-          mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
-          mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
-          typename default_type<RP1,RP2>::type,
-          typename default_type<OP1,OP2>::type,
-          typename default_type<F1,F2>::type
-      #endif
-          >
-          type;
     };
     /**
      * When one of them is open, the result is open
+     * ureal_t<MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)>
      */
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2, bool B1, bool B2>
     struct add_result<ureal_t<R1,P1,RP1,OP1,F1>, ureal_t<R2,P2,RP2,OP2,F2>, B1, B2 >
     {
       typedef
-          ureal_t<
-      #if defined(BOOST_FIXED_POINT_DOXYGEN_INVOKED)
-          MAX(R1,R2)+1, MIN(P1,P2), DT(RP1,RP2), DT(OP1,OP2), DT(F1,F2)
-      #else
-          mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
-          mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
-          typename default_type<RP1,RP2>::type,
-          typename default_type<OP1,OP2>::type,
-          typename default_type<F1,F2>::type
-      #endif
-          >
-          type;
+      ureal_t<
+      mpl::max<mpl::int_<R1>,mpl::int_<R2> >::type::value+1,
+      mpl::min<mpl::int_<P1>,mpl::int_<P2> >::type::value,
+      typename default_type<RP1,RP2>::type,
+      typename default_type<OP1,OP2>::type,
+      typename default_type<F1,F2>::type
+      >
+      type;
     };
 #endif
 
@@ -2733,7 +2705,21 @@
 
     /**
      * signed + signed -> signed.
-     * @Returns <c>RT(incex(RT(lhs).count()+RT(rhs).count())</c>.
+     * @Returns <c>RT(index(RT(lhs).count()+RT(rhs).count())</c>.
+     */
+//    template <typename T, int R1, int P1, typename RP1, typename OP1, typename F1,
+//    int R2, int P2, typename RP2, typename OP2, typename F2>
+//    inline
+//    T
+//    add(real_t<R1,P1,RP1,OP1,F1> const& lhs, real_t<R2,P2,RP2,OP2,F2> const& rhs)
+//    {
+//      typedef T result_type;
+//
+//      return result_type(index(result_type(lhs).count()+result_type(rhs).count()));
+//    }
+    /**
+     * signed + signed -> signed.
+     * @Returns <c>RT(index(RT(lhs).count()+RT(rhs).count())</c>.
      */
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2>
@@ -2839,7 +2825,7 @@
     template <int R1, int P1, typename RP1, typename OP1, typename F1,
     int R2, int P2, typename RP2, typename OP2, typename F2>
     inline
-    typename add_result<ureal_t<R1,P1,RP1,OP1,F1>, ureal_t<R2,P2,RP2,OP2,F2> >::type
+    typename add_result<real_t<R1,P1,RP1,OP1,F1>, real_t<R2,P2,RP2,OP2,F2> >::type
     operator-(ureal_t<R1,P1,RP1,OP1,F1> const& lhs, ureal_t<R2,P2,RP2,OP2,F2> const& rhs)
     {
       typedef typename add_result<ureal_t<R1,P1,RP1,OP1,F1>, ureal_t<R2,P2,RP2,OP2,F2> >::type result_type;