diff options
| author | JosJuice <josjuice@gmail.com> | 2022-08-05 15:39:00 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2022-12-11 08:59:18 +0100 |
| commit | 454537d53efd0579d4cd2a48108f3bdb490b08d2 (patch) | |
| tree | 46f88704bd7fc520d7462d78fe39a4b0c8924153 /Source/Core/Common/BitUtils.h | |
| parent | 48ce5318e1997d02e5544b9ad0b867b055f6fa63 (diff) | |
Replace BitUtils with C++20: RotateLeft/RotateRight
Now that we've flipped the C++20 switch, let's start making use of
the nice new <bit> header.
I'm planning on handling this move away from BitUtils.h incrementally
in a series of PRs. There may be a few functions remaining in
BitUtils.h by the end that C++20 doesn't have any equivalents for.
Diffstat (limited to 'Source/Core/Common/BitUtils.h')
| -rw-r--r-- | Source/Core/Common/BitUtils.h | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/Source/Core/Common/BitUtils.h b/Source/Core/Common/BitUtils.h index 60a6abdc25..273e2a2227 100644 --- a/Source/Core/Common/BitUtils.h +++ b/Source/Core/Common/BitUtils.h @@ -108,50 +108,6 @@ constexpr Result ExtractBits(const T src) noexcept } /// -/// Rotates a value left (ROL). -/// -/// @param value The value to rotate. -/// @param amount The number of bits to rotate the value. -/// @tparam T An unsigned type. -/// -/// @return The rotated value. -/// -template <typename T> -constexpr T RotateLeft(const T value, size_t amount) noexcept -{ - static_assert(std::is_unsigned<T>(), "Can only rotate unsigned types left."); - - amount %= BitSize<T>(); - - if (amount == 0) - return value; - - return static_cast<T>((value << amount) | (value >> (BitSize<T>() - amount))); -} - -/// -/// Rotates a value right (ROR). -/// -/// @param value The value to rotate. -/// @param amount The number of bits to rotate the value. -/// @tparam T An unsigned type. -/// -/// @return The rotated value. -/// -template <typename T> -constexpr T RotateRight(const T value, size_t amount) noexcept -{ - static_assert(std::is_unsigned<T>(), "Can only rotate unsigned types right."); - - amount %= BitSize<T>(); - - if (amount == 0) - return value; - - return static_cast<T>((value >> amount) | (value << (BitSize<T>() - amount))); -} - -/// /// Verifies whether the supplied value is a valid bit mask of the form 0b00...0011...11. /// Both edge cases of all zeros and all ones are considered valid masks, too. /// |
