From 95be6a09b2d93844f3f71396acc40175fd19332c Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Tue, 16 Dec 2014 01:18:56 +0100 Subject: BitField: Add an explicit Assign method. This is useful when doing crazy stuff like inheriting from BitField. --- src/common/bit_field.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/common/bit_field.h') 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: __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::is_signed) -- cgit v1.2.3 From ebfd831ccba32bce097491db3d6bdff0be05935e Mon Sep 17 00:00:00 2001 From: purpasmart96 Date: Tue, 16 Dec 2014 21:38:14 -0800 Subject: License change --- src/common/bit_field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/bit_field.h') diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 9e02210f9..b5977ee56 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. -- cgit v1.2.3 From 0199a7d9ef26516779f73192dd41738ce4116c20 Mon Sep 17 00:00:00 2001 From: Chin Date: Sat, 20 Dec 2014 18:28:17 -0500 Subject: More warning cleanups --- src/common/bit_field.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/common/bit_field.h') diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 3ec061e63..7c633f01f 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -168,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 -- cgit v1.2.3