| 215 | /// Signed subtraction with well-defined behaviour on overflow (as unsigned) |
| 216 | template <typename SignedInt> |
| 217 | SignedInt SafeSignedSubtract(SignedInt u, SignedInt v) { |
| 218 | using UnsignedInt = typename std::make_unsigned<SignedInt>::type; |
| 219 | return static_cast<SignedInt>(static_cast<UnsignedInt>(u) - |
| 220 | static_cast<UnsignedInt>(v)); |
| 221 | } |
| 222 | |
| 223 | /// Signed negation with well-defined behaviour on overflow (as unsigned) |
| 224 | template <typename SignedInt> |
no outgoing calls
no test coverage detected