Repository navigation
util: Add SaturatingAdd helper - #24224
Conversation
|
Concept ACK. This seems useful, hopefully C++ will have built-ins for explicitly saturating/wrapping/checked arithmetic like rust some day. But until then… |
I wasn't aware that rust has those built-in. Mind sharing a link to the docs? |
|
Oh, I see. By default rust will panic, but there are https://doc.rust-lang.org/std/num/index.html: |
klementtan
left a comment
There was a problem hiding this comment.
Code Review ACK fa90189cbfe10552f94fdaa8607cdd5a10341ced
There was a problem hiding this comment.
Out of curiosity, any reason you didn't constexpr this function?
There was a problem hiding this comment.
Outside of unit tests I don't think this will ever be called in a context that would be constexpr.
vasild
left a comment
There was a problem hiding this comment.
ACK fa90189cbfe10552f94fdaa8607cdd5a10341ced
|
Added a test. Should be trivial to re-ACK with |
|
reACK faa7d8a |
Seems good to have this in the repo, as it might be needed to write cleaner code. For example: