mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-23 12:55:41 +01:00
bit_util: Add bit
utility function
Extracts a singular bit, as a bool, from the specified compile-time index.
This commit is contained in:
parent
6f670381cf
commit
add2cfcb96
@ -57,4 +57,11 @@ requires std::is_integral_v<T>
|
|||||||
return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U)));
|
return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <size_t bit_index, typename T>
|
||||||
|
requires std::is_integral_v<T>
|
||||||
|
[[nodiscard]] constexpr bool Bit(const T value) {
|
||||||
|
static_assert(bit_index < BitSize<T>(), "bit_index must be smaller than size of T");
|
||||||
|
return ((value >> bit_index) & T(1)) == T(1);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
Loading…
Reference in New Issue
Block a user