|
|
|
|
|
by tialaramex
1487 days ago
|
|
Ironically (?) this doesn't seem to supply the one thing implied by the explanation it gives It begins by telling us about how in C++ you're obliged to detect potential overflow, because if the overflow already happened then in many cases that's Undefined Behaviour and all bets are off. But you shouldn't use this to merely detect such overflow, out of the box it will give you an Exception - and C++ proponents will insist those are only for Exceptional situations you mustn't expect them to have decent performance for merely conditions such as this overflow check - which might happen in some inner loop depending on the system design. I don't see a way to ask the equivalent of Rust's checked_add() which gives you back Some(answer) or None depending on whether this addition overflows. |
|