diff --git a/Utilities/BitField.h b/Utilities/BitField.h index 189c631fa1..da41049193 100644 --- a/Utilities/BitField.h +++ b/Utilities/BitField.h @@ -12,7 +12,7 @@ template struct bf_base { using type = T; - using vtype = simple_t; + using vtype = std::common_type_t; using utype = typename std::make_unsigned::type; // Datatype bitsize @@ -262,7 +262,7 @@ struct ff_t : bf_base template struct fmt_unveil, void> { - using type = typename fmt_unveil>::type; + using type = typename fmt_unveil>::type; static inline auto get(const bf_t& bf) { @@ -273,7 +273,7 @@ struct fmt_unveil, void> template struct fmt_unveil, void> { - using type = typename fmt_unveil>::type; + using type = typename fmt_unveil>::type; static inline auto get(const cf_t& cf) { @@ -284,7 +284,7 @@ struct fmt_unveil, void> template struct fmt_unveil, void> { - using type = typename fmt_unveil>::type; + using type = typename fmt_unveil>::type; static inline auto get(const ff_t& ff) { diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index b3e6d4b3f4..9ed4e15659 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -74,7 +74,7 @@ struct cmd64 u32 arg2; }; - template > + template > cmd64(const T& value) : m_data(std::bit_cast(value)) { diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index c2b81446d6..ce83cb4d65 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -49,7 +49,7 @@ namespace vm return vm::cast(m_addr); } - operator simple_t() const + operator std::common_type_t() const { return get_ref(); } @@ -64,7 +64,7 @@ namespace vm return get_ref() = right.get_ref(); } - T& operator =(const simple_t& right) const + T& operator =(const std::common_type_t& right) const { return get_ref() = right; } diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index bccc0f9bb2..8a993bca2e 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -155,7 +155,7 @@ struct any32 { u32 m_data; - template > + template > any32(const T& value) : m_data(std::bit_cast(value)) { diff --git a/rpcs3/util/atomic.hpp b/rpcs3/util/atomic.hpp index 27242ec3a7..46a656d7aa 100644 --- a/rpcs3/util/atomic.hpp +++ b/rpcs3/util/atomic.hpp @@ -1119,9 +1119,6 @@ public: atomic_t& operator =(const atomic_t&) = delete; - // Define simple type - using simple_type = simple_t; - constexpr atomic_t(const type& value) noexcept : m_data(value) { @@ -1229,7 +1226,7 @@ public: } // Atomically read data - operator simple_type() const + operator std::common_type_t() const { return atomic_storage::load(m_data); } @@ -1517,7 +1514,7 @@ public: } // Conditionally decrement - bool try_dec(simple_type greater_than) + bool try_dec(std::common_type_t greater_than) { type _new, old = atomic_storage::load(m_data); @@ -1540,7 +1537,7 @@ public: } // Conditionally increment - bool try_inc(simple_type less_than) + bool try_inc(std::common_type_t less_than) { type _new, old = atomic_storage::load(m_data); @@ -1628,8 +1625,6 @@ class atomic_t : private atomic_t public: static constexpr usz align = Align; - using simple_type = bool; - atomic_t() noexcept = default; atomic_t(const atomic_t&) = delete; @@ -1646,6 +1641,9 @@ public: return base::load() != 0; } + // Override implicit conversion from the parent type + explicit operator uchar() const = delete; + operator bool() const noexcept { return base::load() != 0; @@ -1710,6 +1708,17 @@ public: } }; +// Specializations + +template +struct std::common_type, atomic_t> : std::common_type {}; + +template +struct std::common_type, T2> : std::common_type> {}; + +template +struct std::common_type> : std::common_type, T2> {}; + namespace atomic_wait { template diff --git a/rpcs3/util/endian.hpp b/rpcs3/util/endian.hpp index c8f99f431f..e55812180d 100644 --- a/rpcs3/util/endian.hpp +++ b/rpcs3/util/endian.hpp @@ -210,8 +210,6 @@ namespace stx return *this; } - using simple_type = simple_t; - constexpr operator type() const noexcept { return value(); @@ -265,7 +263,7 @@ public: template ())> constexpr bool operator==(const T2& rhs) const noexcept { - using R = simple_t; + using R = std::common_type_t; if constexpr ((std::is_integral_v || std::is_enum_v) && (std::is_integral_v || std::is_enum_v)) { @@ -300,7 +298,7 @@ private: template static constexpr bool check_args_for_bitwise_op() { - using R = simple_t; + using R = std::common_type_t; if constexpr ((std::is_integral_v || std::is_enum_v) && (std::is_integral_v || std::is_enum_v)) { @@ -473,6 +471,17 @@ public: }; } +// Specializations + +template +struct std::common_type, stx::se_t> : std::common_type {}; + +template +struct std::common_type, T2> : std::common_type> {}; + +template +struct std::common_type> : std::common_type, T2> {}; + #ifndef _MSC_VER #pragma GCC diagnostic pop #endif diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 27f78fa25a..6b0e61e13a 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -208,22 +208,6 @@ using atomic_be_t = atomic_t, Align>; template using atomic_le_t = atomic_t, Align>; -// Extract T::simple_type if available, remove cv qualifiers -template -struct simple_type_helper -{ - using type = typename std::remove_cv::type; -}; - -template -struct simple_type_helper> -{ - using type = typename T::simple_type; -}; - -template -using simple_t = typename simple_type_helper::type; - // Bool type equivalent class b8 { @@ -524,7 +508,7 @@ constexpr inline struct umax_helper { constexpr umax_helper() noexcept = default; - template , typename = std::enable_if_t>> + template , typename = std::enable_if_t>> constexpr bool operator==(const T& rhs) const { return rhs == static_cast(-1); @@ -533,24 +517,24 @@ constexpr inline struct umax_helper #if __cpp_impl_three_way_comparison >= 201711 && !__INTELLISENSE__ #else template - friend constexpr std::enable_if_t>, bool> operator==(const T& lhs, const umax_helper&) + friend constexpr std::enable_if_t>, bool> operator==(const T& lhs, const umax_helper&) { - return lhs == static_cast>(-1); + return lhs == static_cast>(-1); } #endif #if __cpp_impl_three_way_comparison >= 201711 #else - template , typename = std::enable_if_t>> + template , typename = std::enable_if_t>> constexpr bool operator!=(const T& rhs) const { return rhs != static_cast(-1); } template - friend constexpr std::enable_if_t>, bool> operator!=(const T& lhs, const umax_helper&) + friend constexpr std::enable_if_t>, bool> operator!=(const T& lhs, const umax_helper&) { - return lhs != static_cast>(-1); + return lhs != static_cast>(-1); } #endif } umax; @@ -784,8 +768,8 @@ struct narrow_impl::value && std // Simple type enabled (TODO: allow for To as well) template -struct narrow_impl> - : narrow_impl, To> +struct narrow_impl, From>>> + : narrow_impl, To> { };