summaryrefslogtreecommitdiffstats
path: root/src/common/bit_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/bit_util.h')
-rw-r--r--src/common/bit_util.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h
index f50d3308a..e4e6287f3 100644
--- a/src/common/bit_util.h
+++ b/src/common/bit_util.h
@@ -1,6 +1,5 @@
-// Copyright 2018 yuzu emulator team
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
+// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -57,4 +56,11 @@ requires std::is_integral_v<T>
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