we want to use iround / llround without exception handling. This is possible
with the 'user_error' option and override a 'user_rounding_error' function.
We want to return numeric_limits<int>::max() or numeric_limits<__int64>::max()
if the rounding overflows over the maximum integer domain. This is then
problematic since the 'user_rounding_error' has a template argument only for
its source type (e.g. float / double), but not for its target type (i.e. int /
__int64).
We can ofc do the check before calling iround / llround, but this check would
then executed be twice for the normal non overflow case.
Anyone idea?
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
This looks like a bug in our design frankly, I'll try and figure out how to
fix this, in the mean time, you could simply implement your own versions of
these since they're basically trivial wrappers around "round" which does all
the work:
template <class T, class Policy>
inline int iround(const T& v, const Policy& pol)
{
BOOST_MATH_STD_USING
T r = boost::math::round(v, pol);
if(fabs(r) > (std::numeric_limits<int>::max)())
return
static_cast<int>(policies::raise_rounding_error("boost::math::iround<%1%>(%1%)",
0, v, pol)); // change this line
return static_cast<int>(r);
}
HTH, John.