diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 49c651417b..ffaac18ded 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -9,18 +9,12 @@ #include #include #include +#include using std::chrono::steady_clock; using namespace std::literals; -#ifdef _MSC_VER -#if !defined(__cpp_lib_bitops) && _MSC_VER < 1928 -#define __cpp_lib_bitops -#endif -#endif -#include - #ifndef __has_builtin #define __has_builtin(x) 0 #endif @@ -57,19 +51,10 @@ using namespace std::literals; #if __cpp_lib_bit_cast < 201806L namespace std { - template > - constexpr To bit_cast(const From& from) noexcept + template + [[nodiscard]] constexpr To bit_cast(const From& from) noexcept { - static_assert(sizeof(To) == sizeof(From), "std::bit_cast<>: incompatible type size"); - - if constexpr ((std::is_same_v, std::remove_const_t> && std::is_constructible_v) || (std::is_integral_v && std::is_integral_v)) - { - return static_cast(from); - } - - To result{}; - __builtin_memcpy(&result, &from, sizeof(From)); - return result; + return __builtin_bit_cast(To, from); } } #endif