| 22 | |
| 23 | template<typename T> |
| 24 | bool SafeMultiply(T a, T b, T& out) |
| 25 | { |
| 26 | if (a == 0 || b == 0) |
| 27 | { |
| 28 | out = 0; |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | if (std::is_unsigned<T>::value || true) |
| 33 | { |
| 34 | if (b > std::numeric_limits<T>::max() / a) |
| 35 | { |
| 36 | return false; |
| 37 | } |
| 38 | } |
| 39 | out = a * b; |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | namespace detail |
| 44 | { |
nothing calls this directly
no outgoing calls
no test coverage detected