mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 18:32:47 +00:00
Replace simple_type with std::common_type
This commit is contained in:
parent
330dea181a
commit
67e2e154fa
@ -12,7 +12,7 @@ template<typename T, uint N>
|
|||||||
struct bf_base
|
struct bf_base
|
||||||
{
|
{
|
||||||
using type = T;
|
using type = T;
|
||||||
using vtype = simple_t<type>;
|
using vtype = std::common_type_t<type>;
|
||||||
using utype = typename std::make_unsigned<vtype>::type;
|
using utype = typename std::make_unsigned<vtype>::type;
|
||||||
|
|
||||||
// Datatype bitsize
|
// Datatype bitsize
|
||||||
@ -262,7 +262,7 @@ struct ff_t : bf_base<T, N>
|
|||||||
template<typename T, uint I, uint N>
|
template<typename T, uint I, uint N>
|
||||||
struct fmt_unveil<bf_t<T, I, N>, void>
|
struct fmt_unveil<bf_t<T, I, N>, void>
|
||||||
{
|
{
|
||||||
using type = typename fmt_unveil<simple_t<T>>::type;
|
using type = typename fmt_unveil<std::common_type_t<T>>::type;
|
||||||
|
|
||||||
static inline auto get(const bf_t<T, I, N>& bf)
|
static inline auto get(const bf_t<T, I, N>& bf)
|
||||||
{
|
{
|
||||||
@ -273,7 +273,7 @@ struct fmt_unveil<bf_t<T, I, N>, void>
|
|||||||
template<typename F, typename... Fields>
|
template<typename F, typename... Fields>
|
||||||
struct fmt_unveil<cf_t<F, Fields...>, void>
|
struct fmt_unveil<cf_t<F, Fields...>, void>
|
||||||
{
|
{
|
||||||
using type = typename fmt_unveil<simple_t<typename F::type>>::type;
|
using type = typename fmt_unveil<std::common_type_t<typename F::type>>::type;
|
||||||
|
|
||||||
static inline auto get(const cf_t<F, Fields...>& cf)
|
static inline auto get(const cf_t<F, Fields...>& cf)
|
||||||
{
|
{
|
||||||
@ -284,7 +284,7 @@ struct fmt_unveil<cf_t<F, Fields...>, void>
|
|||||||
template<typename T, T V, uint N>
|
template<typename T, T V, uint N>
|
||||||
struct fmt_unveil<ff_t<T, V, N>, void>
|
struct fmt_unveil<ff_t<T, V, N>, void>
|
||||||
{
|
{
|
||||||
using type = typename fmt_unveil<simple_t<T>>::type;
|
using type = typename fmt_unveil<std::common_type_t<T>>::type;
|
||||||
|
|
||||||
static inline auto get(const ff_t<T, V, N>& ff)
|
static inline auto get(const ff_t<T, V, N>& ff)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ struct cmd64
|
|||||||
u32 arg2;
|
u32 arg2;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename T2 = simple_t<T>>
|
template <typename T, typename T2 = std::common_type_t<T>>
|
||||||
cmd64(const T& value)
|
cmd64(const T& value)
|
||||||
: m_data(std::bit_cast<u64, T2>(value))
|
: m_data(std::bit_cast<u64, T2>(value))
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ namespace vm
|
|||||||
return vm::cast(m_addr);
|
return vm::cast(m_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator simple_t<T>() const
|
operator std::common_type_t<T>() const
|
||||||
{
|
{
|
||||||
return get_ref();
|
return get_ref();
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ namespace vm
|
|||||||
return get_ref() = right.get_ref();
|
return get_ref() = right.get_ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator =(const simple_t<T>& right) const
|
T& operator =(const std::common_type_t<T>& right) const
|
||||||
{
|
{
|
||||||
return get_ref() = right;
|
return get_ref() = right;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ struct any32
|
|||||||
{
|
{
|
||||||
u32 m_data;
|
u32 m_data;
|
||||||
|
|
||||||
template <typename T, typename T2 = simple_t<T>>
|
template <typename T, typename T2 = std::common_type_t<T>>
|
||||||
any32(const T& value)
|
any32(const T& value)
|
||||||
: m_data(std::bit_cast<u32, T2>(value))
|
: m_data(std::bit_cast<u32, T2>(value))
|
||||||
{
|
{
|
||||||
|
@ -1119,9 +1119,6 @@ public:
|
|||||||
|
|
||||||
atomic_t& operator =(const atomic_t&) = delete;
|
atomic_t& operator =(const atomic_t&) = delete;
|
||||||
|
|
||||||
// Define simple type
|
|
||||||
using simple_type = simple_t<T>;
|
|
||||||
|
|
||||||
constexpr atomic_t(const type& value) noexcept
|
constexpr atomic_t(const type& value) noexcept
|
||||||
: m_data(value)
|
: m_data(value)
|
||||||
{
|
{
|
||||||
@ -1229,7 +1226,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Atomically read data
|
// Atomically read data
|
||||||
operator simple_type() const
|
operator std::common_type_t<T>() const
|
||||||
{
|
{
|
||||||
return atomic_storage<type>::load(m_data);
|
return atomic_storage<type>::load(m_data);
|
||||||
}
|
}
|
||||||
@ -1517,7 +1514,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Conditionally decrement
|
// Conditionally decrement
|
||||||
bool try_dec(simple_type greater_than)
|
bool try_dec(std::common_type_t<T> greater_than)
|
||||||
{
|
{
|
||||||
type _new, old = atomic_storage<type>::load(m_data);
|
type _new, old = atomic_storage<type>::load(m_data);
|
||||||
|
|
||||||
@ -1540,7 +1537,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Conditionally increment
|
// Conditionally increment
|
||||||
bool try_inc(simple_type less_than)
|
bool try_inc(std::common_type_t<T> less_than)
|
||||||
{
|
{
|
||||||
type _new, old = atomic_storage<type>::load(m_data);
|
type _new, old = atomic_storage<type>::load(m_data);
|
||||||
|
|
||||||
@ -1628,8 +1625,6 @@ class atomic_t<bool, Align> : private atomic_t<uchar, Align>
|
|||||||
public:
|
public:
|
||||||
static constexpr usz align = Align;
|
static constexpr usz align = Align;
|
||||||
|
|
||||||
using simple_type = bool;
|
|
||||||
|
|
||||||
atomic_t() noexcept = default;
|
atomic_t() noexcept = default;
|
||||||
|
|
||||||
atomic_t(const atomic_t&) = delete;
|
atomic_t(const atomic_t&) = delete;
|
||||||
@ -1646,6 +1641,9 @@ public:
|
|||||||
return base::load() != 0;
|
return base::load() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override implicit conversion from the parent type
|
||||||
|
explicit operator uchar() const = delete;
|
||||||
|
|
||||||
operator bool() const noexcept
|
operator bool() const noexcept
|
||||||
{
|
{
|
||||||
return base::load() != 0;
|
return base::load() != 0;
|
||||||
@ -1710,6 +1708,17 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Specializations
|
||||||
|
|
||||||
|
template <typename T, usz Align, typename T2, usz Align2>
|
||||||
|
struct std::common_type<atomic_t<T, Align>, atomic_t<T2, Align2>> : std::common_type<T, T2> {};
|
||||||
|
|
||||||
|
template <typename T, usz Align, typename T2>
|
||||||
|
struct std::common_type<atomic_t<T, Align>, T2> : std::common_type<T, std::common_type_t<T2>> {};
|
||||||
|
|
||||||
|
template <typename T, typename T2, usz Align2>
|
||||||
|
struct std::common_type<T, atomic_t<T2, Align2>> : std::common_type<std::common_type_t<T>, T2> {};
|
||||||
|
|
||||||
namespace atomic_wait
|
namespace atomic_wait
|
||||||
{
|
{
|
||||||
template <usz Align>
|
template <usz Align>
|
||||||
|
@ -210,8 +210,6 @@ namespace stx
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
using simple_type = simple_t<T>;
|
|
||||||
|
|
||||||
constexpr operator type() const noexcept
|
constexpr operator type() const noexcept
|
||||||
{
|
{
|
||||||
return value();
|
return value();
|
||||||
@ -265,7 +263,7 @@ public:
|
|||||||
template <typename T2, typename = decltype(+std::declval<const T2&>())>
|
template <typename T2, typename = decltype(+std::declval<const T2&>())>
|
||||||
constexpr bool operator==(const T2& rhs) const noexcept
|
constexpr bool operator==(const T2& rhs) const noexcept
|
||||||
{
|
{
|
||||||
using R = simple_t<T2>;
|
using R = std::common_type_t<T2>;
|
||||||
|
|
||||||
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>))
|
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>))
|
||||||
{
|
{
|
||||||
@ -300,7 +298,7 @@ private:
|
|||||||
template <typename T2>
|
template <typename T2>
|
||||||
static constexpr bool check_args_for_bitwise_op()
|
static constexpr bool check_args_for_bitwise_op()
|
||||||
{
|
{
|
||||||
using R = simple_t<T2>;
|
using R = std::common_type_t<T2>;
|
||||||
|
|
||||||
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>))
|
if constexpr ((std::is_integral_v<T> || std::is_enum_v<T>) && (std::is_integral_v<R> || std::is_enum_v<R>))
|
||||||
{
|
{
|
||||||
@ -473,6 +471,17 @@ public:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specializations
|
||||||
|
|
||||||
|
template <typename T, bool Swap, usz Align, typename T2, bool Swap2, usz Align2>
|
||||||
|
struct std::common_type<stx::se_t<T, Swap, Align>, stx::se_t<T2, Swap2, Align2>> : std::common_type<T, T2> {};
|
||||||
|
|
||||||
|
template <typename T, bool Swap, usz Align, typename T2>
|
||||||
|
struct std::common_type<stx::se_t<T, Swap, Align>, T2> : std::common_type<T, std::common_type_t<T2>> {};
|
||||||
|
|
||||||
|
template <typename T, typename T2, bool Swap2, usz Align2>
|
||||||
|
struct std::common_type<T, stx::se_t<T2, Swap2, Align2>> : std::common_type<std::common_type_t<T>, T2> {};
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -208,22 +208,6 @@ using atomic_be_t = atomic_t<be_t<T>, Align>;
|
|||||||
template <typename T, usz Align = alignof(T)>
|
template <typename T, usz Align = alignof(T)>
|
||||||
using atomic_le_t = atomic_t<le_t<T>, Align>;
|
using atomic_le_t = atomic_t<le_t<T>, Align>;
|
||||||
|
|
||||||
// Extract T::simple_type if available, remove cv qualifiers
|
|
||||||
template <typename T, typename = void>
|
|
||||||
struct simple_type_helper
|
|
||||||
{
|
|
||||||
using type = typename std::remove_cv<T>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct simple_type_helper<T, std::void_t<typename T::simple_type>>
|
|
||||||
{
|
|
||||||
using type = typename T::simple_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using simple_t = typename simple_type_helper<T>::type;
|
|
||||||
|
|
||||||
// Bool type equivalent
|
// Bool type equivalent
|
||||||
class b8
|
class b8
|
||||||
{
|
{
|
||||||
@ -524,7 +508,7 @@ constexpr inline struct umax_helper
|
|||||||
{
|
{
|
||||||
constexpr umax_helper() noexcept = default;
|
constexpr umax_helper() noexcept = default;
|
||||||
|
|
||||||
template <typename T, typename S = simple_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
template <typename T, typename S = std::common_type_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
||||||
constexpr bool operator==(const T& rhs) const
|
constexpr bool operator==(const T& rhs) const
|
||||||
{
|
{
|
||||||
return rhs == static_cast<S>(-1);
|
return rhs == static_cast<S>(-1);
|
||||||
@ -533,24 +517,24 @@ constexpr inline struct umax_helper
|
|||||||
#if __cpp_impl_three_way_comparison >= 201711 && !__INTELLISENSE__
|
#if __cpp_impl_three_way_comparison >= 201711 && !__INTELLISENSE__
|
||||||
#else
|
#else
|
||||||
template <typename T>
|
template <typename T>
|
||||||
friend constexpr std::enable_if_t<std::is_unsigned_v<simple_t<T>>, bool> operator==(const T& lhs, const umax_helper&)
|
friend constexpr std::enable_if_t<std::is_unsigned_v<std::common_type_t<T>>, bool> operator==(const T& lhs, const umax_helper&)
|
||||||
{
|
{
|
||||||
return lhs == static_cast<simple_t<T>>(-1);
|
return lhs == static_cast<std::common_type_t<T>>(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cpp_impl_three_way_comparison >= 201711
|
#if __cpp_impl_three_way_comparison >= 201711
|
||||||
#else
|
#else
|
||||||
template <typename T, typename S = simple_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
template <typename T, typename S = std::common_type_t<T>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
||||||
constexpr bool operator!=(const T& rhs) const
|
constexpr bool operator!=(const T& rhs) const
|
||||||
{
|
{
|
||||||
return rhs != static_cast<S>(-1);
|
return rhs != static_cast<S>(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
friend constexpr std::enable_if_t<std::is_unsigned_v<simple_t<T>>, bool> operator!=(const T& lhs, const umax_helper&)
|
friend constexpr std::enable_if_t<std::is_unsigned_v<std::common_type_t<T>>, bool> operator!=(const T& lhs, const umax_helper&)
|
||||||
{
|
{
|
||||||
return lhs != static_cast<simple_t<T>>(-1);
|
return lhs != static_cast<std::common_type_t<T>>(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} umax;
|
} umax;
|
||||||
@ -784,8 +768,8 @@ struct narrow_impl<From, To, std::enable_if_t<std::is_signed<From>::value && std
|
|||||||
|
|
||||||
// Simple type enabled (TODO: allow for To as well)
|
// Simple type enabled (TODO: allow for To as well)
|
||||||
template <typename From, typename To>
|
template <typename From, typename To>
|
||||||
struct narrow_impl<From, To, std::void_t<typename From::simple_type>>
|
struct narrow_impl<From, To, std::enable_if_t<!std::is_same_v<std::common_type_t<From>, From>>>
|
||||||
: narrow_impl<simple_t<From>, To>
|
: narrow_impl<std::common_type_t<From>, To>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user