mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Fix enum vs integer comparison in se_t::operator==
Need to convert left part to its underlying type.
This commit is contained in:
parent
0f567abdd8
commit
5f29840348
@ -199,9 +199,20 @@ namespace stx
|
||||
{
|
||||
using R = simple_t<T2>;
|
||||
|
||||
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>) && sizeof(T) >= sizeof(R))
|
||||
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>))
|
||||
{
|
||||
return std::bit_cast<type>(m_data) == std::bit_cast<type>(static_cast<se_t>(rhs));
|
||||
if constexpr (sizeof(T) >= sizeof(R))
|
||||
{
|
||||
if constexpr (std::is_enum_v<T> && std::is_convertible_v<T, int> && std::is_convertible_v<R, int>)
|
||||
{
|
||||
using under = std::underlying_type_t<T>;
|
||||
return std::bit_cast<under>(m_data) == std::bit_cast<under>(static_cast<se_t<under, Swap>>(rhs));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::bit_cast<type>(m_data) == std::bit_cast<type>(static_cast<se_t>(rhs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keep outside of if constexpr to make sure it fails on invalid comparison
|
||||
|
Loading…
Reference in New Issue
Block a user