diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index 21229348..c443fb67 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -44,8 +44,8 @@ public: BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) : m_backend(e.m_backend){} template BOOST_MP_FORCEINLINE number(const V& v, typename enable_if_c< - (boost::is_arithmetic::value || is_same::value || is_convertible::value) - && !is_convertible::type, Backend>::value + (boost::is_arithmetic::value || is_same::value || is_convertible::value) + && !is_convertible::type, Backend>::value && !detail::is_restricted_conversion::type, Backend>::value >::type* = 0) { @@ -53,16 +53,16 @@ public: } template BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename enable_if_c< - is_convertible::type, Backend>::value + is_convertible::type, Backend>::value && !detail::is_restricted_conversion::type, Backend>::value - >::type* = 0) + >::type* = 0) : m_backend(canonical_value(v)) {} BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e, unsigned digits10) : m_backend(e.m_backend, digits10){} template explicit BOOST_MP_FORCEINLINE number(const V& v, typename enable_if_c< - (boost::is_arithmetic::value || is_same::value || is_convertible::value) - && !detail::is_explicitly_convertible::type, Backend>::value + (boost::is_arithmetic::value || is_same::value || is_convertible::value) + && !detail::is_explicitly_convertible::type, Backend>::value && detail::is_restricted_conversion::type, Backend>::value >::type* = 0) { @@ -70,10 +70,10 @@ public: } template explicit BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename enable_if_c< - detail::is_explicitly_convertible::type, Backend>::value + detail::is_explicitly_convertible::type, Backend>::value && (detail::is_restricted_conversion::type, Backend>::value || !is_convertible::type, Backend>::value) - >::type* = 0) + >::type* = 0) : m_backend(canonical_value(v)) {} /* // @@ -88,12 +88,12 @@ public: } */ template - BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& val) + BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& val) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) : m_backend(val.backend()) {} template - BOOST_MP_FORCEINLINE number(const number& val, - typename enable_if_c<(boost::is_convertible::value && !detail::is_restricted_conversion::value)>::type* = 0) + BOOST_MP_FORCEINLINE number(const number& val, + typename enable_if_c<(boost::is_convertible::value && !detail::is_restricted_conversion::value)>::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) : m_backend(val.backend()) {} @@ -109,7 +109,7 @@ public: } template explicit BOOST_MP_FORCEINLINE number(const number& val, typename enable_if_c< - (detail::is_explicitly_convertible::value + (detail::is_explicitly_convertible::value && (detail::is_restricted_conversion::value || !boost::is_convertible::value)) >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) : m_backend(val.backend()) {} @@ -142,7 +142,7 @@ public: return *this; } - BOOST_MP_FORCEINLINE number& operator=(const number& e) + BOOST_MP_FORCEINLINE number& operator=(const number& e) BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast(std::declval()))) { m_backend = e.m_backend; @@ -150,22 +150,22 @@ public: } template - BOOST_MP_FORCEINLINE typename enable_if, number& >::type - operator=(const V& v) + BOOST_MP_FORCEINLINE typename enable_if, number& >::type + operator=(const V& v) BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast::type const&>(std::declval::type>()))) { m_backend = canonical_value(v); return *this; } template - BOOST_MP_FORCEINLINE number& assign(const V& v) + BOOST_MP_FORCEINLINE number& assign(const V& v) BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast::type const&>(std::declval::type>()))) { m_backend = canonical_value(v); return *this; } template - typename disable_if, number& >::type + typename disable_if, number& >::type assign(const number& v) { // @@ -181,7 +181,7 @@ public: *this = e; } template - explicit number(const detail::expression& e, + explicit number(const detail::expression& e, typename enable_if_c::result_type, self_type>::value && boost::multiprecision::detail::is_explicitly_convertible::result_type, self_type>::value>::type* = 0) { @@ -189,10 +189,10 @@ public: } #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES - BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(number&& r) - BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) + BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(number&& r) + BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(static_cast(r.m_backend)){} - BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT + BOOST_MP_FORCEINLINE number& operator=(number&& r) BOOST_NOEXCEPT { m_backend = static_cast(r.m_backend); return *this; @@ -234,7 +234,7 @@ public: } template - typename enable_if, number& >::type + typename enable_if, number& >::type operator+=(const V& v) { using default_ops::eval_add; @@ -265,7 +265,7 @@ public: } template - typename enable_if, number& >::type + typename enable_if, number& >::type operator-=(const V& v) { using default_ops::eval_subtract; @@ -309,7 +309,7 @@ public: } template - typename enable_if, number& >::type + typename enable_if, number& >::type operator*=(const V& v) { using default_ops::eval_multiply; @@ -340,7 +340,7 @@ public: return *this; } template - typename enable_if, number& >::type + typename enable_if, number& >::type operator%=(const V& v) { BOOST_STATIC_ASSERT_MSG(number_category::value == number_kind_integer, "The modulus operation is only valid for integer types"); @@ -428,7 +428,7 @@ public: } template - BOOST_MP_FORCEINLINE typename enable_if, number& >::type + BOOST_MP_FORCEINLINE typename enable_if, number& >::type operator/=(const V& v) { using default_ops::eval_divide; @@ -462,7 +462,7 @@ public: } template - BOOST_MP_FORCEINLINE typename enable_if, number& >::type + BOOST_MP_FORCEINLINE typename enable_if, number& >::type operator&=(const V& v) { BOOST_STATIC_ASSERT_MSG(number_category::value == number_kind_integer, "The bitwise & operation is only valid for integer types"); @@ -497,7 +497,7 @@ public: } template - BOOST_MP_FORCEINLINE typename enable_if, number& >::type + BOOST_MP_FORCEINLINE typename enable_if, number& >::type operator|=(const V& v) { BOOST_STATIC_ASSERT_MSG(number_category::value == number_kind_integer, "The bitwise | operation is only valid for integer types"); @@ -530,7 +530,7 @@ public: } template - BOOST_MP_FORCEINLINE typename enable_if, number& >::type + BOOST_MP_FORCEINLINE typename enable_if, number& >::type operator^=(const V& v) { BOOST_STATIC_ASSERT_MSG(number_category::value == number_kind_integer, "The bitwise ^ operation is only valid for integer types"); @@ -602,8 +602,8 @@ public: #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 7) // - // Horrible workaround for gcc-4.6.x which always prefers the non-template - // operator bool() rather than the template operator when converting to + // Horrible workaround for gcc-4.6.x which always prefers the template + // operator bool() rather than the non-template operator when converting to // an arithmetic type: // template , int>::type = 0> @@ -612,7 +612,7 @@ public: using default_ops::eval_is_zero; return !eval_is_zero(backend()); } - template , int>::type = 0> + template ::value || is_void::value, int>::type = 0> explicit operator T ()const { return this->template convert_to(); @@ -628,6 +628,7 @@ public: using default_ops::eval_is_zero; return !eval_is_zero(backend()); } + explicit operator void()const {} #endif #endif // @@ -1581,7 +1582,7 @@ private: { typedef typename Exp::left_type child0_type; typedef typename Exp::right_type child1_type; - return contains_self(e.left(), typename child0_type::arity()) + return contains_self(e.left(), typename child0_type::arity()) || contains_self(e.right(), typename child1_type::arity()); } template @@ -1590,7 +1591,7 @@ private: typedef typename Exp::left_type child0_type; typedef typename Exp::middle_type child1_type; typedef typename Exp::right_type child2_type; - return contains_self(e.left(), typename child0_type::arity()) + return contains_self(e.left(), typename child0_type::arity()) || contains_self(e.middle(), typename child1_type::arity()) || contains_self(e.right(), typename child2_type::arity()); } @@ -1613,8 +1614,8 @@ private: } template - BOOST_MP_FORCEINLINE BOOST_CONSTEXPR bool is_realy_self(const Val&)const BOOST_NOEXCEPT{ return false; } - BOOST_MP_FORCEINLINE BOOST_CONSTEXPR bool is_realy_self(const self_type& v)const BOOST_NOEXCEPT{ return &v == this; } + BOOST_MP_FORCEINLINE BOOST_CONSTEXPR bool is_realy_self(const Val&)const BOOST_NOEXCEPT{ return false; } + BOOST_MP_FORCEINLINE BOOST_CONSTEXPR bool is_realy_self(const self_type& v)const BOOST_NOEXCEPT{ return &v == this; } static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR const Backend& function_arg_value(const self_type& v) BOOST_NOEXCEPT { return v.backend(); } template @@ -1634,10 +1635,10 @@ public: template static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR const B2& canonical_value(const number& v) BOOST_NOEXCEPT { return v.backend(); } template - static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR typename disable_if::type, V>, typename detail::canonical::type>::type + static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR typename disable_if::type, V>, typename detail::canonical::type>::type canonical_value(const V& v) BOOST_NOEXCEPT { return static_cast::type>(v); } template - static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR typename enable_if::type, V>, const V&>::type + static BOOST_MP_FORCEINLINE BOOST_CONSTEXPR typename enable_if::type, V>, const V&>::type canonical_value(const V& v) BOOST_NOEXCEPT { return v; } static BOOST_MP_FORCEINLINE typename detail::canonical::type canonical_value(const std::string& v) BOOST_NOEXCEPT { return v.c_str(); }