In the video CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior...", the presenter at one point brings up the notion of having multiple integer types with the same width and signedness, but different contracts/behavior for things like wrap around and shifting past the end. I am wondering whether this is better handled as distinct types, or as different versions of the primitive operations themselves. For example, two different addition operations, one which does wrap-around and one which doesn't. Then the type wouldn't matter, only the operation.
In the video CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior...", the presenter at one point brings up the notion of having multiple integer types with the same width and signedness, but different contracts/behavior for things like wrap around and shifting past the end. I am wondering whether this is better handled as distinct types, or as different versions of the primitive operations themselves. For example, two different addition operations, one which does wrap-around and one which doesn't. Then the type wouldn't matter, only the operation.