Restore experimental optimized operators == != for se_t<>

This commit is contained in:
Nekotekina 2019-09-27 22:25:11 +03:00
parent 21885264f7
commit 046f8510fa

View File

@ -194,6 +194,26 @@ namespace stx
} }
#endif #endif
template <typename T2>
bool operator==(const T2& rhs) const noexcept
{
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))
{
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
return value() == rhs;
}
template <typename T2>
bool operator!=(const T2& rhs) const noexcept
{
return !operator==<T2>(rhs);
}
template <typename T1> template <typename T1>
se_t& operator+=(const T1& rhs) se_t& operator+=(const T1& rhs)
{ {