Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80115 - sandbox/big_number/boost/multiprecision/detail
From: john_at_[hidden]
Date: 2012-08-21 12:24:06


Author: johnmaddock
Date: 2012-08-21 12:24:05 EDT (Tue, 21 Aug 2012)
New Revision: 80115
URL: http://svn.boost.org/trac/boost/changeset/80115

Log:
Fix a few GCC warnings and errors
Text files modified:
   sandbox/big_number/boost/multiprecision/detail/default_ops.hpp | 12 +++++++-----
   sandbox/big_number/boost/multiprecision/detail/generic_interconvert.hpp | 1 +
   sandbox/big_number/boost/multiprecision/detail/integer_ops.hpp | 34 ++++++++++++++++++++++------------
   3 files changed, 30 insertions(+), 17 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/detail/default_ops.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/default_ops.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/default_ops.hpp 2012-08-21 12:24:05 EDT (Tue, 21 Aug 2012)
@@ -725,10 +725,16 @@
    }
 }
 
+template <class B>
+void eval_lcm(B& result, const B& a, const B& b);
+template <class B>
+void eval_gcd(B& result, const B& a, const B& b);
+
 template <class T, class Arithmetic>
 inline typename enable_if<is_integral<Arithmetic> >::type eval_gcd(T& result, const T& a, const Arithmetic& b)
 {
    typedef typename boost::multiprecision::detail::canonical<Arithmetic, T>::type si_type;
+ using default_ops::eval_gcd;
    T t;
    t = static_cast<si_type>(b);
    eval_gcd(result, a, t);
@@ -742,6 +748,7 @@
 inline typename enable_if<is_integral<Arithmetic> >::type eval_lcm(T& result, const T& a, const Arithmetic& b)
 {
    typedef typename boost::multiprecision::detail::canonical<Arithmetic, T>::type si_type;
+ using default_ops::eval_lcm;
    T t;
    t = static_cast<si_type>(b);
    eval_lcm(result, a, t);
@@ -813,11 +820,6 @@
       eval_bitwise_xor(val, mask);
 }
 
-template <class B>
-void eval_lcm(B& result, const B& a, const B& b);
-template <class B>
-void eval_gcd(B& result, const B& a, const B& b);
-
 //
 // These have to implemented by the backend, declared here so that our macro generated code compiles OK.
 //

Modified: sandbox/big_number/boost/multiprecision/detail/generic_interconvert.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/generic_interconvert.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/generic_interconvert.hpp 2012-08-21 12:24:05 EDT (Tue, 21 Aug 2012)
@@ -66,6 +66,7 @@
    using default_ops::eval_right_shift;
    using default_ops::eval_left_shift;
    using default_ops::eval_bitwise_or;
+ using default_ops::eval_is_zero;
    // smallest unsigned type handled natively by "From" is likely to be it's limb_type:
    typedef typename canonical<unsigned char, From>::type limb_type;
    // get the corresponding type that we can assign to "To":

Modified: sandbox/big_number/boost/multiprecision/detail/integer_ops.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/detail/integer_ops.hpp (original)
+++ sandbox/big_number/boost/multiprecision/detail/integer_ops.hpp 2012-08-21 12:24:05 EDT (Tue, 21 Aug 2012)
@@ -309,7 +309,7 @@
 }
 
 template <class Backend, class Integer>
-void eval_powm(Backend& result, const Backend& a, Integer b, const Backend& c)
+typename enable_if<is_unsigned<Integer> >::type eval_powm(Backend& result, const Backend& a, Integer b, const Backend& c)
 {
    typedef typename canonical<unsigned char, Backend>::type ui_type;
    typedef typename canonical<Integer, Backend>::type i_type;
@@ -320,11 +320,6 @@
    using default_ops::eval_modulus;
    using default_ops::eval_right_shift;
 
- if(b < 0)
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("powm requires a positive exponent."));
- }
-
    Backend x, y(a);
    x = ui_type(1u);
    while(b > 0)
@@ -341,8 +336,18 @@
    eval_modulus(result, x, c);
 }
 
+template <class Backend, class Integer>
+typename enable_if<is_signed<Integer> >::type eval_powm(Backend& result, const Backend& a, Integer b, const Backend& c)
+{
+ if(b < 0)
+ {
+ BOOST_THROW_EXCEPTION(std::runtime_error("powm requires a positive exponent."));
+ }
+ eval_powm(result, a, static_cast<typename make_unsigned<Integer>::type>(b), c);
+}
+
 template <class Backend, class Integer1, class Integer2>
-void eval_powm(Backend& result, const Backend& a, Integer1 b, Integer2 c)
+typename enable_if<is_unsigned<Integer1> >::type eval_powm(Backend& result, const Backend& a, Integer1 b, Integer2 c)
 {
    typedef typename canonical<unsigned char, Backend>::type ui_type;
    typedef typename canonical<Integer1, Backend>::type i1_type;
@@ -354,11 +359,6 @@
    using default_ops::eval_modulus;
    using default_ops::eval_right_shift;
 
- if(b < 0)
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("powm requires a positive exponent."));
- }
-
    Backend x, y(a);
    x = ui_type(1u);
    while(b > 0)
@@ -375,6 +375,16 @@
    eval_modulus(result, x, static_cast<i2_type>(c));
 }
 
+template <class Backend, class Integer1, class Integer2>
+typename enable_if<is_signed<Integer1> >::type eval_powm(Backend& result, const Backend& a, Integer1 b, Integer2 c)
+{
+ if(b < 0)
+ {
+ BOOST_THROW_EXCEPTION(std::runtime_error("powm requires a positive exponent."));
+ }
+ eval_powm(result, a, static_cast<typename make_unsigned<Integer1>::type>(b), c);
+}
+
 struct powm_func
 {
    template <class T, class U, class V>


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