|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80397 - in sandbox/big_number: boost/multiprecision boost/multiprecision/detail libs/multiprecision/doc libs/multiprecision/doc/html libs/multiprecision/doc/html/boost_multiprecision libs/multiprecision/doc/html/boost_multiprecision/indexes libs/multiprecision/doc/html/boost_multiprecision/ref libs/multiprecision/test/compile_fail
From: john_at_[hidden]
Date: 2012-09-04 13:18:20
Author: johnmaddock
Date: 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
New Revision: 80397
URL: http://svn.boost.org/trac/boost/changeset/80397
Log:
Enable optimisations in the GMP and MPFR backends for mixed mode arithmetic.
Allow mixed arithmetic between two different expression templates.
Change docs to indicate mixed arithmetic is allowed and rebuild.
Added:
sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_01.cpp (contents, props changed)
sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_02.cpp (contents, props changed)
Text files modified:
sandbox/big_number/boost/multiprecision/detail/default_ops.hpp | 157 +++++++++++++++++++++++++++++++--------
sandbox/big_number/boost/multiprecision/gmp.hpp | 96 ++++++++++++------------
sandbox/big_number/boost/multiprecision/mpfr.hpp | 96 ++++++++++++------------
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s01.html | 4
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s02.html | 4
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s03.html | 4
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s04.html | 4
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html | 27 +++++-
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html | 18 +---
sandbox/big_number/libs/multiprecision/doc/html/index.html | 2
sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk | 34 +++++---
11 files changed, 274 insertions(+), 172 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-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -178,7 +178,7 @@
// Default versions of 3-arg arithmetic functions, these mostly just forward to the 2 arg versions:
//
template <class T>
-inline void eval_add(T& t, const T& u, const T& v)
+inline void eval_add_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -195,26 +195,37 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_add(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_add_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_add(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_add(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_add_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_add(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_add(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_add_default(T& t, const U& u, const T& v)
{
eval_add(t, v, u);
}
+template <class T, class U, class V>
+inline void eval_add_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_add(t, u);
+}
+template <class T, class U, class V>
+inline void eval_add(T& t, const U& u, const V& v)
+{
+ eval_add_default(t, u, v);
+}
template <class T>
-inline void eval_subtract(T& t, const T& u, const T& v)
+inline void eval_subtract_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -232,27 +243,38 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_subtract(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_subtract_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_subtract(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_subtract(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_subtract_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_subtract(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_subtract(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_subtract_default(T& t, const U& u, const T& v)
{
eval_subtract(t, v, u);
t.negate();
}
+template <class T, class U, class V>
+inline void eval_subtract_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_subtract(t, u);
+}
+template <class T, class U, class V>
+inline void eval_subtract(T& t, const U& u, const V& v)
+{
+ eval_subtract_default(t, u, v);
+}
template <class T>
-inline void eval_multiply(T& t, const T& u, const T& v)
+inline void eval_multiply_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -269,26 +291,37 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_multiply(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_multiply_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_multiply(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_multiply(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_multiply_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_multiply(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_multiply(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_multiply_default(T& t, const U& u, const T& v)
{
eval_multiply(t, v, u);
}
+template <class T, class U, class V>
+inline void eval_multiply_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_multiply(t, u);
+}
+template <class T, class U, class V>
+inline void eval_multiply(T& t, const U& u, const V& v)
+{
+ eval_multiply_default(t, u, v);
+}
template <class T>
-inline void eval_divide(T& t, const T& u, const T& v)
+inline void eval_divide_default(T& t, const T& u, const T& v)
{
if(&t == &u)
eval_divide(t, v);
@@ -305,35 +338,45 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_divide(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_divide_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_divide(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_divide(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_divide_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_divide(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_divide(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_divide_default(T& t, const U& u, const T& v)
{
T uu;
uu = u;
eval_divide(t, uu, v);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_divide(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_divide_default(T& t, const U& u, const T& v)
{
T uu(u);
eval_divide(t, uu, v);
}
-
+template <class T, class U, class V>
+inline void eval_divide_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_divide(t, u);
+}
+template <class T, class U, class V>
+inline void eval_divide(T& t, const U& u, const V& v)
+{
+ eval_divide_default(t, u, v);
+}
template <class T>
-inline void eval_modulus(T& t, const T& u, const T& v)
+inline void eval_modulus_default(T& t, const T& u, const T& v)
{
if(&t == &u)
eval_modulus(t, v);
@@ -350,34 +393,45 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_modulus(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_modulus_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_modulus(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_modulus(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_modulus_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_modulus(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_modulus(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_modulus_default(T& t, const U& u, const T& v)
{
T uu;
uu = u;
eval_modulus(t, uu, v);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_modulus(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_modulus_default(T& t, const U& u, const T& v)
{
T uu(u);
eval_modulus(t, uu, v);
}
+template <class T, class U, class V>
+inline void eval_modulus_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_modulus(t, u);
+}
+template <class T, class U, class V>
+inline void eval_modulus(T& t, const U& u, const V& v)
+{
+ eval_modulus_default(t, u, v);
+}
template <class T>
-inline void eval_bitwise_and(T& t, const T& u, const T& v)
+inline void eval_bitwise_and_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -394,26 +448,37 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_and(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_and_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_bitwise_and(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_and(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_and_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_bitwise_and(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_and(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_and_default(T& t, const U& u, const T& v)
{
eval_bitwise_and(t, v, u);
}
+template <class T, class U, class V>
+inline void eval_bitwise_and_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_bitwise_and(t, u);
+}
+template <class T, class U, class V>
+inline void eval_bitwise_and(T& t, const U& u, const V& v)
+{
+ eval_bitwise_and_default(t, u, v);
+}
template <class T>
-inline void eval_bitwise_or(T& t, const T& u, const T& v)
+inline void eval_bitwise_or_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -430,26 +495,37 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_or(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_or_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_bitwise_or(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_or(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_or_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_bitwise_or(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_or(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_or_default(T& t, const U& u, const T& v)
{
eval_bitwise_or(t, v, u);
}
+template <class T, class U, class V>
+inline void eval_bitwise_or_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_bitwise_or(t, u);
+}
+template <class T, class U, class V>
+inline void eval_bitwise_or(T& t, const U& u, const V& v)
+{
+ eval_bitwise_or_default(t, u, v);
+}
template <class T>
-inline void eval_bitwise_xor(T& t, const T& u, const T& v)
+inline void eval_bitwise_xor_default(T& t, const T& u, const T& v)
{
if(&t == &v)
{
@@ -466,23 +542,34 @@
}
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_xor(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && !is_convertible<U, T>::value>::type eval_bitwise_xor_default(T& t, const T& u, const U& v)
{
T vv;
vv = v;
eval_bitwise_xor(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_xor(T& t, const T& u, const U& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value && is_convertible<U, T>::value>::type eval_bitwise_xor_default(T& t, const T& u, const U& v)
{
T vv(v);
eval_bitwise_xor(t, u, vv);
}
template <class T, class U>
-inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_xor(T& t, const U& u, const T& v)
+inline typename enable_if_c<is_convertible<U, number<T> >::value>::type eval_bitwise_xor_default(T& t, const U& u, const T& v)
{
eval_bitwise_xor(t, v, u);
}
+template <class T, class U, class V>
+inline void eval_bitwise_xor_default(T& t, const U& u, const V& v)
+{
+ t = u;
+ eval_bitwise_xor(t, u);
+}
+template <class T, class U, class V>
+inline void eval_bitwise_xor(T& t, const U& u, const V& v)
+{
+ eval_bitwise_xor_default(t, u, v);
+}
template <class T>
inline void eval_increment(T& val)
Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -567,18 +567,18 @@
return a.compare(b) > 0;
}
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& result, const gmp_float<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(gmp_float<D1>& result, const gmp_float<D2>& o) BOOST_NOEXCEPT
{
mpf_add(result.data(), result.data(), o.data());
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& result, const gmp_float<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(gmp_float<D1>& result, const gmp_float<D2>& o) BOOST_NOEXCEPT
{
mpf_sub(result.data(), result.data(), o.data());
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& result, const gmp_float<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(gmp_float<D1>& result, const gmp_float<D2>& o) BOOST_NOEXCEPT
{
mpf_mul(result.data(), result.data(), o.data());
}
@@ -587,8 +587,8 @@
{
return mpf_sgn(val.data()) == 0;
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& result, const gmp_float<digits10>& o)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(gmp_float<D1>& result, const gmp_float<D2>& o)
{
if(eval_is_zero(o))
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
@@ -651,31 +651,31 @@
//
// Specialised 3 arg versions of the basic operators:
//
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_add(gmp_float<D1>& a, const gmp_float<D2>& x, const gmp_float<D3>& y) BOOST_NOEXCEPT
{
mpf_add(a.data(), x.data(), y.data());
}
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(gmp_float<D1>& a, const gmp_float<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpf_add_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(gmp_float<D1>& a, const gmp_float<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpf_sub_ui(a.data(), x.data(), -y);
else
mpf_add_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(gmp_float<D1>& a, unsigned long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
mpf_add_ui(a.data(), y.data(), x);
}
-template <unsigned digits10>
-inline void eval_add(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(gmp_float<D1>& a, long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -685,31 +685,31 @@
else
mpf_add_ui(a.data(), y.data(), x);
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_subtract(gmp_float<D1>& a, const gmp_float<D2>& x, const gmp_float<D3>& y) BOOST_NOEXCEPT
{
mpf_sub(a.data(), x.data(), y.data());
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(gmp_float<D1>& a, const gmp_float<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpf_sub_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(gmp_float<D1>& a, const gmp_float<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpf_add_ui(a.data(), x.data(), -y);
else
mpf_sub_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(gmp_float<D1>& a, unsigned long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
mpf_ui_sub(a.data(), x, y.data());
}
-template <unsigned digits10>
-inline void eval_subtract(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(gmp_float<D1>& a, long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -720,18 +720,18 @@
mpf_ui_sub(a.data(), x, y.data());
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_multiply(gmp_float<D1>& a, const gmp_float<D2>& x, const gmp_float<D3>& y) BOOST_NOEXCEPT
{
mpf_mul(a.data(), x.data(), y.data());
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(gmp_float<D1>& a, const gmp_float<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpf_mul_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(gmp_float<D1>& a, const gmp_float<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
{
@@ -741,13 +741,13 @@
else
mpf_mul_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(gmp_float<D1>& a, unsigned long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
mpf_mul_ui(a.data(), y.data(), x);
}
-template <unsigned digits10>
-inline void eval_multiply(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(gmp_float<D1>& a, long x, const gmp_float<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -758,22 +758,22 @@
mpf_mul_ui(a.data(), y.data(), x);
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, const gmp_float<digits10>& y)
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_divide(gmp_float<D1>& a, const gmp_float<D2>& x, const gmp_float<D3>& y)
{
if(eval_is_zero(y))
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
mpf_div(a.data(), x.data(), y.data());
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, unsigned long y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(gmp_float<D1>& a, const gmp_float<D2>& x, unsigned long y)
{
if(y == 0)
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
mpf_div_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& a, const gmp_float<digits10>& x, long y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(gmp_float<D1>& a, const gmp_float<D2>& x, long y)
{
if(y == 0)
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
@@ -785,15 +785,15 @@
else
mpf_div_ui(a.data(), x.data(), y);
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& a, unsigned long x, const gmp_float<digits10>& y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(gmp_float<D1>& a, unsigned long x, const gmp_float<D2>& y)
{
if(eval_is_zero(y))
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
mpf_ui_div(a.data(), x, y.data());
}
-template <unsigned digits10>
-inline void eval_divide(gmp_float<digits10>& a, long x, const gmp_float<digits10>& y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(gmp_float<D1>& a, long x, const gmp_float<D2>& y)
{
if(eval_is_zero(y))
BOOST_THROW_EXCEPTION(std::overflow_error("Division by zero."));
Modified: sandbox/big_number/boost/multiprecision/mpfr.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/mpfr.hpp (original)
+++ sandbox/big_number/boost/multiprecision/mpfr.hpp 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -609,23 +609,23 @@
return a.compare(b) > 0;
}
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(mpfr_float_backend<D1>& result, const mpfr_float_backend<D2>& o) BOOST_NOEXCEPT
{
mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(mpfr_float_backend<D1>& result, const mpfr_float_backend<D2>& o) BOOST_NOEXCEPT
{
mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(mpfr_float_backend<D1>& result, const mpfr_float_backend<D2>& o) BOOST_NOEXCEPT
{
mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& result, const mpfr_float_backend<digits10>& o)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(mpfr_float_backend<D1>& result, const mpfr_float_backend<D2>& o)
{
mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
}
@@ -682,31 +682,31 @@
//
// Specialised 3 arg versions of the basic operators:
//
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_add(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, const mpfr_float_backend<D3>& y) BOOST_NOEXCEPT
{
mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpfr_sub_ui(a.data(), x.data(), -y, GMP_RNDN);
else
mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(mpfr_float_backend<D1>& a, unsigned long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_add(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_add(mpfr_float_backend<D1>& a, long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -716,31 +716,31 @@
else
mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_subtract(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, const mpfr_float_backend<D3>& y) BOOST_NOEXCEPT
{
mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
mpfr_add_ui(a.data(), x.data(), -y, GMP_RNDN);
else
mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(mpfr_float_backend<D1>& a, unsigned long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_subtract(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_subtract(mpfr_float_backend<D1>& a, long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -751,18 +751,18 @@
mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_multiply(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, const mpfr_float_backend<D3>& y) BOOST_NOEXCEPT
{
mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, unsigned long y) BOOST_NOEXCEPT
{
mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, long y) BOOST_NOEXCEPT
{
if(y < 0)
{
@@ -772,13 +772,13 @@
else
mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(mpfr_float_backend<D1>& a, unsigned long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_multiply(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y) BOOST_NOEXCEPT
+template <unsigned D1, unsigned D2>
+inline void eval_multiply(mpfr_float_backend<D1>& a, long x, const mpfr_float_backend<D2>& y) BOOST_NOEXCEPT
{
if(x < 0)
{
@@ -789,18 +789,18 @@
mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, const mpfr_float_backend<digits10>& y)
+template <unsigned D1, unsigned D2, unsigned D3>
+inline void eval_divide(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, const mpfr_float_backend<D3>& y)
{
mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, unsigned long y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, unsigned long y)
{
mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& a, const mpfr_float_backend<digits10>& x, long y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(mpfr_float_backend<D1>& a, const mpfr_float_backend<D2>& x, long y)
{
if(y < 0)
{
@@ -810,13 +810,13 @@
else
mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& a, unsigned long x, const mpfr_float_backend<digits10>& y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(mpfr_float_backend<D1>& a, unsigned long x, const mpfr_float_backend<D2>& y)
{
mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
}
-template <unsigned digits10>
-inline void eval_divide(mpfr_float_backend<digits10>& a, long x, const mpfr_float_backend<digits10>& y)
+template <unsigned D1, unsigned D2>
+inline void eval_divide(mpfr_float_backend<D1>& a, long x, const mpfr_float_backend<D2>& y)
{
if(x < 0)
{
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s01.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s01.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s01.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -13,9 +13,9 @@
<div class="spirit-nav">
<a accesskey="p" href="../indexes.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../indexes.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="s02.html"><img src="../../images/next.png" alt="Next"></a>
</div>
-<div class="section id952470">
+<div class="section id949228">
<div class="titlepage"><div><div><h3 class="title">
-<a name="id952470"></a>Function Index</h3></div></div></div>
+<a name="id949228"></a>Function Index</h3></div></div></div>
<p><a class="link" href="s01.html#idx_id_0">A</a> <a class="link" href="s01.html#idx_id_1">B</a> <a class="link" href="s01.html#idx_id_2">C</a> <a class="link" href="s01.html#idx_id_3">D</a> <a class="link" href="s01.html#idx_id_4">E</a> <a class="link" href="s01.html#idx_id_5">F</a> <a class="link" href="s01.html#idx_id_7">I</a> <a class="link" href="s01.html#idx_id_8">L</a> <a class="link" href="s01.html#idx_id_9">M</a> <a class="link" href="s01.html#idx_id_12">P</a> <a class="link" href="s01.html#idx_id_13">R</a> <a class="link" href="s01.html#idx_id_14">S</a> <a class="link" href="s01.html#idx_id_15">T</a> <a class="link" href="s01.html#idx_id_17">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s02.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s02.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s02.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -13,9 +13,9 @@
<div class="spirit-nav">
<a accesskey="p" href="s01.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../indexes.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="s03.html"><img src="../../images/next.png" alt="Next"></a>
</div>
-<div class="section id954901">
+<div class="section id951725">
<div class="titlepage"><div><div><h3 class="title">
-<a name="id954901"></a>Class Index</h3></div></div></div>
+<a name="id951725"></a>Class Index</h3></div></div></div>
<p><a class="link" href="s02.html#idx_id_20">C</a> <a class="link" href="s02.html#idx_id_24">G</a> <a class="link" href="s02.html#idx_id_25">I</a> <a class="link" href="s02.html#idx_id_27">M</a> <a class="link" href="s02.html#idx_id_28">N</a> <a class="link" href="s02.html#idx_id_33">T</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s03.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s03.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s03.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -13,9 +13,9 @@
<div class="spirit-nav">
<a accesskey="p" href="s02.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../indexes.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="s04.html"><img src="../../images/next.png" alt="Next"></a>
</div>
-<div class="section id955245">
+<div class="section id952069">
<div class="titlepage"><div><div><h3 class="title">
-<a name="id955245"></a>Typedef Index</h3></div></div></div>
+<a name="id952069"></a>Typedef Index</h3></div></div></div>
<p><a class="link" href="s03.html#idx_id_38">C</a> <a class="link" href="s03.html#idx_id_43">I</a> <a class="link" href="s03.html#idx_id_44">L</a> <a class="link" href="s03.html#idx_id_45">M</a> <a class="link" href="s03.html#idx_id_51">T</a> <a class="link" href="s03.html#idx_id_52">U</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s04.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s04.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/indexes/s04.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -12,9 +12,9 @@
<div class="spirit-nav">
<a accesskey="p" href="s03.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../indexes.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a>
</div>
-<div class="section id958711">
+<div class="section id954443">
<div class="titlepage"><div><div><h3 class="title">
-<a name="id958711"></a>Index</h3></div></div></div>
+<a name="id954443"></a>Index</h3></div></div></div>
<p><a class="link" href="s04.html#idx_id_54">A</a> <a class="link" href="s04.html#idx_id_55">B</a> <a class="link" href="s04.html#idx_id_56">C</a> <a class="link" href="s04.html#idx_id_57">D</a> <a class="link" href="s04.html#idx_id_58">E</a> <a class="link" href="s04.html#idx_id_59">F</a> <a class="link" href="s04.html#idx_id_60">G</a> <a class="link" href="s04.html#idx_id_61">I</a> <a class="link" href="s04.html#idx_id_62">L</a> <a class="link" href="s04.html#idx_id_63">M</a> <a class="link" href="s04.html#idx_id_64">N</a> <a class="link" href="s04.html#idx_id_65">O</a> <a class="link" href="s04.html#idx_id_66">P</a> <a class="link" href="s04.html#idx_id_67">R</a> <a class="link" href="s04.html#idx_id_68">S</a> <a class="link" href="s04.html#idx_id_69">T</a> <a class="link" href="s04.html#idx_id_70">U</a> <a class="link" href="s04.html#idx_id_71">Z</a></p>
<div class="variablelist"><dl class="variablelist">
<dt>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -87,24 +87,39 @@
<span class="identifier">my_float</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">;</span> <span class="comment">// These variables have 300 decimal digits precision</span>
</pre>
<p>
- Note that mixing arithmetic operations using types of different precision is
- strictly forbidden:
+ We can also mix arithmetic operations between different types, provided there
+ is an unambiguous implicit conversion from one type to the other:
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">cpp_int</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<span class="keyword">namespace</span> <span class="identifier">mp</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">;</span> <span class="comment">// Reduce the typing a bit later...</span>
-<span class="identifier">mp</span><span class="special">::</span><span class="identifier">int128_t</span> <span class="identifier">a</span><span class="special">(</span><span class="number">3</span><span class="special">),</span> <span class="identifier">b</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
+<span class="identifier">mp</span><span class="special">::</span><span class="identifier">int128_t</span> <span class="identifier">a</span><span class="special">(</span><span class="number">3</span><span class="special">),</span> <span class="identifier">b</span><span class="special">(</span><span class="number">4</span><span class="special">);</span>
<span class="identifier">mp</span><span class="special">::</span><span class="identifier">int512_t</span> <span class="identifier">c</span><span class="special">(</span><span class="number">50</span><span class="special">),</span> <span class="identifier">d</span><span class="special">;</span>
-<span class="identifier">d</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">*</span> <span class="identifier">a</span><span class="special">;</span> <span class="comment">// Compiler error</span>
+<span class="identifier">d</span> <span class="special">=</span> <span class="identifier">c</span> <span class="special">*</span> <span class="identifier">a</span><span class="special">;</span> <span class="comment">// OK, result of mixed arithmetic is an int512_t</span>
</pre>
<p>
- However, conversions are allowed:
+ Conversions are also allowed:
</p>
<pre class="programlisting"><span class="identifier">d</span> <span class="special">=</span> <span class="identifier">a</span><span class="special">;</span> <span class="comment">// OK, widening conversion.</span>
<span class="identifier">d</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">*</span> <span class="identifier">b</span><span class="special">;</span> <span class="comment">// OK, can convert from an expression template too.</span>
-<span class="identifier">d</span> <span class="special">=</span> <span class="identifier">mp</span><span class="special">::</span><span class="identifier">int512_t</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span> <span class="special">*</span> <span class="identifier">c</span><span class="special">;</span> <span class="comment">// OK, all the types in the expression are the same now.</span>
+</pre>
+<p>
+ However conversions that are inherently lossy are either declared explicit
+ or else forbidden altogether:
+ </p>
+<pre class="programlisting"><span class="identifier">d</span> <span class="special">=</span> <span class="number">3.14</span><span class="special">;</span> <span class="comment">// Error implicit conversion from float not allowed.</span>
+<span class="identifier">d</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">mp</span><span class="special">::</span><span class="identifier">int512_t</span><span class="special">>(</span><span class="number">3.14</span><span class="special">);</span> <span class="comment">// OK explicit construction is allowed</span>
+</pre>
+<p>
+ Mixed arithmetic will fail if the conversion is either ambiguous or explicit:
+ </p>
+<pre class="programlisting"><span class="identifier">number</span><span class="special"><</span><span class="identifier">cpp_int_backend</span><span class="special"><>,</span> <span class="keyword">false</span><span class="special">></span> <span class="identifier">a</span><span class="special">(</span><span class="number">2</span><span class="special">);</span>
+<span class="identifier">number</span><span class="special"><</span><span class="identifier">cpp_int_backend</span><span class="special"><>,</span> <span class="keyword">true</span><span class="special">></span> <span class="identifier">b</span><span class="special">(</span><span class="number">3</span><span class="special">);</span>
+
+<span class="identifier">b</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">*</span> <span class="identifier">b</span><span class="special">;</span> <span class="comment">// Error, implicit conversion could go either way.</span>
+<span class="identifier">b</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">*</span> <span class="number">3.14</span><span class="special">;</span> <span class="comment">// Error, no operator overload if the conversion would be explicit.</span>
</pre>
<h5>
<a name="boost_multiprecision.intro.h0"></a>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -342,7 +342,8 @@
An expression template derived from <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">></span></code>.
</li>
<li class="listitem">
- Any type implicitly convertible to <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span></code>.
+ Any type implicitly convertible to <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span></code>, including some other instance of
+ class <code class="computeroutput"><span class="identifier">number</span></code>.
</li>
</ul></div>
<p>
@@ -350,10 +351,6 @@
type with a positive value (negative values result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code>
being thrown).
</p>
-<p>
- Note that all the types involved in the expression must evaluate to the same
- type - which is to say we cannot mix a <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">B1</span><span class="special">></span></code> with a <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">B2</span><span class="special">></span></code> where B1 and B2 are different types.
- </p>
<pre class="programlisting"><span class="keyword">operator</span> <span class="emphasis"><em>convertible-to-bool-type</em></span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
@@ -483,11 +480,12 @@
<li class="listitem">
An expression template type derived from <code class="computeroutput"><span class="identifier">number</span></code>.
</li>
+<li class="listitem">
+ Any type for which <code class="computeroutput"><span class="identifier">number</span></code>
+ has an implicit constructor - for example a builtin arithmetic type.
+ </li>
</ul></div>
<p>
- In addition, one of the two arguments may be a builtin arithmetic type.
- </p>
-<p>
The return type of these operators is either:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
@@ -508,10 +506,6 @@
</li>
</ul></div>
<p>
- Note that all the types involved in the expression must evaluate to the same
- type - which is to say we cannot mix a <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">B1</span><span class="special">></span></code> with a <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">B2</span><span class="special">></span></code> where B1 and B2 are different types.
- </p>
-<p>
Finally note that the second argument to the left and right shift operations
must be a builtin integer type, and that the argument must be positive (negative
arguments result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code>
Modified: sandbox/big_number/libs/multiprecision/doc/html/index.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/index.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/index.html 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -120,7 +120,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: August 30, 2012 at 17:55:33 GMT</small></p></td>
+<td align="left"><p><small>Last revised: September 04, 2012 at 17:13:56 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk (original)
+++ sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -99,22 +99,35 @@
my_float a, b, c; // These variables have 300 decimal digits precision
-Note that mixing arithmetic operations using types of different precision is strictly forbidden:
+We can also mix arithmetic operations between different types, provided there is an unambiguous implicit conversion from one
+type to the other:
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision; // Reduce the typing a bit later...
- mp::int128_t a(3), b(2);
+ mp::int128_t a(3), b(4);
mp::int512_t c(50), d;
- d = c * a; // Compiler error
+ d = c * a; // OK, result of mixed arithmetic is an int512_t
-However, conversions are allowed:
+Conversions are also allowed:
d = a; // OK, widening conversion.
d = a * b; // OK, can convert from an expression template too.
- d = mp::int512_t(a) * c; // OK, all the types in the expression are the same now.
+
+However conversions that are inherently lossy are either declared explicit or else forbidden altogether:
+
+ d = 3.14; // Error implicit conversion from float not allowed.
+ d = static_cast<mp::int512_t>(3.14); // OK explicit construction is allowed
+
+Mixed arithmetic will fail if the conversion is either ambiguous or explicit:
+
+ number<cpp_int_backend<>, false> a(2);
+ number<cpp_int_backend<>, true> b(3);
+
+ b = a * b; // Error, implicit conversion could go either way.
+ b = a * 3.14; // Error, no operator overload if the conversion would be explicit.
[h4 Move Semantics]
@@ -1319,14 +1332,11 @@
* Another `number<Backend, ExpressionTemplates>`.
* An expression template derived from `number<Backend>`.
-* Any type implicitly convertible to `number<Backend, ExpressionTemplates>`.
+* Any type implicitly convertible to `number<Backend, ExpressionTemplates>`, including some other instance of class `number`.
For the left and right shift operations, the argument must be a builtin
integer type with a positive value (negative values result in a `std::runtime_error` being thrown).
-Note that all the types involved in the expression must evaluate to the same type - which is to say
-we cannot mix a `number<B1>` with a `number<B2>` where B1 and B2 are different types.
-
operator ``['convertible-to-bool-type]``()const;
Returns an ['unmentionable-type] that is usable in Boolean contexts (this allows `number` to be used in any
@@ -1418,8 +1428,7 @@
* A `number`.
* An expression template type derived from `number`.
-
-In addition, one of the two arguments may be a builtin arithmetic type.
+* Any type for which `number` has an implicit constructor - for example a builtin arithmetic type.
The return type of these operators is either:
@@ -1427,9 +1436,6 @@
* Type `number<Backend, false>` when `ExpressionTemplates` is `false`.
* Type `bool` if the operator is a comparison operator.
-Note that all the types involved in the expression must evaluate to the same type - which is to say
-we cannot mix a `number<B1>` with a `number<B2>` where B1 and B2 are different types.
-
Finally note that the second argument to the left and right shift operations must be a builtin integer type,
and that the argument must be positive (negative arguments result in a `std::runtime_error` being thrown).
Added: sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_01.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_01.cpp 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -0,0 +1,17 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ number<cpp_dec_float<50>, true> a(2);
+ number<cpp_dec_float<50>, false> b(2);
+
+ a = a + b;
+}
+
Added: sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_02.cpp
==============================================================================
--- (empty file)
+++ sandbox/big_number/libs/multiprecision/test/compile_fail/operator_fail_02.cpp 2012-09-04 13:18:18 EDT (Tue, 04 Sep 2012)
@@ -0,0 +1,18 @@
+///////////////////////////////////////////////////////////////////////////////
+// Copyright 2012 John Maddock. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/multiprecision/cpp_dec_float.hpp>
+#include <boost/multiprecision/cpp_int.hpp>
+
+using namespace boost::multiprecision;
+
+int main()
+{
+ cpp_dec_float_50 a(2);
+ cpp_int b(2);
+
+ a = a + b;
+}
+
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