4 ms·
"Zero cost" here means the author is asserting it doesn't add a bunch of extra branches or instructions or whatever (compared to normal addition) by the time it
by missblit 4y ago
"Zero cost" here means the author is asserting it doesn't add a bunch of extra branches or instructions or whatever (compared to normal addition) by the time it gets compiled down to assembly.
For example there's a slow looking if statement in there:
if ((_is_neg() && _storage < usmin) ||
(!_is_neg() && _storage > usmax))
But in theory an optimizing compiler could remove it entirely since it can never be true (on C++20 or above).
Whether the compiler does this in practice depends on a variety of factors, but in general they're fairly good at spotting "obvious" optimizations.