| 2673 | /// Do a check for overflow on signed numbers |
| 2674 | template <typename T> |
| 2675 | inline typename std::enable_if<std::is_signed<T>::value, T>::type overflowCheck(const T &a, const T &b) { |
| 2676 | if ((a > 0) == (b > 0)) { |
| 2677 | return ((std::numeric_limits<T>::max)() / (std::abs)(a) < (std::abs)(b)); |
| 2678 | } else { |
| 2679 | return ((std::numeric_limits<T>::min)() / (std::abs)(a) > -(std::abs)(b)); |
| 2680 | } |
| 2681 | } |
| 2682 | /// Do a check for overflow on unsigned numbers |
| 2683 | template <typename T> |
| 2684 | inline typename std::enable_if<!std::is_signed<T>::value, T>::type overflowCheck(const T &a, const T &b) { |