From a2ba230e057d76b73b221f8dc44de17253b843cf Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 11 Jun 2019 22:29:39 -0700 Subject: Combine two macros into one --- common/albyte.h | 26 +++++++++----------------- 1 file 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::value)> inline constexpr al::byte operator>>(al::byte lhs, T rhs) noexcept { return al::byte(to_integer(lhs) >> rhs); } -#define AL_DECL_OP(op) \ -template::value)> \ -inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \ -{ return al::byte(to_integer(lhs) op rhs); } \ -inline constexpr al::byte operator op (al::byte lhs, al::byte rhs) noexcept \ -{ return al::byte(lhs op to_integer(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(b)); } - - template::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::value)> \ +inline constexpr al::byte operator op (al::byte lhs, T rhs) noexcept \ +{ return al::byte(to_integer(lhs) op rhs); } \ +template::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(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(b)); } + + template class bitfield { static constexpr size_t bits_per_byte{std::numeric_limits::digits}; -- cgit v1.2.3