aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-24 13:30:40 -0700
committerChris Robinson <[email protected]>2019-05-24 13:30:40 -0700
commitb4fbc271d297b084df310e827e241b44bf9532b3 (patch)
tree147319249e9627a5f865db978c407f049efe8ad9
parent674ca3cf243acfb4bb698fec86ca1b0da839dc9f (diff)
Add byte ops that take an integer-based rhs parameter
-rw-r--r--common/albyte.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/albyte.h b/common/albyte.h
index 6fc78dbd..f9230005 100644
--- a/common/albyte.h
+++ b/common/albyte.h
@@ -24,8 +24,11 @@ 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, typename std::enable_if<std::is_integral<T>::value,int>::type = 0> \
+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(to_integer<unsigned int>(lhs) op to_integer<unsigned int>(rhs)); }
+{ return al::byte(lhs op to_integer<unsigned int>(rhs)); }
AL_DECL_OP(|)
AL_DECL_OP(&)
@@ -46,6 +49,9 @@ inline al::byte& operator>>=(al::byte &lhs, T rhs) noexcept
{ lhs = lhs >> rhs; return lhs; }
#define AL_DECL_OP(op) \
+template<typename T, typename std::enable_if<std::is_integral<T>::value,int>::type = 0> \
+inline al::byte& operator op##= (al::byte &lhs, T rhs) noexcept \
+{ lhs = lhs op rhs; return lhs; } \
inline al::byte& operator op##= (al::byte &lhs, al::byte rhs) noexcept \
{ lhs = lhs op rhs; return lhs; }