| 243 | /// Signed negation with well-defined behaviour on overflow (as unsigned) |
| 244 | template <typename SignedInt> |
| 245 | SignedInt SafeSignedNegate(SignedInt u) { |
| 246 | using UnsignedInt = typename std::make_unsigned<SignedInt>::type; |
| 247 | return static_cast<SignedInt>(~static_cast<UnsignedInt>(u) + 1); |
| 248 | } |
| 249 | |
| 250 | /// Signed left shift with well-defined behaviour on negative numbers or overflow |
| 251 | template <typename SignedInt, typename Shift> |
no outgoing calls