| 2688 | /// Performs a *= b; if it doesn't cause integer overflow. Returns false otherwise. |
| 2689 | template <typename T> |
| 2690 | typename std::enable_if<std::is_integral<T>::value, bool>::type checked_multiply(T &a, T b) { |
| 2691 | if (a == 0 || b == 0 || a == 1 || b == 1) { |
| 2692 | a *= b; |
| 2693 | return true; |
| 2694 | } |
| 2695 | if (a == (std::numeric_limits<T>::min)() || b == (std::numeric_limits<T>::min)()) { |
| 2696 | return false; |
| 2697 | } |
| 2698 | if (overflowCheck(a, b)) { |
| 2699 | return false; |
| 2700 | } |
| 2701 | a *= b; |
| 2702 | return true; |
| 2703 | } |
| 2704 | |
| 2705 | /// Performs a *= b; if it doesn't equal infinity. Returns false otherwise. |
| 2706 | template <typename T> |
no test coverage detected