Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/multiprecision/detail/number_base.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/multiprecision/detail/number_base.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/multiprecision/detail/number_base.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -75,18 +75,35 @@ // Workaround for missing abs(long long) and abs(__int128) on some compilers: // template <class T> -typename enable_if_c<(is_signed<T>::value || is_floating_point<T>::value), T>::type abs(T t) BOOST_NOEXCEPT +BOOST_CONSTEXPR typename enable_if_c<(is_signed<T>::value || is_floating_point<T>::value), T>::type abs(T t) BOOST_NOEXCEPT { - return t < 0 ? -t : t; + // This strange expression avoids a hardware trap in the corner case + // that val is the most negative value permitted in long long. + // See https://svn.boost.org/trac/boost/ticket/9740. + return t < 0 ? T(1u) + T(-(t + 1)) : t; } template <class T> -typename enable_if_c<(is_unsigned<T>::value), T>::type abs(T t) BOOST_NOEXCEPT +BOOST_CONSTEXPR typename enable_if_c<(is_unsigned<T>::value), T>::type abs(T t) BOOST_NOEXCEPT { return t; } #define BOOST_MP_USING_ABS using boost::multiprecision::detail::abs; +template <class T> +BOOST_CONSTEXPR typename enable_if_c<(is_signed<T>::value || is_floating_point<T>::value), typename make_unsigned<T>::type>::type unsigned_abs(T t) BOOST_NOEXCEPT +{ + // This strange expression avoids a hardware trap in the corner case + // that val is the most negative value permitted in long long. + // See https://svn.boost.org/trac/boost/ticket/9740. + return t < 0 ? static_cast<typename make_unsigned<T>::type>(1u) + static_cast<typename make_unsigned<T>::type>(-(t + 1)) : static_cast<typename make_unsigned<T>::type>(t); +} +template <class T> +BOOST_CONSTEXPR typename enable_if_c<(is_unsigned<T>::value), T>::type unsigned_abs(T t) BOOST_NOEXCEPT +{ + return t; +} + // // Move support: // @@ -128,6 +145,18 @@ { typedef B type; }; +#ifdef __SUNPRO_CC +template <class B, class Backend> +struct canonical_imp<number<B, et_on>, Backend, mpl::int_<3> > +{ + typedef B type; +}; +template <class B, class Backend> +struct canonical_imp<number<B, et_off>, Backend, mpl::int_<3> > +{ + typedef B type; +}; +#endif template <class Val, class Backend> struct canonical_imp<Val, Backend, mpl::int_<0> > { @@ -589,9 +618,9 @@ } } if(neg) - str.insert(0, 1, '-'); + str.insert(static_cast<std::string::size_type>(0), 1, '-'); else if(showpos) - str.insert(0, 1, '+'); + str.insert(static_cast<std::string::size_type>(0), 1, '+'); return; } @@ -636,8 +665,8 @@ { if(my_exp < 0) { - str.insert(0, static_cast<std::string::size_type>(-1 - my_exp), '0'); - str.insert(0, "0."); + str.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(-1 - my_exp), '0'); + str.insert(static_cast<std::string::size_type>(0), "0."); } else { @@ -662,21 +691,21 @@ BOOST_MP_USING_ABS // Scientific format: if(showpoint || (str.size() > 1)) - str.insert(1, 1, '.'); - str.append(1, 'e'); + str.insert(static_cast<std::string::size_type>(1u), 1, '.'); + str.append(static_cast<std::string::size_type>(1u), 'e'); S e = boost::lexical_cast<S>(abs(my_exp)); if(e.size() < BOOST_MP_MIN_EXPONENT_DIGITS) - e.insert(0, BOOST_MP_MIN_EXPONENT_DIGITS-e.size(), '0'); + e.insert(static_cast<std::string::size_type>(0), BOOST_MP_MIN_EXPONENT_DIGITS - e.size(), '0'); if(my_exp < 0) - e.insert(0, 1, '-'); + e.insert(static_cast<std::string::size_type>(0), 1, '-'); else - e.insert(0, 1, '+'); + e.insert(static_cast<std::string::size_type>(0), 1, '+'); str.append(e); } if(neg) - str.insert(0, 1, '-'); + str.insert(static_cast<std::string::size_type>(0), 1, '-'); else if(showpos) - str.insert(0, 1, '+'); + str.insert(static_cast<std::string::size_type>(0), 1, '+'); } template <class V> @@ -768,7 +797,22 @@ } -}}} +} + +namespace constants{ + + template <class T> + struct is_explicitly_convertible_from_string; + + template <class B, boost::multiprecision::expression_template_option ET> + struct is_explicitly_convertible_from_string<boost::multiprecision::number<B, ET> > + { + static const bool value = true; + }; + +} + +}} #endif // BOOST_MATH_BIG_NUM_BASE_HPP