summaryrefslogtreecommitdiff
path: root/boost/multiprecision
diff options
context:
space:
mode:
Diffstat (limited to 'boost/multiprecision')
-rw-r--r--boost/multiprecision/cpp_bin_float.hpp15
-rw-r--r--boost/multiprecision/cpp_bin_float/io.hpp4
-rw-r--r--boost/multiprecision/cpp_dec_float.hpp31
-rw-r--r--boost/multiprecision/cpp_int.hpp102
-rw-r--r--boost/multiprecision/cpp_int/misc.hpp5
-rw-r--r--boost/multiprecision/detail/default_ops.hpp73
-rw-r--r--boost/multiprecision/detail/float_string_cvt.hpp4
-rw-r--r--boost/multiprecision/detail/number_base.hpp34
-rw-r--r--boost/multiprecision/detail/number_compare.hpp24
-rw-r--r--boost/multiprecision/float128.hpp67
-rw-r--r--boost/multiprecision/gmp.hpp53
-rw-r--r--boost/multiprecision/mpfr.hpp2
-rw-r--r--boost/multiprecision/number.hpp43
-rw-r--r--boost/multiprecision/rational_adaptor.hpp12
-rw-r--r--boost/multiprecision/tommath.hpp4
15 files changed, 346 insertions, 127 deletions
diff --git a/boost/multiprecision/cpp_bin_float.hpp b/boost/multiprecision/cpp_bin_float.hpp
index cc2454c243..9a4ceff587 100644
--- a/boost/multiprecision/cpp_bin_float.hpp
+++ b/boost/multiprecision/cpp_bin_float.hpp
@@ -67,9 +67,9 @@ private:
exponent_type m_exponent;
bool m_sign;
public:
- cpp_bin_float() : m_data(), m_exponent(exponent_nan), m_sign(false) {}
+ cpp_bin_float() BOOST_NOEXCEPT_IF(noexcept(rep_type())) : m_data(), m_exponent(exponent_nan), m_sign(false) {}
- cpp_bin_float(const cpp_bin_float &o)
+ cpp_bin_float(const cpp_bin_float &o) BOOST_NOEXCEPT_IF(noexcept(rep_type(std::declval<const rep_type&>())))
: m_data(o.m_data), m_exponent(o.m_exponent), m_sign(o.m_sign) {}
template <unsigned D, digit_base_type B, class A, class E, E MinE, E MaxE>
@@ -104,7 +104,7 @@ public:
this->assign_float(f);
}
- cpp_bin_float& operator=(const cpp_bin_float &o)
+ cpp_bin_float& operator=(const cpp_bin_float &o) BOOST_NOEXCEPT_IF(noexcept(std::declval<rep_type&>() = std::declval<const rep_type&>()))
{
m_data = o.m_data;
m_exponent = o.m_exponent;
@@ -136,6 +136,7 @@ public:
{
BOOST_MATH_STD_USING
using default_ops::eval_add;
+ typedef typename boost::multiprecision::detail::canonical<int, cpp_bin_float>::type bf_int_type;
switch((boost::math::fpclassify)(f))
{
@@ -174,10 +175,16 @@ public:
{
f = ldexp(f, bits);
e -= bits;
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
int ipart = itrunc(f);
+#else
+ int ipart = static_cast<int>(f);
+#endif
f -= ipart;
m_exponent += bits;
- eval_add(*this, ipart);
+ cpp_bin_float t;
+ t = static_cast<bf_int_type>(ipart);
+ eval_add(*this, t);
}
m_exponent += static_cast<Exponent>(e);
return *this;
diff --git a/boost/multiprecision/cpp_bin_float/io.hpp b/boost/multiprecision/cpp_bin_float/io.hpp
index 6ad0f7ce32..ae3ab38e1d 100644
--- a/boost/multiprecision/cpp_bin_float/io.hpp
+++ b/boost/multiprecision/cpp_bin_float/io.hpp
@@ -496,7 +496,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s
// Fixed precision, no significant digits, and nothing to round!
s = "0";
if(sign())
- s.insert(0, 1, '-');
+ s.insert(static_cast<std::string::size_type>(0), 1, '-');
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, true);
return s;
}
@@ -661,7 +661,7 @@ std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::s
}
if(sign())
- s.insert(0, 1, '-');
+ s.insert(static_cast<std::string::size_type>(0), 1, '-');
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, false);
}
diff --git a/boost/multiprecision/cpp_dec_float.hpp b/boost/multiprecision/cpp_dec_float.hpp
index 8fc97250a4..d19abafec4 100644
--- a/boost/multiprecision/cpp_dec_float.hpp
+++ b/boost/multiprecision/cpp_dec_float.hpp
@@ -165,7 +165,7 @@ private:
public:
// Constructors
- cpp_dec_float() :
+ cpp_dec_float() BOOST_NOEXCEPT_IF(noexcept(array_type())) :
data(),
exp (static_cast<ExponentType>(0)),
neg (false),
@@ -210,7 +210,7 @@ public:
from_unsigned_long_long(i);
}
- cpp_dec_float(const cpp_dec_float& f) :
+ cpp_dec_float(const cpp_dec_float& f) BOOST_NOEXCEPT_IF(noexcept(array_type(std::declval<const array_type&>()))) :
data (f.data),
exp (f.exp),
neg (f.neg),
@@ -326,14 +326,22 @@ public:
static const cpp_dec_float& long_double_min()
{
init.do_nothing();
+#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+ static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::min)()));
+#else
static cpp_dec_float val((std::numeric_limits<long double>::min)());
+#endif
return val;
}
static const cpp_dec_float& long_double_max()
{
init.do_nothing();
+#ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+ static cpp_dec_float val(static_cast<long double>((std::numeric_limits<double>::max)()));
+#else
static cpp_dec_float val((std::numeric_limits<long double>::max)());
+#endif
return val;
}
@@ -366,7 +374,7 @@ public:
}
// Basic operations.
- cpp_dec_float& operator=(const cpp_dec_float& v)
+ cpp_dec_float& operator=(const cpp_dec_float& v) BOOST_NOEXCEPT_IF(noexcept(std::declval<array_type&>() = std::declval<const array_type&>()))
{
data = v.data;
exp = v.exp;
@@ -1767,7 +1775,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
// We only get here if the output format is "fixed" and we just need to
// round the first non-zero digit.
number_of_digits -= my_exp + 1; // reset to original value
- str.insert(0, std::string::size_type(number_of_digits), '0');
+ str.insert(static_cast<std::string::size_type>(0), std::string::size_type(number_of_digits), '0');
have_leading_zeros = true;
}
@@ -1775,7 +1783,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
{
str = "0";
if(isneg())
- str.insert(0, 1, '-');
+ str.insert(static_cast<std::string::size_type>(0), 1, '-');
boost::multiprecision::detail::format_float_string(str, 0, number_of_digits - my_exp - 1, f, this->iszero());
return str;
}
@@ -1866,7 +1874,7 @@ std::string cpp_dec_float<Digits10, ExponentType, Allocator>::str(boost::intmax_
}
if(isneg())
- str.insert(0, 1, '-');
+ str.insert(static_cast<std::string::size_type>(0), 1, '-');
boost::multiprecision::detail::format_float_string(str, my_exp, org_digits, f, this->iszero());
return str;
@@ -1963,7 +1971,7 @@ bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* con
// Remove all trailing insignificant zeros.
const std::string::const_reverse_iterator rit_non_zero = std::find_if(str.rbegin(), str.rend(), char_is_nonzero_predicate);
- if(rit_non_zero != str.rbegin())
+ if(rit_non_zero != static_cast<std::string::const_reverse_iterator>(str.rbegin()))
{
const std::string::size_type ofs = str.length() - std::distance<std::string::const_reverse_iterator>(str.rbegin(), rit_non_zero);
str.erase(str.begin() + ofs, str.end());
@@ -1993,7 +2001,7 @@ bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* con
// Bring one single digit into the mantissa and adjust the exponent accordingly.
str.erase(str.begin(), it_non_zero);
- str.insert(static_cast<std::size_t>(1u), ".");
+ str.insert(static_cast<std::string::size_type>(1u), ".");
exp -= static_cast<ExponentType>(delta_exp + 1u);
}
}
@@ -2029,9 +2037,9 @@ bool cpp_dec_float<Digits10, ExponentType, Allocator>::rd_string(const char* con
// Do the decimal point shift.
if(n_shift != static_cast<std::size_t>(0u))
{
- str.insert(static_cast<std::size_t>(pos_plus_one + n_shift), ".");
+ str.insert(static_cast<std::string::size_type>(pos_plus_one + n_shift), ".");
- str.erase(pos, static_cast<std::size_t>(1u));
+ str.erase(pos, static_cast<std::string::size_type>(1u));
exp -= static_cast<ExponentType>(n_shift);
}
@@ -2224,6 +2232,8 @@ cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, Expone
*this = zero();
f = frexp(a, &e);
+ // See https://svn.boost.org/trac/boost/ticket/10924 for an example of why this may go wrong:
+ BOOST_ASSERT((boost::math::isfinite)(f));
static const int shift = std::numeric_limits<int>::digits - 1;
@@ -2231,6 +2241,7 @@ cpp_dec_float<Digits10, ExponentType, Allocator>& cpp_dec_float<Digits10, Expone
{
// extract int sized bits from f:
f = ldexp(f, shift);
+ BOOST_ASSERT((boost::math::isfinite)(f));
term = floor(f);
e -= shift;
*this *= pow2(shift);
diff --git a/boost/multiprecision/cpp_int.hpp b/boost/multiprecision/cpp_int.hpp
index 2713b7ec11..311f7c16da 100644
--- a/boost/multiprecision/cpp_int.hpp
+++ b/boost/multiprecision/cpp_int.hpp
@@ -1,4 +1,4 @@
-///////////////////////////////////////////////////////////////
+//////////////////3/////////////////////////////////////////////
// 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_
@@ -354,6 +354,9 @@ public:
std::swap(m_internal, o.m_internal);
std::swap(m_limbs, o.m_limbs);
}
+protected:
+ template <class A>
+ void check_in_range(const A&) BOOST_NOEXCEPT {}
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
@@ -477,9 +480,11 @@ public:
if((m_limbs == 1) && (!*p)) m_sign = false; // zero is always unsigned
}
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() : m_wrapper(limb_type(0u)), m_limbs(1), m_sign(false) {}
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base()BOOST_NOEXCEPT : m_wrapper(limb_type(0u)), m_limbs(1), m_sign(false) {}
+ // Not defaulted, it breaks constexpr support in the Intel compiler for some reason:
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& o)BOOST_NOEXCEPT
+ : m_wrapper(o.m_wrapper), m_limbs(o.m_limbs), m_sign(o.m_sign) {}
// Defaulted functions:
- //BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& i)BOOST_NOEXCEPT;
//~cpp_int_base() BOOST_NOEXCEPT {}
void assign(const cpp_int_base& o) BOOST_NOEXCEPT
@@ -512,6 +517,9 @@ public:
std::swap(m_sign, o.m_sign);
std::swap(m_limbs, o.m_limbs);
}
+protected:
+ template <class A>
+ void check_in_range(const A&) BOOST_NOEXCEPT {}
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
@@ -615,8 +623,9 @@ public:
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() BOOST_NOEXCEPT
: m_wrapper(limb_type(0u)), m_limbs(1) {}
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT
+ : m_wrapper(o.m_wrapper), m_limbs(o.m_limbs) {}
// Defaulted functions:
- //BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT;
//~cpp_int_base() BOOST_NOEXCEPT {}
BOOST_MP_FORCEINLINE void assign(const cpp_int_base& o) BOOST_NOEXCEPT
@@ -660,6 +669,9 @@ public:
std::swap(m_wrapper.m_data[i], o.m_wrapper.m_data[i]);
std::swap(m_limbs, o.m_limbs);
}
+protected:
+ template <class A>
+ void check_in_range(const A&) BOOST_NOEXCEPT {}
};
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
@@ -735,10 +747,10 @@ protected:
BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent."));
}
template <class T, int C>
- void check_in_range(T, const mpl::int_<C>&){}
+ void check_in_range(T, const mpl::int_<C>&) BOOST_NOEXCEPT {}
template <class T>
- void check_in_range(T val)
+ void check_in_range(T val) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type())))
{
check_in_range(val, checked_type());
}
@@ -748,34 +760,34 @@ public:
// Direct construction:
//
template <class SI>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<SI>())))
: m_data(i < 0 ? static_cast<local_limb_type>(static_cast<typename make_unsigned<SI>::type>(boost::multiprecision::detail::unsigned_abs(i)) & limb_mask) : static_cast<local_limb_type>(i)& limb_mask), m_sign(i < 0) {}
template <class SI>
- BOOST_MP_FORCEINLINE cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<SI>())))
: m_data(i < 0 ? (static_cast<local_limb_type>(static_cast<typename make_unsigned<SI>::type>(boost::multiprecision::detail::unsigned_abs(i)) & limb_mask)) : static_cast<local_limb_type>(i)& limb_mask), m_sign(i < 0)
{ check_in_range(i); }
template <class UI>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == unchecked)>::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == unchecked)>::type const* = 0) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(i) & limb_mask), m_sign(false) {}
template <class UI>
- BOOST_MP_FORCEINLINE cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == checked)>::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == checked)>::type const* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<UI>())))
: m_data(static_cast<local_limb_type>(i) & limb_mask), m_sign(false) { check_in_range(i); }
template <class F>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(F i, typename boost::enable_if_c<is_floating_point<F>::value && (Checked == unchecked)>::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(F i, typename boost::enable_if_c<is_floating_point<F>::value && (Checked == unchecked)>::type const* = 0) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(std::fabs(i)) & limb_mask), m_sign(i < 0) {}
template <class F>
- BOOST_MP_FORCEINLINE cpp_int_base(F i, typename boost::enable_if_c<is_floating_point<F>::value && (Checked == checked)>::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE cpp_int_base(F i, typename boost::enable_if_c<is_floating_point<F>::value && (Checked == checked)>::type const* = 0)
: m_data(static_cast<local_limb_type>(std::fabs(i)) & limb_mask), m_sign(i < 0) { check_in_range(i); }
#if defined(BOOST_MP_USER_DEFINED_LITERALS)
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<>) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(0u)), m_sign(false) {}
template <limb_type a>
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a>)BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(a)), m_sign(false) {}
template <limb_type a, limb_type b>
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a, b>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a, b>)BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(a) | (static_cast<local_limb_type>(b) << bits_per_limb)), m_sign(false) {}
- BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& a, const literals::detail::negate_tag&)
+ BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& a, const literals::detail::negate_tag&)BOOST_NOEXCEPT
: m_data(a.m_data), m_sign(a.m_data ? !a.m_sign : false) {}
#endif
//
@@ -806,7 +818,7 @@ public:
m_data &= limb_mask;
}
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() : m_data(0), m_sign(false) {}
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() BOOST_NOEXCEPT : m_data(0), m_sign(false) {}
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT
: m_data(o.m_data), m_sign(o.m_sign) {}
//~cpp_int_base() BOOST_NOEXCEPT {}
@@ -860,7 +872,7 @@ private:
protected:
template <class T>
typename boost::disable_if_c<std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits)>::type
- check_in_range(T val, const mpl::int_<checked>&, const mpl::false_&)
+ check_in_range(T val, const mpl::int_<checked>&, const boost::false_type&)
{
typedef typename common_type<T, local_limb_type>::type common_type;
@@ -868,7 +880,7 @@ protected:
BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent."));
}
template <class T>
- void check_in_range(T val, const mpl::int_<checked>&, const mpl::true_&)
+ void check_in_range(T val, const mpl::int_<checked>&, const boost::true_type&)
{
typedef typename common_type<T, local_limb_type>::type common_type;
@@ -878,10 +890,10 @@ protected:
BOOST_THROW_EXCEPTION(std::range_error("The argument to an unsigned cpp_int constructor was negative."));
}
template <class T, int C, bool B>
- BOOST_MP_FORCEINLINE void check_in_range(T, const mpl::int_<C>&, const mpl::bool_<B>&){}
+ BOOST_MP_FORCEINLINE void check_in_range(T, const mpl::int_<C>&, const boost::integral_constant<bool, B>&) BOOST_NOEXCEPT {}
template <class T>
- BOOST_MP_FORCEINLINE void check_in_range(T val)
+ BOOST_MP_FORCEINLINE void check_in_range(T val) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type(), is_signed<T>())))
{
check_in_range(val, checked_type(), is_signed<T>());
}
@@ -891,16 +903,16 @@ public:
// Direct construction:
//
template <class SI>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT
: m_data(i < 0 ? (1 + ~static_cast<local_limb_type>(-i)) & limb_mask : static_cast<local_limb_type>(i) & limb_mask) {}
template <class SI>
- BOOST_MP_FORCEINLINE cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE cpp_int_base(SI i, typename boost::enable_if_c<is_signed<SI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<SI>())))
: m_data(i < 0 ? 1 + ~static_cast<local_limb_type>(-i) : static_cast<local_limb_type>(i)) { check_in_range(i); }
template <class UI>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == unchecked) >::type const* = 0) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(i) & limb_mask) {}
template <class UI>
- BOOST_MP_FORCEINLINE cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE cpp_int_base(UI i, typename boost::enable_if_c<is_unsigned<UI>::value && (Checked == checked) >::type const* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<UI>())))
: m_data(static_cast<local_limb_type>(i)) { check_in_range(i); }
template <class F>
BOOST_MP_FORCEINLINE cpp_int_base(F i, typename boost::enable_if<is_floating_point<F> >::type const* = 0) BOOST_NOEXCEPT_IF((Checked == unchecked))
@@ -911,13 +923,13 @@ public:
negate();
}
#if defined(BOOST_MP_USER_DEFINED_LITERALS)
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<>) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(0u)) {}
template <limb_type a>
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a>) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(a)) {}
template <limb_type a, limb_type b>
- BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a, b>)
+ BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a, b>) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(a) | (static_cast<local_limb_type>(b) << bits_per_limb)) {}
#endif
//
@@ -942,7 +954,7 @@ public:
m_data &= limb_mask;
}
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() : m_data(0) {}
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base() BOOST_NOEXCEPT : m_data(0) {}
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& o) BOOST_NOEXCEPT
: m_data(o.m_data) {}
//~cpp_int_base() BOOST_NOEXCEPT {}
@@ -1039,7 +1051,7 @@ public:
// Direct construction from arithmetic type:
//
template <class Arg>
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_backend(Arg i, typename boost::enable_if_c<is_allowed_cpp_int_base_conversion<Arg, base_type>::value >::type const* = 0)BOOST_NOEXCEPT_IF((Checked == unchecked) && boost::is_void<Allocator>::value)
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR cpp_int_backend(Arg i, typename boost::enable_if_c<is_allowed_cpp_int_base_conversion<Arg, base_type>::value >::type const* = 0)BOOST_NOEXCEPT_IF(noexcept(base_type(std::declval<Arg>())))
: base_type(i) {}
private:
@@ -1128,13 +1140,13 @@ public:
: base_type(static_cast<const base_type&>(a), tag){}
#endif
- BOOST_MP_FORCEINLINE cpp_int_backend& operator = (const cpp_int_backend& o) BOOST_NOEXCEPT_IF((Checked == unchecked) && boost::is_void<Allocator>::value)
+ BOOST_MP_FORCEINLINE cpp_int_backend& operator = (const cpp_int_backend& o) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().assign(std::declval<const cpp_int_backend&>())))
{
this->assign(o);
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- BOOST_MP_FORCEINLINE cpp_int_backend& operator = (cpp_int_backend&& o) BOOST_NOEXCEPT_IF(boost::is_void<Allocator>::value)
+ BOOST_MP_FORCEINLINE cpp_int_backend& operator = (cpp_int_backend&& o) BOOST_NOEXCEPT_IF(noexcept(std::declval<base_type&>() = std::declval<base_type>()))
{
*static_cast<base_type*>(this) = static_cast<base_type&&>(o);
return *this;
@@ -1142,14 +1154,16 @@ public:
#endif
private:
template <class A>
- typename boost::enable_if<is_unsigned<A> >::type do_assign_arithmetic(A val, const mpl::true_&)
+ typename boost::enable_if<is_unsigned<A> >::type do_assign_arithmetic(A val, const mpl::true_&)
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>())))
{
this->check_in_range(val);
*this->limbs() = static_cast<typename self_type::local_limb_type>(val);
this->normalize();
}
template <class A>
- typename boost::disable_if_c<is_unsigned<A>::value || !is_integral<A>::value >::type do_assign_arithmetic(A val, const mpl::true_&)
+ typename boost::disable_if_c<is_unsigned<A>::value || !is_integral<A>::value >::type do_assign_arithmetic(A val, const mpl::true_&)
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>())) && noexcept(std::declval<cpp_int_backend>().sign(true)))
{
this->check_in_range(val);
*this->limbs() = (val < 0) ? static_cast<typename self_type::local_limb_type>(boost::multiprecision::detail::unsigned_abs(val)) : static_cast<typename self_type::local_limb_type>(val);
@@ -1170,13 +1184,13 @@ private:
*this->limbs() = i;
this->sign(false);
}
- BOOST_MP_FORCEINLINE void do_assign_arithmetic(signed_limb_type i, const mpl::false_&) BOOST_NOEXCEPT_IF((Checked == unchecked))
+ BOOST_MP_FORCEINLINE void do_assign_arithmetic(signed_limb_type i, const mpl::false_&) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true)))
{
this->resize(1, 1);
*this->limbs() = static_cast<limb_type>(boost::multiprecision::detail::unsigned_abs(i));
this->sign(i < 0);
}
- void do_assign_arithmetic(double_limb_type i, const mpl::false_&)
+ void do_assign_arithmetic(double_limb_type i, const mpl::false_&) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT(sizeof(i) == 2 * sizeof(limb_type));
BOOST_STATIC_ASSERT(base_type::internal_limb_count >= 2);
@@ -1186,7 +1200,7 @@ private:
this->resize(p[1] ? 2 : 1, p[1] ? 2 : 1);
this->sign(false);
}
- void do_assign_arithmetic(signed_double_limb_type i, const mpl::false_&)
+ void do_assign_arithmetic(signed_double_limb_type i, const mpl::false_&) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true)))
{
BOOST_STATIC_ASSERT(sizeof(i) == 2 * sizeof(limb_type));
BOOST_STATIC_ASSERT(base_type::internal_limb_count >= 2);
@@ -1249,7 +1263,7 @@ private:
}
public:
template <class Arithmetic>
- BOOST_MP_FORCEINLINE cpp_int_backend& operator = (Arithmetic val)
+ BOOST_MP_FORCEINLINE cpp_int_backend& operator = (Arithmetic val) BOOST_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().do_assign_arithmetic(std::declval<Arithmetic>(), trivial_tag())))
{
do_assign_arithmetic(val, trivial_tag());
return *this;
@@ -1477,7 +1491,7 @@ private:
if(f & std::ios_base::showbase)
{
const char* pp = base == 8 ? "0" : "0x";
- result.insert(0, pp);
+ result.insert(static_cast<std::string::size_type>(0), pp);
}
}
else
@@ -1501,9 +1515,9 @@ private:
if(result.empty())
result = "0";
if(neg)
- result.insert(0, 1, '-');
+ result.insert(static_cast<std::string::size_type>(0), 1, '-');
else if(f & std::ios_base::showpos)
- result.insert(0, 1, '+');
+ result.insert(static_cast<std::string::size_type>(0), 1, '+');
}
return result;
}
@@ -1562,7 +1576,7 @@ private:
if(f & std::ios_base::showbase)
{
const char* pp = base == 8 ? "0" : "0x";
- result.insert(0, pp);
+ result.insert(static_cast<std::string::size_type>(0), pp);
}
}
else
@@ -1606,9 +1620,9 @@ private:
if(result.empty())
result = "0";
if(neg)
- result.insert(0, 1, '-');
+ result.insert(static_cast<std::string::size_type>(0), 1, '-');
else if(f & std::ios_base::showpos)
- result.insert(0, 1, '+');
+ result.insert(static_cast<std::string::size_type>(0), 1, '+');
}
return result;
}
diff --git a/boost/multiprecision/cpp_int/misc.hpp b/boost/multiprecision/cpp_int/misc.hpp
index 0ef79b9445..266edac2ed 100644
--- a/boost/multiprecision/cpp_int/misc.hpp
+++ b/boost/multiprecision/cpp_int/misc.hpp
@@ -9,6 +9,7 @@
#define BOOST_MP_CPP_INT_MISC_HPP
#include <boost/multiprecision/detail/bitscan.hpp> // lsb etc
+#include <boost/integer/common_factor_rt.hpp> // gcd/lcm
#ifdef BOOST_MSVC
#pragma warning(push)
@@ -505,14 +506,14 @@ template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_
BOOST_MP_FORCEINLINE typename enable_if_c<is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value>::type
eval_gcd(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& b) BOOST_NOEXCEPT
{
- *result.limbs() = boost::math::gcd(*a.limbs(), *b.limbs());
+ *result.limbs() = boost::integer::gcd(*a.limbs(), *b.limbs());
}
// This one is only enabled for unchecked cpp_int's, for checked int's we need the checking in the default version:
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
BOOST_MP_FORCEINLINE typename enable_if_c<is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && (Checked1 == unchecked)>::type
eval_lcm(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& b) BOOST_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value))
{
- *result.limbs() = boost::math::lcm(*a.limbs(), *b.limbs());
+ *result.limbs() = boost::integer::lcm(*a.limbs(), *b.limbs());
result.normalize(); // result may overflow the specified number of bits
}
diff --git a/boost/multiprecision/detail/default_ops.hpp b/boost/multiprecision/detail/default_ops.hpp
index 97ae1a279d..bf51a58295 100644
--- a/boost/multiprecision/detail/default_ops.hpp
+++ b/boost/multiprecision/detail/default_ops.hpp
@@ -1561,6 +1561,71 @@ inline long long llround(const number<T, ExpressionTemplates>& v)
return llround(v, boost::math::policies::policy<>());
}
#endif
+//
+// frexp does not return an expression template since we require the
+// integer argument to be evaluated even if the returned value is
+// not assigned to anything...
+//
+template <class T, expression_template_option ExpressionTemplates>
+inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, short* pint)
+{
+ using default_ops::eval_frexp;
+ number<T, ExpressionTemplates> result;
+ eval_frexp(result.backend(), v.backend(), pint);
+ return BOOST_MP_MOVE(result);
+}
+template <class tag, class A1, class A2, class A3, class A4>
+inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type
+ frexp(const detail::expression<tag, A1, A2, A3, A4>& v, short* pint)
+{
+ typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
+ return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint));
+}
+template <class T, expression_template_option ExpressionTemplates>
+inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, int* pint)
+{
+ using default_ops::eval_frexp;
+ number<T, ExpressionTemplates> result;
+ eval_frexp(result.backend(), v.backend(), pint);
+ return BOOST_MP_MOVE(result);
+}
+template <class tag, class A1, class A2, class A3, class A4>
+inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type
+frexp(const detail::expression<tag, A1, A2, A3, A4>& v, int* pint)
+{
+ typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
+ return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint));
+}
+template <class T, expression_template_option ExpressionTemplates>
+inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, long* pint)
+{
+ using default_ops::eval_frexp;
+ number<T, ExpressionTemplates> result;
+ eval_frexp(result.backend(), v.backend(), pint);
+ return BOOST_MP_MOVE(result);
+}
+template <class tag, class A1, class A2, class A3, class A4>
+inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type
+frexp(const detail::expression<tag, A1, A2, A3, A4>& v, long* pint)
+{
+ typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
+ return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint));
+}
+template <class T, expression_template_option ExpressionTemplates>
+inline typename enable_if_c<number_category<T>::value == number_kind_floating_point, number<T, ExpressionTemplates> >::type frexp(const number<T, ExpressionTemplates>& v, long long* pint)
+{
+ using default_ops::eval_frexp;
+ number<T, ExpressionTemplates> result;
+ eval_frexp(result.backend(), v.backend(), pint);
+ return BOOST_MP_MOVE(result);
+}
+template <class tag, class A1, class A2, class A3, class A4>
+inline typename enable_if_c<number_category<typename detail::expression<tag, A1, A2, A3, A4>::result_type>::value == number_kind_floating_point, typename detail::expression<tag, A1, A2, A3, A4>::result_type>::type
+frexp(const detail::expression<tag, A1, A2, A3, A4>& v, long long* pint)
+{
+ typedef typename detail::expression<tag, A1, A2, A3, A4>::result_type number_type;
+ return BOOST_MP_MOVE(frexp(static_cast<number_type>(v), pint));
+}
template <class B, expression_template_option ExpressionTemplates>
inline typename enable_if_c<number_category<B>::value == number_kind_integer, number<B, ExpressionTemplates> >::type
@@ -2034,13 +2099,13 @@ UNARY_OP_FUNCTOR(sinh, number_kind_floating_point)
UNARY_OP_FUNCTOR(tanh, number_kind_floating_point)
HETERO_BINARY_OP_FUNCTOR(ldexp, short, number_kind_floating_point)
-HETERO_BINARY_OP_FUNCTOR(frexp, short*, number_kind_floating_point)
+//HETERO_BINARY_OP_FUNCTOR(frexp, short*, number_kind_floating_point)
HETERO_BINARY_OP_FUNCTOR_B(ldexp, int, number_kind_floating_point)
-HETERO_BINARY_OP_FUNCTOR_B(frexp, int*, number_kind_floating_point)
+//HETERO_BINARY_OP_FUNCTOR_B(frexp, int*, number_kind_floating_point)
HETERO_BINARY_OP_FUNCTOR_B(ldexp, long, number_kind_floating_point)
-HETERO_BINARY_OP_FUNCTOR_B(frexp, long*, number_kind_floating_point)
+//HETERO_BINARY_OP_FUNCTOR_B(frexp, long*, number_kind_floating_point)
HETERO_BINARY_OP_FUNCTOR_B(ldexp, long long, number_kind_floating_point)
-HETERO_BINARY_OP_FUNCTOR_B(frexp, long long*, number_kind_floating_point)
+//HETERO_BINARY_OP_FUNCTOR_B(frexp, long long*, number_kind_floating_point)
BINARY_OP_FUNCTOR(pow, number_kind_floating_point)
BINARY_OP_FUNCTOR(fmod, number_kind_floating_point)
BINARY_OP_FUNCTOR(atan2, number_kind_floating_point)
diff --git a/boost/multiprecision/detail/float_string_cvt.hpp b/boost/multiprecision/detail/float_string_cvt.hpp
index 7ce246a240..9b5774f1af 100644
--- a/boost/multiprecision/detail/float_string_cvt.hpp
+++ b/boost/multiprecision/detail/float_string_cvt.hpp
@@ -24,7 +24,7 @@ inline void round_string_up_at(std::string& s, int pos, I& expon)
//
if(pos < 0)
{
- s.insert(0, 1, '1');
+ s.insert(static_cast<std::string::size_type>(0), 1, '1');
s.erase(s.size() - 1);
++expon;
}
@@ -182,7 +182,7 @@ std::string convert_to_string(Backend b, std::streamsize digits, std::ios_base::
}
BOOST_ASSERT(org_digits >= 0);
if(isneg)
- result.insert(0, 1, '-');
+ result.insert(static_cast<std::string::size_type>(0), 1, '-');
format_float_string(result, expon, org_digits, f, iszero);
return result;
diff --git a/boost/multiprecision/detail/number_base.hpp b/boost/multiprecision/detail/number_base.hpp
index 9353082d37..09c86e6ce0 100644
--- a/boost/multiprecision/detail/number_base.hpp
+++ b/boost/multiprecision/detail/number_base.hpp
@@ -145,6 +145,18 @@ struct canonical_imp<number<B, et_off>, Backend, Tag>
{
typedef B type;
};
+#ifdef __SUNPRO_CC
+template <class B, class Backend>
+struct canonical_imp<number<B, et_on>, Backend, mpl::int_<3> >
+{
+ typedef B type;
+};
+template <class B, class Backend>
+struct canonical_imp<number<B, et_off>, Backend, mpl::int_<3> >
+{
+ typedef B type;
+};
+#endif
template <class Val, class Backend>
struct canonical_imp<Val, Backend, mpl::int_<0> >
{
@@ -606,9 +618,9 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
}
}
if(neg)
- str.insert(0, 1, '-');
+ str.insert(static_cast<std::string::size_type>(0), 1, '-');
else if(showpos)
- str.insert(0, 1, '+');
+ str.insert(static_cast<std::string::size_type>(0), 1, '+');
return;
}
@@ -653,8 +665,8 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
{
if(my_exp < 0)
{
- str.insert(0, static_cast<std::string::size_type>(-1 - my_exp), '0');
- str.insert(0, "0.");
+ str.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(-1 - my_exp), '0');
+ str.insert(static_cast<std::string::size_type>(0), "0.");
}
else
{
@@ -679,21 +691,21 @@ void format_float_string(S& str, boost::intmax_t my_exp, boost::intmax_t digits,
BOOST_MP_USING_ABS
// Scientific format:
if(showpoint || (str.size() > 1))
- str.insert(1, 1, '.');
- str.append(1, 'e');
+ str.insert(static_cast<std::string::size_type>(1u), 1, '.');
+ str.append(static_cast<std::string::size_type>(1u), 'e');
S e = boost::lexical_cast<S>(abs(my_exp));
if(e.size() < BOOST_MP_MIN_EXPONENT_DIGITS)
- e.insert(0, BOOST_MP_MIN_EXPONENT_DIGITS-e.size(), '0');
+ e.insert(static_cast<std::string::size_type>(0), BOOST_MP_MIN_EXPONENT_DIGITS - e.size(), '0');
if(my_exp < 0)
- e.insert(0, 1, '-');
+ e.insert(static_cast<std::string::size_type>(0), 1, '-');
else
- e.insert(0, 1, '+');
+ e.insert(static_cast<std::string::size_type>(0), 1, '+');
str.append(e);
}
if(neg)
- str.insert(0, 1, '-');
+ str.insert(static_cast<std::string::size_type>(0), 1, '-');
else if(showpos)
- str.insert(0, 1, '+');
+ str.insert(static_cast<std::string::size_type>(0), 1, '+');
}
template <class V>
diff --git a/boost/multiprecision/detail/number_compare.hpp b/boost/multiprecision/detail/number_compare.hpp
index bd01c3d6bb..d1606ad73d 100644
--- a/boost/multiprecision/detail/number_compare.hpp
+++ b/boost/multiprecision/detail/number_compare.hpp
@@ -93,8 +93,8 @@ struct is_valid_mixed_compare<expression<tag, Arg1, Arg2, Arg3, Arg4>, number<B,
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator == (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator == (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_eq;
return eval_eq(a.backend(), b.backend());
@@ -141,8 +141,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A
return eval_eq(t.backend(), t2.backend());
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator != (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator != (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_eq;
return !eval_eq(a.backend(), b.backend());
@@ -189,8 +189,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A
return !eval_eq(t.backend(), t2.backend());
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator < (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator < (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_lt;
return eval_lt(a.backend(), b.backend());
@@ -237,8 +237,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A
return eval_lt(t.backend(), t2.backend());
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator > (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator > (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_gt;
return eval_gt(a.backend(), b.backend());
@@ -285,8 +285,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A
return eval_gt(t.backend(), t2.backend());
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator <= (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator <= (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_gt;
return !eval_gt(a.backend(), b.backend());
@@ -333,8 +333,8 @@ inline typename enable_if<is_same<typename detail::expression<Tag, A1, A2, A3, A
return !eval_gt(t.backend(), t2.backend());
}
-template <class Backend, expression_template_option ExpressionTemplates>
-inline bool operator >= (const number<Backend, ExpressionTemplates>& a, const number<Backend, ExpressionTemplates>& b)
+template <class Backend, expression_template_option ExpressionTemplates, class Backend2, expression_template_option ExpressionTemplates2>
+inline bool operator >= (const number<Backend, ExpressionTemplates>& a, const number<Backend2, ExpressionTemplates2>& b)
{
using default_ops::eval_lt;
return !eval_lt(a.backend(), b.backend());
diff --git a/boost/multiprecision/float128.hpp b/boost/multiprecision/float128.hpp
index ac09519c3f..6e2958e07f 100644
--- a/boost/multiprecision/float128.hpp
+++ b/boost/multiprecision/float128.hpp
@@ -136,18 +136,18 @@ struct float128_backend
private:
float128_type m_value;
public:
- BOOST_CONSTEXPR float128_backend() : m_value(0) {}
- BOOST_CONSTEXPR float128_backend(const float128_backend& o) : m_value(o.m_value) {}
- float128_backend& operator = (const float128_backend& o)
+ BOOST_CONSTEXPR float128_backend() BOOST_NOEXCEPT : m_value(0) {}
+ BOOST_CONSTEXPR float128_backend(const float128_backend& o) BOOST_NOEXCEPT : m_value(o.m_value) {}
+ float128_backend& operator = (const float128_backend& o) BOOST_NOEXCEPT
{
m_value = o.m_value;
return *this;
}
template <class T>
- BOOST_CONSTEXPR float128_backend(const T& i, const typename enable_if_c<is_convertible<T, float128_type>::value>::type* = 0)
+ BOOST_CONSTEXPR float128_backend(const T& i, const typename enable_if_c<is_convertible<T, float128_type>::value>::type* = 0) BOOST_NOEXCEPT
: m_value(i) {}
template <class T>
- typename enable_if_c<is_arithmetic<T>::value || is_convertible<T, float128_type>::value, float128_backend&>::type operator = (const T& i)
+ typename enable_if_c<is_arithmetic<T>::value || is_convertible<T, float128_type>::value, float128_backend&>::type operator = (const T& i) BOOST_NOEXCEPT
{
m_value = i;
return *this;
@@ -166,7 +166,7 @@ public:
#endif
return *this;
}
- void swap(float128_backend& o)
+ void swap(float128_backend& o) BOOST_NOEXCEPT
{
std::swap(m_value, o.value());
}
@@ -209,7 +209,7 @@ public:
return boost::multiprecision::detail::convert_to_string(*this, digits ? digits : 37, f);
#endif
}
- void negate()
+ void negate() BOOST_NOEXCEPT
{
m_value = -m_value;
}
@@ -563,6 +563,59 @@ public:
BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
};
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_specialized;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::digits;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::digits10;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::max_digits10;
+
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_signed;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_integer;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_exact;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::radix;
+
+
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::min_exponent;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::max_exponent;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::min_exponent10;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const int numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::max_exponent10;
+
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::has_infinity;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::has_quiet_NaN;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::has_signaling_NaN;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::has_denorm_loss;
+
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_iec559;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_bounded;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::is_modulo;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::traps;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const bool numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::tinyness_before;
+
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::round_style;
+template <boost::multiprecision::expression_template_option ExpressionTemplates>
+const float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::float128_backend, ExpressionTemplates> >::has_denorm;
+
} // namespace std
diff --git a/boost/multiprecision/gmp.hpp b/boost/multiprecision/gmp.hpp
index d6da98ef2f..3b020d07c5 100644
--- a/boost/multiprecision/gmp.hpp
+++ b/boost/multiprecision/gmp.hpp
@@ -1216,10 +1216,10 @@ struct gmp_int
{
int pos = s[0] == '-' ? 1 : 0;
const char* pp = base == 8 ? "0" : "0x";
- s.insert(pos, pp);
+ s.insert(static_cast<std::string::size_type>(pos), pp);
}
if((f & std::ios_base::showpos) && (s[0] != '-'))
- s.insert(0, 1, '+');
+ s.insert(static_cast<std::string::size_type>(0), 1, '+');
return s;
}
@@ -2331,6 +2331,55 @@ private:
template<unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
const typename numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::data_initializer numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::initializer;
+#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
+
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::digits;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::digits10;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::max_digits10;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_signed;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_integer;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_exact;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::radix;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::min_exponent;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::min_exponent10;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::max_exponent;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::max_exponent10;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::has_infinity;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::has_quiet_NaN;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::has_signaling_NaN;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::has_denorm;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::has_denorm_loss;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_iec559;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_bounded;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::is_modulo;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::traps;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::tinyness_before;
+template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
+BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<Digits10>, ExpressionTemplates> >::round_style;
+
+#endif
+
template<boost::multiprecision::expression_template_option ExpressionTemplates>
class numeric_limits<boost::multiprecision::number<boost::multiprecision::gmp_float<0>, ExpressionTemplates> >
{
diff --git a/boost/multiprecision/mpfr.hpp b/boost/multiprecision/mpfr.hpp
index f66cf4ac41..36298c143e 100644
--- a/boost/multiprecision/mpfr.hpp
+++ b/boost/multiprecision/mpfr.hpp
@@ -624,7 +624,7 @@ struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationTy
mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {}
mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_backend(mpfr_float_backend&& o) : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o)) {}
+ mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o)) {}
#endif
template <unsigned D, mpfr_allocation_type AT>
mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename enable_if_c<D <= digits10>::type* = 0)
diff --git a/boost/multiprecision/number.hpp b/boost/multiprecision/number.hpp
index 54e83c5c50..c977958ea5 100644
--- a/boost/multiprecision/number.hpp
+++ b/boost/multiprecision/number.hpp
@@ -41,7 +41,7 @@ class number
public:
typedef Backend backend_type;
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number() BOOST_NOEXCEPT_IF(noexcept(Backend())) {}
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Backend&>(std::declval<Backend>())))) : m_backend(e.m_backend){}
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>()))) : m_backend(e.m_backend){}
template <class V>
BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c<
(boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value)
@@ -55,16 +55,21 @@ public:
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c<
is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
&& !detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
- >::type* = 0)
+ >::type* = 0)
+#ifndef BOOST_INTEL
+ BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<typename detail::canonical<V, Backend>::type const&>())))
+#endif
: m_backend(canonical_value(v)) {}
- BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e, unsigned digits10)
+ BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e, unsigned digits10)
+ BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>(), std::declval<unsigned>())))
: m_backend(e.m_backend, digits10){}
template <class V>
explicit BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c<
(boost::is_arithmetic<V>::value || is_same<std::string, V>::value || is_convertible<V, const char*>::value)
&& !detail::is_explicitly_convertible<typename detail::canonical<V, Backend>::type, Backend>::value
&& detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
- >::type* = 0)
+ >::type* = 0)
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<typename detail::canonical<V, Backend>::type const&>()))
{
m_backend = canonical_value(v);
}
@@ -74,6 +79,7 @@ public:
&& (detail::is_restricted_conversion<typename detail::canonical<V, Backend>::type, Backend>::value
|| !is_convertible<typename detail::canonical<V, Backend>::type, Backend>::value)
>::type* = 0)
+ BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<typename detail::canonical<V, Backend>::type const&>())))
: m_backend(canonical_value(v)) {}
/*
//
@@ -89,12 +95,12 @@ public:
*/
template<expression_template_option ET>
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number<Backend, ET>& val)
- BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Backend&>(std::declval<Backend>())))) : m_backend(val.backend()) {}
+ BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend const&>()))) : m_backend(val.backend()) {}
template <class Other, expression_template_option ET>
BOOST_MP_FORCEINLINE number(const number<Other, ET>& val,
typename boost::enable_if_c<(boost::is_convertible<Other, Backend>::value && !detail::is_restricted_conversion<Other, Backend>::value)>::type* = 0)
- BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Other&>(std::declval<Other>()))))
+ BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Other const&>())))
: m_backend(val.backend()) {}
template <class Other, expression_template_option ET>
@@ -111,7 +117,7 @@ public:
explicit BOOST_MP_FORCEINLINE number(const number<Other, ET>& val, typename boost::enable_if_c<
(detail::is_explicitly_convertible<Other, Backend>::value
&& (detail::is_restricted_conversion<Other, Backend>::value || !boost::is_convertible<Other, Backend>::value))
- >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast<const Other&>(std::declval<Other>()))))
+ >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Other const&>())))
: m_backend(val.backend()) {}
template <class V>
@@ -143,7 +149,7 @@ public:
}
BOOST_MP_FORCEINLINE number& operator=(const number& e)
- BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<const Backend&>(std::declval<Backend>())))
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<Backend const&>()))
{
m_backend = e.m_backend;
return *this;
@@ -152,14 +158,14 @@ public:
template <class V>
BOOST_MP_FORCEINLINE typename boost::enable_if<is_convertible<V, self_type>, number<Backend, ExpressionTemplates>& >::type
operator=(const V& v)
- BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<typename boost::multiprecision::detail::canonical<V, Backend>::type const&>(std::declval<typename boost::multiprecision::detail::canonical<V, Backend>::type>())))
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<const typename detail::canonical<V, Backend>::type&>()))
{
m_backend = canonical_value(v);
return *this;
}
template <class V>
BOOST_MP_FORCEINLINE number<Backend, ExpressionTemplates>& assign(const V& v)
- BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>() = static_cast<typename boost::multiprecision::detail::canonical<V, Backend>::type const&>(std::declval<typename boost::multiprecision::detail::canonical<V, Backend>::type>())))
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<const typename detail::canonical<V, Backend>::type&>()))
{
m_backend = canonical_value(v);
return *this;
@@ -192,7 +198,7 @@ public:
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(number&& r)
BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<Backend>())))
: m_backend(static_cast<Backend&&>(r.m_backend)){}
- BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT
+ BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend&>() = std::declval<Backend>()))
{
m_backend = static_cast<Backend&&>(r.m_backend);
return *this;
@@ -541,7 +547,7 @@ public:
//
// swap:
//
- BOOST_MP_FORCEINLINE void swap(self_type& other) BOOST_NOEXCEPT
+ BOOST_MP_FORCEINLINE void swap(self_type& other) BOOST_NOEXCEPT_IF(noexcept(std::declval<Backend>().swap(std::declval<Backend&>())))
{
m_backend.swap(other.backend());
}
@@ -1686,7 +1692,7 @@ inline std::ostream& operator << (std::ostream& os, const number<Backend, Expres
if((os.flags() & std::ios_base::left) == std::ios_base::left)
s.append(static_cast<std::string::size_type>(ss - s.size()), fill);
else
- s.insert(0, static_cast<std::string::size_type>(ss - s.size()), fill);
+ s.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(ss - s.size()), fill);
}
return os << s;
}
@@ -1719,7 +1725,8 @@ inline std::istream& operator >> (std::istream& is, number<Backend, ExpressionTe
}
template <class Backend, expression_template_option ExpressionTemplates>
-BOOST_MP_FORCEINLINE void swap(number<Backend, ExpressionTemplates>& a, number<Backend, ExpressionTemplates>& b)
+BOOST_MP_FORCEINLINE void swap(number<Backend, ExpressionTemplates>& a, number<Backend, ExpressionTemplates>& b)
+ BOOST_NOEXCEPT_IF(noexcept(std::declval<number<Backend, ExpressionTemplates>&>() = std::declval<number<Backend, ExpressionTemplates>&>()))
{
a.swap(b);
}
@@ -1747,9 +1754,9 @@ inline std::istream& operator >> (std::istream& is, rational<multiprecision::num
is.get();
}
if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
- s1.insert(0, "0x");
+ s1.insert(static_cast<std::string::size_type>(0), "0x");
if(oct_format && (s1[0] != '0'))
- s1.insert(0, "0");
+ s1.insert(static_cast<std::string::size_type>(0), "0");
v1.assign(s1);
s1.erase();
if(c == '/')
@@ -1763,9 +1770,9 @@ inline std::istream& operator >> (std::istream& is, rational<multiprecision::num
is.get();
}
if(hex_format && ((s1[0] != '0') || (s1[1] != 'x')))
- s1.insert(0, "0x");
+ s1.insert(static_cast<std::string::size_type>(0), "0x");
if(oct_format && (s1[0] != '0'))
- s1.insert(0, "0");
+ s1.insert(static_cast<std::string::size_type>(0), "0");
v2.assign(s1);
}
else
diff --git a/boost/multiprecision/rational_adaptor.hpp b/boost/multiprecision/rational_adaptor.hpp
index 94df3988c2..3e294aabb2 100644
--- a/boost/multiprecision/rational_adaptor.hpp
+++ b/boost/multiprecision/rational_adaptor.hpp
@@ -34,12 +34,12 @@ struct rational_adaptor
typedef typename IntBackend::unsigned_types unsigned_types;
typedef typename IntBackend::float_types float_types;
- rational_adaptor(){}
- rational_adaptor(const rational_adaptor& o)
+ rational_adaptor() BOOST_NOEXCEPT_IF(noexcept(rational_type())) {}
+ rational_adaptor(const rational_adaptor& o) BOOST_NOEXCEPT_IF(noexcept(std::declval<rational_type&>() = std::declval<const rational_type&>()))
{
m_value = o.m_value;
}
- rational_adaptor(const IntBackend& o) : m_value(o) {}
+ rational_adaptor(const IntBackend& o) BOOST_NOEXCEPT_IF(noexcept(rational_type(std::declval<const IntBackend&>()))) : m_value(o) {}
template <class U>
rational_adaptor(const U& u, typename enable_if_c<is_convertible<U, IntBackend>::value>::type* = 0)
@@ -57,9 +57,9 @@ struct rational_adaptor
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- rational_adaptor(rational_adaptor&& o) : m_value(o.m_value) {}
- rational_adaptor(IntBackend&& o) : m_value(o) {}
- rational_adaptor& operator = (rational_adaptor&& o)
+ rational_adaptor(rational_adaptor&& o) BOOST_NOEXCEPT_IF(noexcept(rational_type(std::declval<rational_type>()))) : m_value(static_cast<rational_type&&>(o.m_value)) {}
+ rational_adaptor(IntBackend&& o) BOOST_NOEXCEPT_IF(noexcept(rational_type(std::declval<IntBackend>()))) : m_value(static_cast<IntBackend&&>(o)) {}
+ rational_adaptor& operator = (rational_adaptor&& o) BOOST_NOEXCEPT_IF(noexcept(std::declval<rational_type&>() = std::declval<rational_type>()))
{
m_value = static_cast<rational_type&&>(o.m_value);
return *this;
diff --git a/boost/multiprecision/tommath.hpp b/boost/multiprecision/tommath.hpp
index f294056465..8abee83c4a 100644
--- a/boost/multiprecision/tommath.hpp
+++ b/boost/multiprecision/tommath.hpp
@@ -314,10 +314,10 @@ struct tommath_int
{
int pos = result[0] == '-' ? 1 : 0;
const char* pp = base == 8 ? "0" : "0x";
- result.insert(pos, pp);
+ result.insert(static_cast<std::string::size_type>(pos), pp);
}
if((f & std::ios_base::showpos) && (result[0] != '-'))
- result.insert(0, 1, '+');
+ result.insert(static_cast<std::string::size_type>(0), 1, '+');
return result;
}
~tommath_int()