diff options
author | darkf <lw9k123@gmail.com> | 2014-12-29 19:47:41 -0800 |
---|---|---|
committer | darkf <lw9k123@gmail.com> | 2014-12-29 19:47:41 -0800 |
commit | 8ba9ac0f74abb0408a26207a76a0c1808bad8de0 (patch) | |
tree | f1c7c3393fa726435b5b90bf335567c93e528ef1 /src/common/bit_field.h | |
parent | a19354acedbfeafd28219c48a1ec32f76dd17a54 (diff) | |
parent | 3d14eb285382740b144e5b047cb2ad072f6129ea (diff) |
Fix merge conflicts
Diffstat (limited to 'src/common/bit_field.h')
-rw-r--r-- | src/common/bit_field.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 9e02210f9..8eab054b8 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -1,4 +1,4 @@ -// Licensed under GPLv2 +// Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -142,7 +142,7 @@ public: __forceinline BitField& operator=(T val) { - storage = (storage & ~GetMask()) | (((StorageType)val << position) & GetMask()); + Assign(val); return *this; } @@ -151,6 +151,10 @@ public: return Value(); } + __forceinline void Assign(const T& value) { + storage = (storage & ~GetMask()) | (((StorageType)value << position) & GetMask()); + } + __forceinline T Value() const { if (std::numeric_limits<T>::is_signed) @@ -164,6 +168,12 @@ public: } } + // TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015 + __forceinline bool ToBool() const + { + return Value() != 0; + } + private: // StorageType is T for non-enum types and the underlying type of T if // T is an enumeration. Note that T is wrapped within an enable_if in the |