From 98ff84b860cbf55d06d96c97b0cf7bf449189ee1 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Fri, 6 Feb 2015 18:33:58 +0000 Subject: [PATCH] Mark some more functions with conditional noexcept support, also simplified/removed some casts which weren't required. --- include/boost/multiprecision/number.hpp | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index 54e83c5c..91cdb836 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/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(std::declval())))) : m_backend(e.m_backend){} + BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& e) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(e.m_backend){} template BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c< (boost::is_arithmetic::value || is_same::value || is_convertible::value) @@ -55,16 +55,18 @@ public: BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const V& v, typename boost::enable_if_c< is_convertible::type, Backend>::value && !detail::is_restricted_conversion::type, Backend>::value - >::type* = 0) + >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval::type const&>()))) : 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(static_cast(std::declval()), std::declval()))) : m_backend(e.m_backend, digits10){} template explicit BOOST_MP_FORCEINLINE number(const V& v, typename boost::enable_if_c< (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) + >::type* = 0) + BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval::type const&>())) { m_backend = canonical_value(v); } @@ -74,6 +76,7 @@ public: && (detail::is_restricted_conversion::type, Backend>::value || !is_convertible::type, Backend>::value) >::type* = 0) + BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval::type const&>()))) : m_backend(canonical_value(v)) {} /* // @@ -89,12 +92,12 @@ public: */ template BOOST_MP_FORCEINLINE BOOST_CONSTEXPR number(const number& val) - BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) : m_backend(val.backend()) {} + BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(val.backend()) {} template BOOST_MP_FORCEINLINE number(const number& val, typename boost::enable_if_c<(boost::is_convertible::value && !detail::is_restricted_conversion::value)>::type* = 0) - BOOST_NOEXCEPT_IF(noexcept(Backend(static_cast(std::declval())))) + BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(val.backend()) {} template @@ -111,7 +114,7 @@ public: explicit BOOST_MP_FORCEINLINE number(const number& val, typename boost::enable_if_c< (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())))) + >::type* = 0) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval()))) : m_backend(val.backend()) {} template @@ -143,7 +146,7 @@ public: } BOOST_MP_FORCEINLINE number& operator=(const number& e) - BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast(std::declval()))) + BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval())) { m_backend = e.m_backend; return *this; @@ -152,14 +155,14 @@ public: template BOOST_MP_FORCEINLINE typename boost::enable_if, number& >::type operator=(const V& v) - BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast::type const&>(std::declval::type>()))) + BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval::type&>())) { m_backend = canonical_value(v); return *this; } template BOOST_MP_FORCEINLINE number& assign(const V& v) - BOOST_NOEXCEPT_IF(noexcept(std::declval() = static_cast::type const&>(std::declval::type>()))) + BOOST_NOEXCEPT_IF(noexcept(std::declval() = std::declval::type&>())) { m_backend = canonical_value(v); return *this; @@ -192,7 +195,7 @@ public: 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_IF(noexcept(std::declval() = std::declval())) { m_backend = static_cast(r.m_backend); return *this; @@ -541,7 +544,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().swap(std::declval()))) { m_backend.swap(other.backend()); } @@ -1719,7 +1722,8 @@ inline std::istream& operator >> (std::istream& is, number -BOOST_MP_FORCEINLINE void swap(number& a, number& b) +BOOST_MP_FORCEINLINE void swap(number& a, number& b) + BOOST_NOEXCEPT_IF(noexcept(std::declval >() = std::declval&>())) { a.swap(b); }