| 67 | // Avoid undefined behaviour on signed overflow |
| 68 | template <typename Signed> |
| 69 | Signed SafeSignedAdd(Signed u, Signed v) { |
| 70 | using Unsigned = typename std::make_unsigned<Signed>::type; |
| 71 | return static_cast<Signed>(static_cast<Unsigned>(u) + static_cast<Unsigned>(v)); |
| 72 | } |
| 73 | |
| 74 | // Special case for 8-bit ints (must output their decimal value, not the |
| 75 | // corresponding ASCII character) |
no outgoing calls
no test coverage detected