From b4fbc271d297b084df310e827e241b44bf9532b3 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 24 May 2019 13:30:40 -0700 Subject: [PATCH] Add byte ops that take an integer-based rhs parameter --- common/albyte.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(lhs) >> rhs); } #define AL_DECL_OP(op) \ +template::value,int>::type = 0> \ +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(to_integer(lhs) op to_integer(rhs)); } +{ return al::byte(lhs op to_integer(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::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; }