diff options
Diffstat (limited to 'common/albyte.h')
-rw-r--r-- | common/albyte.h | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/common/albyte.h b/common/albyte.h index f95b92d7..c7f4d219 100644 --- a/common/albyte.h +++ b/common/albyte.h @@ -27,23 +27,6 @@ template<typename T, REQUIRES(std::is_integral<T>::value)> inline constexpr al::byte operator>>(al::byte lhs, T rhs) noexcept { return al::byte(to_integer<unsigned int>(lhs) >> rhs); } -#define AL_DECL_OP(op) \ -template<typename T, REQUIRES(std::is_integral<T>::value)> \ -inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \ -{ return al::byte(to_integer<unsigned int>(lhs) op rhs); } \ -inline constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \ -{ return al::byte(lhs op to_integer<unsigned int>(rhs)); } - -AL_DECL_OP(|) -AL_DECL_OP(&) -AL_DECL_OP(^) - -#undef AL_DECL_OP - -inline constexpr al::byte operator~(al::byte b) noexcept -{ return al::byte(~to_integer<unsigned int>(b)); } - - template<typename T, REQUIRES(std::is_integral<T>::value)> inline al::byte& operator<<=(al::byte &lhs, T rhs) noexcept { lhs = lhs << rhs; return lhs; } @@ -54,8 +37,13 @@ inline al::byte& operator>>=(al::byte &lhs, T rhs) noexcept #define AL_DECL_OP(op) \ template<typename T, REQUIRES(std::is_integral<T>::value)> \ +inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \ +{ return al::byte(to_integer<unsigned int>(lhs) op rhs); } \ +template<typename T, REQUIRES(std::is_integral<T>::value)> \ inline al::byte& operator op##= (al::byte &lhs, T rhs) noexcept \ { lhs = lhs op rhs; return lhs; } \ +inline constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \ +{ return al::byte(lhs op to_integer<unsigned int>(rhs)); } \ inline al::byte& operator op##= (al::byte &lhs, al::byte rhs) noexcept \ { lhs = lhs op rhs; return lhs; } @@ -65,6 +53,10 @@ AL_DECL_OP(^) #undef AL_DECL_OP +inline constexpr al::byte operator~(al::byte b) noexcept +{ return al::byte(~to_integer<unsigned int>(b)); } + + template<size_t N> class bitfield { static constexpr size_t bits_per_byte{std::numeric_limits<unsigned char>::digits}; |