diff options
author | bunnei <bunneidev@gmail.com> | 2022-10-24 02:25:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 02:25:18 +0200 |
commit | 0313ee77936a696f9135a31ac0b644e6ffe49ae8 (patch) | |
tree | b9e4a934447468338c60add33375409341f5bc7d /src/common/bit_field.h | |
parent | Merge pull request #9095 from FernandoS27/meat-good-vegetable-bad (diff) | |
parent | CMakeLists: Disable -Wbraced-scalar-init on Clang (diff) | |
download | yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar.gz yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar.bz2 yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar.lz yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar.xz yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.tar.zst yuzu-0313ee77936a696f9135a31ac0b644e6ffe49ae8.zip |
Diffstat (limited to 'src/common/bit_field.h')
-rw-r--r-- | src/common/bit_field.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 7e1df62b1..e4e58ea45 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -141,10 +141,6 @@ public: constexpr BitField(BitField&&) noexcept = default; constexpr BitField& operator=(BitField&&) noexcept = default; - [[nodiscard]] constexpr operator T() const { - return Value(); - } - constexpr void Assign(const T& value) { #ifdef _MSC_VER storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); @@ -162,6 +158,17 @@ public: return ExtractValue(storage); } + template <typename ConvertedToType> + [[nodiscard]] constexpr ConvertedToType As() const { + static_assert(!std::is_same_v<T, ConvertedToType>, + "Unnecessary cast. Use Value() instead."); + return static_cast<ConvertedToType>(Value()); + } + + [[nodiscard]] constexpr operator T() const { + return Value(); + } + [[nodiscard]] constexpr explicit operator bool() const { return Value() != 0; } |