mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
* Special case bool in cmp_less to avoid msvc's warnings * Fix underflow in out of range check The previous fix addressed bool but it seems that was not the heart of the issue. The problem is that (lhs - 1) can underflow. Another example of the check trigger when it shouldn't is: uint8_t with min_value set to 0 and a value of uint8_t::max lhs-1 would underflow and find max (see added test). The issue happens when lhs == rhs. To avoid that situation: flip the if-else! `cmp_less(rhs, lhs)`means that rhs is strictly less than lhs, so the check will not trigger when lhs == rhs. Also, cleanup the bool special-case, as it is no longer necessary. Note: for the bug to manifest, it is important that the min of the enums is customized to be 0, so corresponding enum_range specializations need to be present in the regression tests. |
||
|---|---|---|
| .. | ||
| magic_enum.hpp | ||