summaryrefslogtreecommitdiffstats
path: root/src/common/bit_field.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-08-14 15:38:45 +0200
committerLioncash <mathew1800@gmail.com>2020-08-15 23:17:52 +0200
commitdf7248039553b3ebd338380c3ef0428b0e046e79 (patch)
treeeca7153300e311ac7954f5c085fdada0c7295699 /src/common/bit_field.h
parentMerge pull request #4526 from lioncash/core-semi (diff)
downloadyuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar.gz
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar.bz2
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar.lz
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar.xz
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.tar.zst
yuzu-df7248039553b3ebd338380c3ef0428b0e046e79.zip
Diffstat (limited to '')
-rw-r--r--src/common/bit_field.h19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 26ae6c7fc..0f0661172 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -36,13 +36,6 @@
#include "common/common_funcs.h"
#include "common/swap.h"
-// Inlining
-#ifdef _WIN32
-#define FORCE_INLINE __forceinline
-#else
-#define FORCE_INLINE inline __attribute__((always_inline))
-#endif
-
/*
* Abstract bitfield class
*
@@ -142,8 +135,8 @@ public:
* containing several bitfields can be assembled by formatting each of their values and ORing
* the results together.
*/
- static constexpr FORCE_INLINE StorageType FormatValue(const T& value) {
- return ((StorageType)value << position) & mask;
+ [[nodiscard]] static constexpr StorageType FormatValue(const T& value) {
+ return (static_cast<StorageType>(value) << position) & mask;
}
/**
@@ -151,7 +144,7 @@ public:
* (such as Value() or operator T), but this can be used to extract a value from a bitfield
* union in a constexpr context.
*/
- static constexpr FORCE_INLINE T ExtractValue(const StorageType& storage) {
+ [[nodiscard]] static constexpr T ExtractValue(const StorageType& storage) {
if constexpr (std::numeric_limits<UnderlyingType>::is_signed) {
std::size_t shift = 8 * sizeof(T) - bits;
return static_cast<T>(static_cast<UnderlyingType>(storage << (shift - position)) >>
@@ -175,7 +168,7 @@ public:
constexpr BitField(BitField&&) noexcept = default;
constexpr BitField& operator=(BitField&&) noexcept = default;
- constexpr operator T() const {
+ [[nodiscard]] constexpr operator T() const {
return Value();
}
@@ -183,11 +176,11 @@ public:
storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value));
}
- constexpr T Value() const {
+ [[nodiscard]] constexpr T Value() const {
return ExtractValue(storage);
}
- constexpr explicit operator bool() const {
+ [[nodiscard]] constexpr explicit operator bool() const {
return Value() != 0;
}