| 122 | |
| 123 | template <typename Int> |
| 124 | [[nodiscard]] bool DivideWithOverflowGeneric(Int u, Int v, Int* out) { |
| 125 | if (v == 0) { |
| 126 | *out = Int{}; |
| 127 | return true; |
| 128 | } |
| 129 | if constexpr (std::is_signed_v<Int>) { |
| 130 | constexpr auto kMin = std::numeric_limits<Int>::min(); |
| 131 | if (u == kMin && v == -1) { |
| 132 | *out = kMin; |
| 133 | return true; |
| 134 | } |
| 135 | } |
| 136 | *out = u / v; |
| 137 | return false; |
| 138 | } |
| 139 | |
| 140 | template <typename Int> |
| 141 | [[nodiscard]] bool ModuloWithOverflowGeneric(Int u, Int v, Int* out) { |
nothing calls this directly
no outgoing calls
no test coverage detected