mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-19 14:32:35 +00:00
Mark some more functions with conditional noexcept support, also simplified/removed some casts which weren't required.
This commit is contained in:
@@ -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,18 @@ 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) BOOST_NOEXCEPT_IF(noexcept(Backend(std::declval<typename detail::canonical<V, Backend>::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<const Backend&>(std::declval<Backend>()), 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 +76,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 +92,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 +114,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 +146,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 +155,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 +195,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 +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<Backend>().swap(std::declval<Backend&>())))
|
||||
{
|
||||
m_backend.swap(other.backend());
|
||||
}
|
||||
@@ -1719,7 +1722,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user