diff --git a/include/boost/multiprecision/cpp_int.hpp b/include/boost/multiprecision/cpp_int.hpp index 20e77d77..23d91973 100644 --- a/include/boost/multiprecision/cpp_int.hpp +++ b/include/boost/multiprecision/cpp_int.hpp @@ -2811,7 +2811,7 @@ inline Integer negate_integer(Integer i, const mpl::true_&) BOOST_NOEXCEPT template inline Integer negate_integer(Integer i, const mpl::false_&) BOOST_NOEXCEPT { - return ~--i; + return ~(i-1); } template diff --git a/include/boost/multiprecision/detail/number_base.hpp b/include/boost/multiprecision/detail/number_base.hpp index 0d7fe45a..ab3e34fe 100644 --- a/include/boost/multiprecision/detail/number_base.hpp +++ b/include/boost/multiprecision/detail/number_base.hpp @@ -78,6 +78,16 @@ struct canonical_imp { typedef typename remove_cv::type>::type type; }; +template +struct canonical_imp, Backend, Tag> +{ + typedef B type; +}; +template +struct canonical_imp, Backend, Tag> +{ + typedef B type; +}; template struct canonical_imp > { diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index 55b38314..b30e7891 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -112,7 +112,7 @@ public: explicit BOOST_FORCEINLINE number(const number& val, typename enable_if_c< (detail::is_explicitly_convertible::value && (detail::is_restricted_conversion::value || !boost::is_convertible::value)) - >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval())) + >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(val.backend()) {} template @@ -148,13 +148,13 @@ public: do_assign(e, tag_type()); return *this; } -/* + BOOST_FORCEINLINE number& operator=(const number& e) BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast(std::declval()))) { m_backend = e.m_backend; return *this; } - */ + template BOOST_FORCEINLINE typename enable_if, number& >::type operator=(const V& v) BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval::type>())) @@ -603,6 +603,11 @@ explicit operator T()const { return this->template convert_to(); } +explicit operator bool()const +{ + using default_ops::eval_is_zero; + return !eval_is_zero(backend()); +} #endif // // Default precision: diff --git a/test/test_arithmetic.cpp b/test/test_arithmetic.cpp index 99c1bb8b..4a6f102f 100644 --- a/test/test_arithmetic.cpp +++ b/test/test_arithmetic.cpp @@ -485,16 +485,16 @@ void test_integer_ops(const boost::mpl::int_::is_signed) { @@ -516,17 +516,17 @@ void test_integer_ops(const boost::mpl::int_