mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
Use c++20 has_single_bit for POT test
This commit is contained in:
parent
99b6963fab
commit
8aec943093
@ -13,6 +13,12 @@ namespace utils
|
||||
{
|
||||
return std::span<T>(bless<T>(span.data()), sizeof(U) * span.size() / sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool is_power_of_2(T value)
|
||||
{
|
||||
return std::has_single_bit(value);
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -385,13 +385,6 @@ namespace utils
|
||||
return static_cast<T>(value / align + (value > 0 ? T{(value % align) > (align / 2)} : 0 - T{(value % align) < (align / 2)}));
|
||||
}
|
||||
|
||||
// Returns true if input is an unsigned integer with a power of 2
|
||||
template <typename T> requires(std::is_integral_v<T> && std::is_unsigned_v<T>)
|
||||
constexpr T is_power_of_2(T value)
|
||||
{
|
||||
return !(value & (value - 1));
|
||||
}
|
||||
|
||||
// Hack. Pointer cast util to workaround UB. Use with extreme care.
|
||||
template <typename T, typename U>
|
||||
[[nodiscard]] T* bless(U* ptr)
|
||||
|
Loading…
Reference in New Issue
Block a user