diff options
Diffstat (limited to 'boost/multiprecision/detail/number_base.hpp')
-rw-r--r-- | boost/multiprecision/detail/number_base.hpp | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/boost/multiprecision/detail/number_base.hpp b/boost/multiprecision/detail/number_base.hpp index f229914c79..5911b3a28b 100644 --- a/boost/multiprecision/detail/number_base.hpp +++ b/boost/multiprecision/detail/number_base.hpp @@ -26,16 +26,25 @@ # define BOOST_MP_FORCEINLINE inline #endif -#if (defined(BOOST_GCC) && (BOOST_GCC <= 40700)) || defined(__SUNPRO_CC) +#if (defined(BOOST_GCC) && (BOOST_GCC <= 40700)) || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5140) # define BOOST_MP_NOEXCEPT_IF(x) #else # define BOOST_MP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x) #endif -#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || defined(__SUNPRO_CC) +#if defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || BOOST_WORKAROUND(__SUNPRO_CC, < 0x5140) #define BOOST_MP_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS #endif +// +// Thread local storage: +// +#if !defined(BOOST_NO_CXX11_THREAD_LOCAL) && !defined(BOOST_INTEL) +# define BOOST_MP_THREAD_LOCAL thread_local +#else +# define BOOST_MP_THREAD_LOCAL +#endif + #ifdef BOOST_MSVC # pragma warning(push) # pragma warning(disable:6326) @@ -402,7 +411,11 @@ struct expression<tag, Arg1, void, void, void> return static_cast<T>(static_cast<result_type>(*this)); } # else - template <class T, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0> + template <class T +#ifndef __SUNPRO_CC +, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0 +#endif +> explicit operator T()const { return static_cast<T>(static_cast<result_type>(*this)); @@ -412,7 +425,9 @@ struct expression<tag, Arg1, void, void, void> result_type r(*this); return static_cast<bool>(r); } - explicit operator void()const {} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) + BOOST_MP_FORCEINLINE explicit operator void()const {} +#endif # endif #else operator unmentionable_type()const @@ -466,7 +481,11 @@ struct expression<terminal, Arg1, void, void, void> return static_cast<T>(static_cast<result_type>(*this)); } # else - template <class T, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0> + template <class T +#ifndef __SUNPRO_CC +, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0 +#endif +> explicit operator T()const { return static_cast<T>(static_cast<result_type>(*this)); @@ -476,7 +495,9 @@ struct expression<terminal, Arg1, void, void, void> result_type r(*this); return static_cast<bool>(r); } - explicit operator void()const {} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) + BOOST_MP_FORCEINLINE explicit operator void()const {} +#endif # endif #else operator unmentionable_type()const @@ -534,7 +555,11 @@ struct expression<tag, Arg1, Arg2, void, void> return static_cast<T>(static_cast<result_type>(*this)); } # else - template <class T, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0> + template <class T +#ifndef __SUNPRO_CC +, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0 +#endif +> explicit operator T()const { return static_cast<T>(static_cast<result_type>(*this)); @@ -544,7 +569,9 @@ struct expression<tag, Arg1, Arg2, void, void> result_type r(*this); return static_cast<bool>(r); } - explicit operator void()const {} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) + BOOST_MP_FORCEINLINE explicit operator void()const {} +#endif # endif #else operator unmentionable_type()const @@ -613,7 +640,11 @@ struct expression<tag, Arg1, Arg2, Arg3, void> return static_cast<T>(static_cast<result_type>(*this)); } # else - template <class T, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0> + template <class T +#ifndef __SUNPRO_CC +, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0 +#endif +> explicit operator T()const { return static_cast<T>(static_cast<result_type>(*this)); @@ -623,7 +654,9 @@ struct expression<tag, Arg1, Arg2, Arg3, void> result_type r(*this); return static_cast<bool>(r); } - explicit operator void()const {} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) + BOOST_MP_FORCEINLINE explicit operator void()const {} +#endif # endif #else operator unmentionable_type()const @@ -701,7 +734,11 @@ struct expression return static_cast<T>(static_cast<result_type>(*this)); } # else - template <class T, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0> + template <class T +#ifndef __SUNPRO_CC +, typename boost::disable_if_c<is_number<T>::value || is_constructible<T const&, result_type>::value, int>::type = 0 +#endif +> explicit operator T()const { return static_cast<T>(static_cast<result_type>(*this)); @@ -711,7 +748,9 @@ struct expression result_type r(*this); return static_cast<bool>(r); } - explicit operator void()const {} +#if BOOST_WORKAROUND(BOOST_GCC_VERSION, < 40800) + BOOST_MP_FORCEINLINE explicit operator void()const {} +#endif # endif #else operator unmentionable_type()const @@ -751,7 +790,8 @@ struct digits2 BOOST_STATIC_ASSERT((std::numeric_limits<T>::radix == 2) || (std::numeric_limits<T>::radix == 10)); // If we really have so many digits that this fails, then we're probably going to hit other problems anyway: BOOST_STATIC_ASSERT(LONG_MAX / 1000 > (std::numeric_limits<T>::digits + 1)); - static const long value = std::numeric_limits<T>::radix == 10 ? (((std::numeric_limits<T>::digits + 1) * 1000L) / 301L) : std::numeric_limits<T>::digits; + static const long m_value = std::numeric_limits<T>::radix == 10 ? (((std::numeric_limits<T>::digits + 1) * 1000L) / 301L) : std::numeric_limits<T>::digits; + static inline BOOST_CONSTEXPR long value()BOOST_NOEXCEPT { return m_value; } }; #ifndef BOOST_MP_MIN_EXPONENT_DIGITS |