Skip to content

Commit

Permalink
Use constexpr if in checked_diff function
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Oct 21, 2024
1 parent 387d321 commit cf1873f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/upa/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline Out checked_diff(T a, T b) {
const UT diff = static_cast<UT>(static_cast<UT>(a) - static_cast<UT>(b));
if (diff <= unsigned_limit<Out>::max())
return static_cast<Out>(diff);
} else if (std::is_signed_v<Out>) {
} else if constexpr (std::is_signed_v<Out>) {
// b > a ==> diff >= 1
const UT diff = static_cast<UT>(static_cast<UT>(b) - static_cast<UT>(a));
if (diff <= unsigned_limit<Out>::min())
Expand Down

0 comments on commit cf1873f

Please sign in to comment.