2017-03-07 18:32 GMT+01:00 Robert Ramey via Boost
using result_base_type = typename boost::mpl::if_c< std::numeric_limits
::is_signed || std::numeric_limits ::is_signed, std::intmax_t, std::uintmax_t >::type; Why division doesn't use calculate_max_t like multiplication deserves some explanation. Division can overflow too (numeric_limits ::max() / 1). Hmmm - I'm sure it's because I've presumed that the result can aways be contained in the same size type as the number being divide. That t / x <= t - and divide by zero is checked separately. Am I wrong about this?
I am not sure if this is what Steve meant, but: int x = INT_MIN; int y = -1; int a = x / y; // overflows! safe<int> does a check for this condition, but I find it quite surprising that it throws a domain_error rather than overflow_error. How do you make a call whether it is an overflow or a domain error? For mathematical ints dividing -2147483648 by -1 is well defined. Regards, &rzej;