mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 10:42:47 +01:00
bit_field: Make all methods constexpr.
This commit is contained in:
parent
c6ab2c94d9
commit
0315fe8c3d
1 changed files with 5 additions and 5 deletions
|
@ -115,7 +115,7 @@ private:
|
||||||
// assignment would copy the full storage value, rather than just the bits
|
// assignment would copy the full storage value, rather than just the bits
|
||||||
// relevant to this particular bit field.
|
// relevant to this particular bit field.
|
||||||
// We don't delete it because we want BitField to be trivially copyable.
|
// We don't delete it because we want BitField to be trivially copyable.
|
||||||
BitField& operator=(const BitField&) = default;
|
constexpr BitField& operator=(const BitField&) = default;
|
||||||
|
|
||||||
// StorageType is T for non-enum types and the underlying type of T if
|
// 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
|
// T is an enumeration. Note that T is wrapped within an enable_if in the
|
||||||
|
@ -166,20 +166,20 @@ public:
|
||||||
// so that we can use this within unions
|
// so that we can use this within unions
|
||||||
constexpr BitField() = default;
|
constexpr BitField() = default;
|
||||||
|
|
||||||
FORCE_INLINE operator T() const {
|
constexpr FORCE_INLINE operator T() const {
|
||||||
return Value();
|
return Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE void Assign(const T& value) {
|
constexpr FORCE_INLINE void Assign(const T& value) {
|
||||||
storage = (storage & ~mask) | FormatValue(value);
|
storage = (storage & ~mask) | FormatValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE T Value() const {
|
constexpr T Value() const {
|
||||||
return ExtractValue(storage);
|
return ExtractValue(storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015
|
// TODO: we may want to change this to explicit operator bool() if it's bug-free in VS2015
|
||||||
FORCE_INLINE bool ToBool() const {
|
constexpr FORCE_INLINE bool ToBool() const {
|
||||||
return Value() != 0;
|
return Value() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue