mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-11 01:08:39 +12:00
Simplify umax
Add operator less and conversion operator.
This commit is contained in:
parent
b1736b6411
commit
5724d2d4c7
4 changed files with 11 additions and 27 deletions
|
@ -480,39 +480,25 @@ struct get_int_impl<16>
|
|||
};
|
||||
|
||||
// Return magic value for any unsigned type
|
||||
constexpr inline struct umax_helper
|
||||
constexpr struct umax_impl_t
|
||||
{
|
||||
constexpr umax_helper() noexcept = default;
|
||||
|
||||
template <typename T> requires (std::is_unsigned_v<std::common_type_t<T>>) || (std::is_same_v<std::common_type_t<T>, u128>)
|
||||
friend constexpr bool operator==(const umax_helper&, const T& rhs)
|
||||
constexpr bool operator==(const T& rhs) const
|
||||
{
|
||||
return rhs == static_cast<std::common_type_t<T>>(-1);
|
||||
}
|
||||
|
||||
#if __cpp_impl_three_way_comparison >= 201711 && !__INTELLISENSE__
|
||||
#else
|
||||
template <typename T> requires (std::is_unsigned_v<std::common_type_t<T>>) || (std::is_same_v<std::common_type_t<T>, u128>)
|
||||
friend constexpr bool operator==(const T& lhs, const umax_helper&)
|
||||
constexpr bool operator<(const T& rhs) const
|
||||
{
|
||||
return lhs == static_cast<std::common_type_t<T>>(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __cpp_impl_three_way_comparison >= 201711
|
||||
#else
|
||||
template <typename T> requires (std::is_unsigned_v<std::common_type_t<T>>) || (std::is_same_v<std::common_type_t<T>, u128>)
|
||||
friend constexpr bool operator!=(const umax_helper&, const T& rhs)
|
||||
{
|
||||
return rhs != static_cast<std::common_type_t<T>>(-1);
|
||||
return rhs < static_cast<std::common_type_t<T>>(-1);
|
||||
}
|
||||
|
||||
template <typename T> requires (std::is_unsigned_v<std::common_type_t<T>>) || (std::is_same_v<std::common_type_t<T>, u128>)
|
||||
friend constexpr bool operator!=(const T& lhs, const umax_helper&)
|
||||
constexpr operator T() const
|
||||
{
|
||||
return lhs != static_cast<std::common_type_t<T>>(-1);
|
||||
return static_cast<std::common_type_t<T>>(-1);
|
||||
}
|
||||
#endif
|
||||
} umax;
|
||||
|
||||
enum class f16 : u16{};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue