From 0481ca18ec39a3794f1db008bde31ac5e22e8d93 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 1 Jun 2014 18:43:16 +0100 Subject: [PATCH] Change floating point to rational number conversions to be implicit as per https://svn.boost.org/trac/boost/ticket/10082. --- doc/html/boost_multiprecision/map/hist.html | 20 +++++++++++++------ doc/html/index.html | 2 +- doc/multiprecision.qbk | 4 ++++ .../boost/multiprecision/rational_adaptor.hpp | 9 ++++++++- .../traits/is_restricted_conversion.hpp | 2 +- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/doc/html/boost_multiprecision/map/hist.html b/doc/html/boost_multiprecision/map/hist.html index aebfe5a8..902b437f 100644 --- a/doc/html/boost_multiprecision/map/hist.html +++ b/doc/html/boost_multiprecision/map/hist.html @@ -28,6 +28,14 @@
+ Multiprecision-2.2.2 +
+
+
+ Multiprecision-2.2.1 (Boost-1.56)
@@ -35,7 +43,7 @@ Fix bug in assignment from string in cpp_int, see 9936.
- + Multiprecision-2.2.0
- + Boost-1.55
- + 1.54
- + 1.53
- + Post review changes
@@ -226,7 +234,7 @@
- + Pre-review history
diff --git a/doc/html/index.html b/doc/html/index.html index 1e4f62a1..28fc565e 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -157,7 +157,7 @@ - +

Last revised: May 23, 2014 at 11:16:27 GMT

Last revised: June 01, 2014 at 17:35:12 GMT


diff --git a/doc/multiprecision.qbk b/doc/multiprecision.qbk index 8b3da640..c4d10472 100644 --- a/doc/multiprecision.qbk +++ b/doc/multiprecision.qbk @@ -4919,6 +4919,10 @@ Windows Vista machine. [section:hist History] +[h4 Multiprecision-2.2.2] + +* Change floating point to rational conversions to be implicit, see [https://svn.boost.org/trac/boost/ticket/10082 10082]. + [h4 Multiprecision-2.2.1 (Boost-1.56)] * Fix bug in assignment from string in cpp_int, see [@https://svn.boost.org/trac/boost/ticket/9936 9936]. diff --git a/include/boost/multiprecision/rational_adaptor.hpp b/include/boost/multiprecision/rational_adaptor.hpp index c3605ced..4e2c0867 100644 --- a/include/boost/multiprecision/rational_adaptor.hpp +++ b/include/boost/multiprecision/rational_adaptor.hpp @@ -165,10 +165,17 @@ struct rational_adaptor return m_value > o.m_value ? 1 : (m_value < o.m_value ? -1 : 0); } template - typename enable_if, int>::type compare(Arithmatic i)const + typename enable_if_c::value && !is_floating_point::value, int>::type compare(Arithmatic i)const { return m_value > i ? 1 : (m_value < i ? -1 : 0); } + template + typename enable_if_c::value, int>::type compare(Arithmatic i)const + { + rational_adaptor r; + r = i; + return this->compare(r); + } rational_type& data() { return m_value; } const rational_type& data()const { return m_value; } diff --git a/include/boost/multiprecision/traits/is_restricted_conversion.hpp b/include/boost/multiprecision/traits/is_restricted_conversion.hpp index 283f15ce..ff8f7f63 100644 --- a/include/boost/multiprecision/traits/is_restricted_conversion.hpp +++ b/include/boost/multiprecision/traits/is_restricted_conversion.hpp @@ -19,7 +19,7 @@ struct is_lossy_conversion { typedef typename mpl::if_c< ((number_category::value == number_kind_floating_point) && (number_category::value == number_kind_integer)) - || ((number_category::value == number_kind_floating_point) && (number_category::value == number_kind_rational)) + /* || ((number_category::value == number_kind_floating_point) && (number_category::value == number_kind_rational))*/ || ((number_category::value == number_kind_rational) && (number_category::value == number_kind_integer)) || ((number_category::value == number_kind_fixed_point) && (number_category::value == number_kind_integer)) || (number_category::value == number_kind_unknown)