Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77796 - in trunk: boost/ratio/detail libs/ratio/doc libs/ratio/test libs/ratio/test/ratio_arithmetic libs/ratio/test/ratio_comparison libs/ratio/test/ratio_extensions libs/ratio/test/ratio_ratio
From: vicente.botet_at_[hidden]
Date: 2012-04-06 19:45:40


Author: viboes
Date: 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
New Revision: 77796
URL: http://svn.boost.org/trac/boost/changeset/77796

Log:
Ratio: Avoid the Mpl error when using the 0x7FFFFFFFFFFFFFFELL + update history + try __typeof__ trick on sun
Text files modified:
   trunk/boost/ratio/detail/overflow_helpers.hpp | 24 +++++++++++++-----------
   trunk/libs/ratio/doc/ratio.qbk | 13 +++++++++++--
   trunk/libs/ratio/test/Jamfile.v2 | 8 ++++++++
   trunk/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp | 5 ++---
   trunk/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp | 2 +-
   trunk/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp | 2 +-
   trunk/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp | 2 +-
   trunk/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp | 1 -
   trunk/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp | 2 +-
   trunk/libs/ratio/test/ratio_ratio/ratio_pass.cpp | 9 ++++-----
   trunk/libs/ratio/test/ratio_test.cpp | 2 +-
   22 files changed, 43 insertions(+), 38 deletions(-)

Modified: trunk/boost/ratio/detail/overflow_helpers.hpp
==============================================================================
--- trunk/boost/ratio/detail/overflow_helpers.hpp (original)
+++ trunk/boost/ratio/detail/overflow_helpers.hpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -42,6 +42,8 @@
 #include <boost/utility/enable_if.hpp>
 #include <boost/integer_traits.hpp>
 
+#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFELL)
+
 #if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_RATIO_USES_MPL_ASSERT)
 #define BOOST_RATIO_OVERFLOW_IN_ADD "overflow in ratio add"
 #define BOOST_RATIO_OVERFLOW_IN_SUB "overflow in ratio sub"
@@ -216,7 +218,7 @@
   template <class R1, class R2> struct ratio_subtract;
   template <class R1, class R2> struct ratio_multiply;
   template <class R1, class R2> struct ratio_divide;
-
+
   template <class R1, class R2>
   struct ratio_add
   {
@@ -247,7 +249,7 @@
   {
     typedef R type;
   };
-
+
   template <class R1, class R2>
   struct ratio_subtract
   {
@@ -273,13 +275,13 @@
>
>::type type;
   };
-
+
   template <class R, boost::intmax_t D>
   struct ratio_subtract<R, ratio<0,D> >
   {
     typedef R type;
   };
-
+
   template <class R1, class R2>
   struct ratio_multiply
   {
@@ -322,12 +324,12 @@
              ((R2::num / gcd_n1_n2 ==1) && (R1::den / gcd_d1_d2)==1)
> type;
   };
-
+
   template <class T>
- struct is_ratio : public boost::false_type
+ struct is_ratio : public boost::false_type
   {};
   template <boost::intmax_t N, boost::intmax_t D>
- struct is_ratio<ratio<N, D> > : public boost::true_type
+ struct is_ratio<ratio<N, D> > : public boost::true_type
   {};
 
   template <class R1, class R2,
@@ -361,11 +363,11 @@
   {
     static const bool value = ratio_less1<ratio<R2::den, M2>, ratio<R1::den, M1>
>::value;
- };
-
+ };
+
   template <
- class R1,
- class R2,
+ class R1,
+ class R2,
       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
>

Modified: trunk/libs/ratio/doc/ratio.qbk
==============================================================================
--- trunk/libs/ratio/doc/ratio.qbk (original)
+++ trunk/libs/ratio/doc/ratio.qbk 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -1596,12 +1596,21 @@
 [section:history Appendix A: History]
 [/==================================]
 
-[section [*Version 1.0.1, Jan 8, 2011] ]
+[section [*Version 1.0.2, April 1, 2012 - 1.50] ]
+
+[*Fixes:]
+
+* [@http://svn.boost.org/trac/boost/ticket/6498 #6498] boost::ratio won't compile with default settings.
+
+[endsect]
+
+[section [*Version 1.0.1, Jan 8, 2011 ] ]
+
+[*Features:]
 
 * Added MPL Rational Constant and the associated numeric metafunction specializations.
 
 [endsect]
-
 
 [section [*Version 1.0.0, Jan 2, 2011] ]
 

Modified: trunk/libs/ratio/test/Jamfile.v2
==============================================================================
--- trunk/libs/ratio/test/Jamfile.v2 (original)
+++ trunk/libs/ratio/test/Jamfile.v2 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -27,6 +27,9 @@
         <define>BOOST_ENABLE_WARNINGS
         <define>BOOST_RATIO_USES_MPL_ASSERT
         <define>BOOST_MPL_NEXT_PRIOR_EXT
+ #<toolset>sun:<define>BOOST_COMMON_TYPE_DONT_USE_TYPEOF
+ #<toolset>sun:<define>BOOST_TYPEOF_EMULATION
+ <toolset>sun:<define>__typeof__=__typeof__
         <warnings>all
         <toolset>gcc:<cxxflags>-Wextra
         <toolset>gcc:<cxxflags>-Wno-long-long
@@ -117,3 +120,8 @@
         [ compile ratio_extensions/mpl_rational_constant_pass.cpp ]
 
         ;
+
+ test-suite "tickets"
+ :
+ [ run test_6498_pass.cpp ]
+ ;

Modified: trunk/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp (original)
+++ trunk/libs/ratio/test/ratio_arithmetic/ratio_add_fail.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -18,11 +18,10 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX boost::integer_traits<boost::intmax_t>::const_max
 
-typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
+typedef boost::ratio<boost::integer_traits<boost::intmax_t>::const_max, 1> R1;
 typedef boost::ratio<1, 1> R2;
 typedef boost::ratio_add<R1, R2>::type RT;
 
-BOOST_RATIO_STATIC_ASSERT(RT::num==BOOST_RATIO_INTMAX_T_MAX+1, NOTHING, (RT));
+BOOST_RATIO_STATIC_ASSERT(RT::num==boost::integer_traits<boost::intmax_t>::const_max+1, NOTHING, (RT));
 BOOST_RATIO_STATIC_ASSERT(RT::den==1, NOTHING, (RT));

Modified: trunk/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_arithmetic/ratio_add_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -71,7 +71,7 @@
     BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ());
     }
     {
- typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
     typedef boost::ratio<-1, 1> R2;
     typedef boost::ratio_add<R1, R2>::type RT;
     }

Modified: trunk/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp (original)
+++ trunk/libs/ratio/test/ratio_arithmetic/ratio_divide_fail.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -15,6 +15,6 @@
 
 #include <boost/ratio/ratio.hpp>
 
-typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
 typedef boost::ratio<1,2> R2;
 typedef boost::ratio_divide<R1, R2>::type RT;

Modified: trunk/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp (original)
+++ trunk/libs/ratio/test/ratio_arithmetic/ratio_multiply_fail.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -15,6 +15,6 @@
 
 #include <boost/ratio/ratio.hpp>
 
-typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
 typedef boost::ratio<2,1> R2;
 typedef boost::ratio_multiply<R1, R2>::type RT;

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -18,7 +18,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_greater_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -16,7 +16,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_greater_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -15,7 +15,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_less_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -15,7 +15,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_less_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -16,7 +16,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 void test()
 {
     {

Modified: trunk/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_comparison/ratio_not_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -15,7 +15,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_equal_to_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -20,7 +20,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_greater_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -18,7 +18,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_greater_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -17,7 +17,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_less_equal_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -17,7 +17,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_less_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -18,7 +18,6 @@
 #define NOTHING ""
 #endif
 
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 void test()
 {
     {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_not_equal_to_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -17,7 +17,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 void test()
 {

Modified: trunk/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_extensions/mpl_plus_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -72,7 +72,7 @@
     BOOST_RATIO_STATIC_ASSERT(R::num == 127970191639601LL && R::den == 5177331081415LL, NOTHING, ());
     }
     {
- typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), 1> R1;
+ typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
     typedef boost::ratio<-1, 1> R2;
     typedef boost::mpl::int_<0> R3;
     typedef boost::mpl::plus<R1, R2, R3>::type RT;

Modified: trunk/libs/ratio/test/ratio_ratio/ratio_pass.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_ratio/ratio_pass.cpp (original)
+++ trunk/libs/ratio/test/ratio_ratio/ratio_pass.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -19,7 +19,6 @@
 #if !defined(BOOST_NO_STATIC_ASSERT)
 #define NOTHING ""
 #endif
-#define BOOST_RATIO_INTMAX_T_MAX (0x7FFFFFFFFFFFFFFFLL)
 
 template <long long N, long long D, long long eN, long long eD>
 void test()
@@ -46,10 +45,10 @@
     test<222, -333, -2, 3>();
     test<-222, 333, -2, 3>();
     test<-222, -333, 2, 3>();
- test<BOOST_RATIO_INTMAX_T_MAX, 127, 72624976668147841LL, 1>();
- test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>();
- test<BOOST_RATIO_INTMAX_T_MAX, -127, -72624976668147841LL, 1>();
- test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>();
+ //test<BOOST_RATIO_INTMAX_T_MAX, 127, 72624976668147841LL, 1>();
+ //test<-BOOST_RATIO_INTMAX_T_MAX, 127, -72624976668147841LL, 1>();
+ //test<BOOST_RATIO_INTMAX_T_MAX, -127, -72624976668147841LL, 1>();
+ //test<-BOOST_RATIO_INTMAX_T_MAX, -127, 72624976668147841LL, 1>();
     //~ test<BOOST_RATIO_INTMAX_T_MAX, 127, BOOST_RATIO_INTMAX_T_MAX, 127>();
     //~ test<-BOOST_RATIO_INTMAX_T_MAX, 127, -BOOST_RATIO_INTMAX_T_MAX, 127>();
     //~ test<BOOST_RATIO_INTMAX_T_MAX, -127, -BOOST_RATIO_INTMAX_T_MAX, 127>();

Modified: trunk/libs/ratio/test/ratio_test.cpp
==============================================================================
--- trunk/libs/ratio/test/ratio_test.cpp (original)
+++ trunk/libs/ratio/test/ratio_test.cpp 2012-04-06 19:45:38 EDT (Fri, 06 Apr 2012)
@@ -19,7 +19,7 @@
 
 // Test the case described in library working group issue 948.
 
-typedef boost::ratio<BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFFF), BOOST_RATIO_INTMAX_C(0x7FFFFFFFFFFFFFF0)> R1;
+typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, BOOST_RATIO_INTMAX_T_MAX-16> R1;
 typedef boost::ratio<8, 7> R2;
 typedef boost::ratio_multiply<R1, R2>::type RT;
 


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