namespace detail{
template <class T, class Policy>
-inline typename tools::promote_args<T>::type round(const T& v, const Policy& pol, const boost::false_type&)
+inline typename tools::promote_args<T>::type round(const T& v, const Policy& pol, const std::false_type&)
{
BOOST_MATH_STD_USING
typedef typename tools::promote_args<T>::type result_type;
}
}
template <class T, class Policy>
-inline typename tools::promote_args<T>::type round(const T& v, const Policy&, const boost::true_type&)
+inline typename tools::promote_args<T>::type round(const T& v, const Policy&, const std::true_type&)
{
return v;
}
template <class T, class Policy>
inline typename tools::promote_args<T>::type round(const T& v, const Policy& pol)
{
- return detail::round(v, pol, boost::integral_constant<bool, detail::is_integer_for_rounding<T>::value>());
+ return detail::round(v, pol, std::integral_constant<bool, detail::is_integer_for_rounding<T>::value>());
}
template <class T>
inline typename tools::promote_args<T>::type round(const T& v)
// namespace as the UDT: these will then be found via argument
// dependent lookup. See our concept archetypes for examples.
//
+// Non-standard numeric limits syntax "(std::numeric_limits<int>::max)()"
+// is to avoid macro substiution from MSVC
+// https://stackoverflow.com/questions/27442885/syntax-error-with-stdnumeric-limitsmax
+//
template <class T, class Policy>
inline int iround(const T& v, const Policy& pol)
{
BOOST_MATH_STD_USING
+ typedef typename tools::promote_args<T>::type result_type;
T r = boost::math::round(v, pol);
- if((r > (std::numeric_limits<int>::max)()) || (r < (std::numeric_limits<int>::min)()))
+ if(r > static_cast<result_type>((std::numeric_limits<int>::max)()) || r < static_cast<result_type>((std::numeric_limits<int>::min)()))
return static_cast<int>(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)", 0, v, 0, pol));
return static_cast<int>(r);
}
inline long lround(const T& v, const Policy& pol)
{
BOOST_MATH_STD_USING
+ typedef typename tools::promote_args<T>::type result_type;
T r = boost::math::round(v, pol);
- if((r > (std::numeric_limits<long>::max)()) || (r < (std::numeric_limits<long>::min)()))
+ if(r > static_cast<result_type>((std::numeric_limits<long>::max)()) || r < static_cast<result_type>((std::numeric_limits<long>::min)()))
return static_cast<long int>(policies::raise_rounding_error("boost::math::lround<%1%>(%1%)", 0, v, 0L, pol));
return static_cast<long int>(r);
}
return lround(v, policies::policy<>());
}
-#ifdef BOOST_HAS_LONG_LONG
-
template <class T, class Policy>
-inline boost::long_long_type llround(const T& v, const Policy& pol)
+inline long long llround(const T& v, const Policy& pol)
{
BOOST_MATH_STD_USING
+ typedef typename tools::promote_args<T>::type result_type;
T r = boost::math::round(v, pol);
- if((r > (std::numeric_limits<boost::long_long_type>::max)()) || (r < (std::numeric_limits<boost::long_long_type>::min)()))
- return static_cast<boost::long_long_type>(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", 0, v, static_cast<boost::long_long_type>(0), pol));
- return static_cast<boost::long_long_type>(r);
+ if(r > static_cast<result_type>((std::numeric_limits<long long>::max)()) ||
+ r < static_cast<result_type>((std::numeric_limits<long long>::min)()))
+ {
+ return static_cast<long long>(policies::raise_rounding_error("boost::math::llround<%1%>(%1%)", 0, v, static_cast<long long>(0), pol));
+ }
+ return static_cast<long long>(r);
}
template <class T>
-inline boost::long_long_type llround(const T& v)
+inline long long llround(const T& v)
{
return llround(v, policies::policy<>());
}
-#endif
-
}} // namespaces
#endif // BOOST_MATH_ROUND_HPP