diff options
| author | 2014-12-16 01:18:56 +0100 | |
|---|---|---|
| committer | 2014-12-20 18:05:53 +0100 | |
| commit | 95be6a09b2d93844f3f71396acc40175fd19332c (patch) | |
| tree | 20feef5f7c8caf80f92fbfe51548dd405c228910 /src/common/bit_field.h | |
| parent | citra-qt: static-constify a map. (diff) | |
| download | yuzu-95be6a09b2d93844f3f71396acc40175fd19332c.tar.gz yuzu-95be6a09b2d93844f3f71396acc40175fd19332c.tar.xz yuzu-95be6a09b2d93844f3f71396acc40175fd19332c.zip | |
BitField: Add an explicit Assign method.
This is useful when doing crazy stuff like inheriting from BitField.
Diffstat (limited to '')
| -rw-r--r-- | src/common/bit_field.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 9e02210f9..3ec061e63 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -142,7 +142,7 @@ public: | |||
| 142 | 142 | ||
| 143 | __forceinline BitField& operator=(T val) | 143 | __forceinline BitField& operator=(T val) |
| 144 | { | 144 | { |
| 145 | storage = (storage & ~GetMask()) | (((StorageType)val << position) & GetMask()); | 145 | Assign(val); |
| 146 | return *this; | 146 | return *this; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| @@ -151,6 +151,10 @@ public: | |||
| 151 | return Value(); | 151 | return Value(); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | __forceinline void Assign(const T& value) { | ||
| 155 | storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask()); | ||
| 156 | } | ||
| 157 | |||
| 154 | __forceinline T Value() const | 158 | __forceinline T Value() const |
| 155 | { | 159 | { |
| 156 | if (std::numeric_limits<T>::is_signed) | 160 | if (std::numeric_limits<T>::is_signed) |