diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index c003f8d..0febc40 100644 --- a/include/magic_enum.hpp +++ b/include/magic_enum.hpp @@ -145,15 +145,15 @@ template constexpr bool mixed_sign_less(L lhs, R rhs) noexcept { static_assert(std::is_integral_v && std::is_integral_v, "magic_enum::detail::mixed_sign_less requires integral type."); - if constexpr(std::is_signed_v == std::is_signed_v) { - // If same signedness (both signed or both unsigned). - return lhs < rhs; - } else if constexpr(std::is_signed_v) { + if constexpr (std::is_signed_v && std::is_unsigned_v) { // If 'left' is negative, then result is 'true', otherwise cast & compare. return lhs < 0 || static_cast>(lhs) < rhs; - } else { // std::is_signed_v + } else if constexpr (std::is_unsigned_v && std::is_signed_v) { // If 'right' is negative, then result is 'false', otherwise cast & compare. return rhs >= 0 && lhs < static_cast>(rhs); + } else { + // If same signedness (both signed or both unsigned). + return lhs < rhs; } }