summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2022-01-11 01:44:19 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2022-01-11 22:01:12 +0100
commitd92b5fc435b5444314fc1ce407a908ba0222f318 (patch)
tree09d1be56d9cb49ec7bbe0ff3663c5f0b9fd8ca84 /src/common
parentMerge pull request #7683 from liushuyu/fmt-8.1 (diff)
downloadyuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar.gz
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar.bz2
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar.lz
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar.xz
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.tar.zst
yuzu-d92b5fc435b5444314fc1ce407a908ba0222f318.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/bit_util.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h
index eef8c1c5a..f50d3308a 100644
--- a/src/common/bit_util.h
+++ b/src/common/bit_util.h
@@ -46,6 +46,12 @@ template <typename T>
}
template <typename T>
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr bool IsPow2(T value) {
+ return std::has_single_bit(value);
+}
+
+template <typename T>
requires std::is_integral_v<T>
[[nodiscard]] T NextPow2(T value) {
return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U)));