summaryrefslogtreecommitdiffstats
path: root/src/common/bit_field.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/bit_field.h26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 4748999ed..8d45743e2 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -1,7 +1,6 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-
// Copyright 2014 Tony Wasserka
// All rights reserved.
//
@@ -29,7 +28,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
#pragma once
#include <cstddef>
@@ -111,9 +109,8 @@
* symptoms.
*/
#pragma pack(1)
-template<std::size_t position, std::size_t bits, typename T>
-struct BitField
-{
+template <std::size_t position, std::size_t bits, typename T>
+struct BitField {
private:
// We hide the copy assigment operator here, because the default copy
// assignment would copy the full storage value, rather than just the bits
@@ -141,13 +138,10 @@ public:
}
FORCE_INLINE T Value() const {
- if (std::numeric_limits<T>::is_signed)
- {
- std::size_t shift = 8 * sizeof(T)-bits;
+ if (std::numeric_limits<T>::is_signed) {
+ std::size_t shift = 8 * sizeof(T) - bits;
return (T)((storage << (shift - position)) >> shift);
- }
- else
- {
+ } else {
return (T)((storage & GetMask()) >> position);
}
}
@@ -162,15 +156,14 @@ private:
// T is an enumeration. Note that T is wrapped within an enable_if in the
// former case to workaround compile errors which arise when using
// std::underlying_type<T>::type directly.
- typedef typename std::conditional < std::is_enum<T>::value,
- std::underlying_type<T>,
- std::enable_if < true, T >> ::type::type StorageType;
+ typedef typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>,
+ std::enable_if<true, T>>::type::type StorageType;
// Unsigned version of StorageType
typedef typename std::make_unsigned<StorageType>::type StorageTypeU;
FORCE_INLINE StorageType GetMask() const {
- return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position;
+ return (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position;
}
StorageType storage;
@@ -186,5 +179,6 @@ private:
#pragma pack()
#if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER)
-static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value, "BitField must be trivially copyable");
+static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value,
+ "BitField must be trivially copyable");
#endif