Added AddOverflow, SubOverflow and MulOverflow to compute truncated results and return a flag indicating whether overflow occured.
Can you confirm that the tests pass with UBSan enabled?
I think you want to have T1 X, T2 Y and enable_if::<is_same<T1, T2>::value since you're trying to avoid promotions entirely.
I'd also rather return a pair or a struct with named values instead of having a reference return value, and make the result nodiscard.
We have bit_cast in ADT/bit.h if that's what you meant to use. I think you meant static_cast thought :)
You probably want signed char instead of char.
Unfortunately, I would like to avoid any refactoring in this diff.
I would like to keep these functions simple so at some point we might make them straightforward wrappers over __builtin_add_overflow etc, reason why I would like to keep this signature. Promotions can be handled on the callee's side. For my use case, I always want to explicitly specify the template parameter type.
Regarding struct returns, that sounds like a use case for a class such as CheckedInt/SafeInt etc, which doesn't seem to be required yet. A future implementation might use these methods though.
If the sizes match, doesn't static cast simply move the number bit by bit to the result? I have adjusted the comment.