diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-10-21 08:34:06 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-10-22 21:02:04 +0200 |
commit | e6ab1f673b88b1af6bd966886249c7824ec5dbd4 (patch) | |
tree | 045b57ae71c4b8efe34be8504d86638f13cf61ac /src/common/bit_field.h | |
parent | CMakeLists: Remove all redundant warnings (diff) | |
download | yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar.gz yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar.bz2 yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar.lz yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar.xz yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.tar.zst yuzu-e6ab1f673b88b1af6bd966886249c7824ec5dbd4.zip |
Diffstat (limited to '')
-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; } |