mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
Implement umax global variable (max unsigned value)
Implements operators == and != comparisons.
This commit is contained in:
parent
70bcb1cd52
commit
0cf35e3b22
1 changed files with 42 additions and 0 deletions
|
@ -409,6 +409,48 @@ struct alignas(16) s128
|
||||||
CHECK_SIZE_ALIGN(u128, 16, 16);
|
CHECK_SIZE_ALIGN(u128, 16, 16);
|
||||||
CHECK_SIZE_ALIGN(s128, 16, 16);
|
CHECK_SIZE_ALIGN(s128, 16, 16);
|
||||||
|
|
||||||
|
// Return magic value for any unsigned type
|
||||||
|
constexpr inline struct umax_helper
|
||||||
|
{
|
||||||
|
constexpr umax_helper() noexcept = default;
|
||||||
|
|
||||||
|
template <typename T, typename S = simple_t<std::decay_t<T>>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
||||||
|
explicit constexpr operator T() const
|
||||||
|
{
|
||||||
|
return std::numeric_limits<S>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, typename S = simple_t<std::decay_t<T>>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
||||||
|
constexpr bool operator==(const T& rhs) const
|
||||||
|
{
|
||||||
|
return rhs == std::numeric_limits<simple_t<std::decay_t<T>>>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __cpp_impl_three_way_comparison >= 201711 && !__INTELLISENSE__
|
||||||
|
#else
|
||||||
|
template <typename T>
|
||||||
|
friend constexpr std::enable_if_t<std::is_unsigned_v<simple_t<std::decay_t<T>>>, bool> operator==(const T& lhs, const umax_helper& rhs)
|
||||||
|
{
|
||||||
|
return rhs == lhs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __cpp_impl_three_way_comparison >= 201711
|
||||||
|
#else
|
||||||
|
template <typename T, typename S = simple_t<std::decay_t<T>>, typename = std::enable_if_t<std::is_unsigned_v<S>>>
|
||||||
|
constexpr bool operator!=(const T& rhs) const
|
||||||
|
{
|
||||||
|
return rhs != std::numeric_limits<simple_t<std::decay_t<T>>>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
friend constexpr std::enable_if_t<std::is_unsigned_v<simple_t<std::decay_t<T>>>, bool> operator!=(const T& lhs, const umax_helper& rhs)
|
||||||
|
{
|
||||||
|
return rhs != lhs;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} umax;
|
||||||
|
|
||||||
using f32 = float;
|
using f32 = float;
|
||||||
using f64 = double;
|
using f64 = double;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue