From 046f8510fa4ab8ea14a75d1e1c221b0b73ec27d2 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 27 Sep 2019 22:25:11 +0300 Subject: [PATCH] Restore experimental optimized operators == != for se_t<> --- rpcs3/util/endian.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rpcs3/util/endian.hpp b/rpcs3/util/endian.hpp index c3983ec802..aee04c1e55 100644 --- a/rpcs3/util/endian.hpp +++ b/rpcs3/util/endian.hpp @@ -194,6 +194,26 @@ namespace stx } #endif + template + bool operator==(const T2& rhs) const noexcept + { + using R = simple_t; + + if constexpr ((std::is_integral_v || std::is_enum_v) && (std::is_integral_v || std::is_enum_v) && sizeof(T) >= sizeof(R)) + { + return std::bit_cast(m_data) == std::bit_cast(static_cast(rhs)); + } + + // Keep outside of if constexpr to make sure it fails on invalid comparison + return value() == rhs; + } + + template + bool operator!=(const T2& rhs) const noexcept + { + return !operator==(rhs); + } + template se_t& operator+=(const T1& rhs) {