aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-06-11 22:29:39 -0700
committerChris Robinson <[email protected]>2019-06-11 22:29:39 -0700
commita2ba230e057d76b73b221f8dc44de17253b843cf (patch)
treea85639edba8bf51bea788f17288eb1ad1bc0054d
parenta478fd4b2506ab5105c7e759762786a9f855cf3e (diff)
Combine two macros into one
-rw-r--r--common/albyte.h26
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};